We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reduce
I am trying to count the number of unique in sorted array. The Base.reduce works as expected but ThreadsX.reduce gives the wrong result.
Base.reduce
ThreadsX.reduce
See
function unique_count_reduce_inner((cnt, last_a), new_a) cnt += (last_a != new_a) cnt, new_a end reduce_nunique(a) = reduce(unique_count_reduce_inner, a; init = (1, a[1]))[1] using ThreadsX treduce_nunique(a) = ThreadsX.reduce(unique_count_reduce_inner, a; init = (1, a[1]))[1] a = rand(1_000_000) sort!(a) @time reduce_nunique(a) # 0.5 @time treduce_nunique(a) # 0.3
The text was updated successfully, but these errors were encountered:
Looks like init as a keyword argument is not supported.
init
julia> mapreduce(identity, +, 1:10, init = 100) 155 julia> ThreadsX.mapreduce(identity, +, 1:10, init = 100) 1055
init is used on each thread instead of only once.
Sorry, something went wrong.
No branches or pull requests
I am trying to count the number of unique in sorted array. The
Base.reduce
works as expected butThreadsX.reduce
gives the wrong result.See
The text was updated successfully, but these errors were encountered: