Open xiaodaigh opened 4 years ago
I implemented a function with reduce and ThreadsX.reduce. The threads version failed.
reduce
ThreadsX.reduce
using ThreadsX feature = rand(Int, 1_000_000) target = rand(Bool, 1_000_000) function reduce_groupreduce(feature, target) zft = zip(feature, target) f_fold, t_fold = reduce((u, x) -> begin last_f = last(u[1]) target_sum = last(u[2]) f = x[1] t = x[2] if isequal(f, last_f) u[2][end] += t else push!(u[1], f) push!(u[2], t) end u end, zft; init = (feature[1:1], Int[0])) end @time reduce_groupreduce(feature, target) # this works function reduce_groupreduce(feature, target) zft = zip(feature, target) f_fold, t_fold = ThreadsX.reduce((u, x) -> begin last_f = last(u[1]) target_sum = last(u[2]) f = x[1] t = x[2] if isequal(f, last_f) u[2][end] += t else push!(u[1], f) push!(u[2], t) end u end, zft; init = (feature[1:1], Int[0])) end @time reduce_groupreduce(feature, target) # this doesn't
I implemented a function with
reduce
andThreadsX.reduce
. The threads version failed.