Skip to content
New issue

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

Bug in map? #198

Open
alfaromartino opened this issue Feb 19, 2023 · 1 comment
Open

Bug in map? #198

alfaromartino opened this issue Feb 19, 2023 · 1 comment

Comments

@alfaromartino
Copy link

alfaromartino commented Feb 19, 2023

I think there's a bug in ThreadsX.map. I initialized Julia with 16 threads.

MWE

using ThreadsX, BenchmarkTools

list1 = rand(50_000_000) .* 100
list2 = rand(50_000_000) .* 100

#OPERATION
foo(x,y) = 100 + x * y + log(x) * 2 / y

with results

@btime ThreadsX.map(foo, list1, list2); #302.361 ms (2771 allocations: 2.39 GiB)

@btime map(foo, list1, list2); #  213.384 ms (4 allocations: 381.47 MiB)

If I run @code_warntype ThreadsX.map(foo, list1, list2);, it shows that the function is type unstable.

REMARK: This is NOT a problem that occurs with ThreadsX.map! or with vmapntt! from LoopVectorization

using LoopVectorization

output = similar(list1)
@btime ThreadsX.map!(foo, output, list1, list2) # 32.265 ms (916 allocations: 88.42 KiB)
@btime vmapntt!(foo, output, list1, list2) # 26.963 ms (0 allocations: 0 bytes)

EDIT: I realized that this seems to be similar to #196 by @bkamins

@MasonProtter
Copy link

Hoping to mitigate this somewhat with JuliaFolds/Transducers.jl#553. However, Transducers.jl (and by extension, ThreadsX.jl), is at it's worst when dealing with very fast functions like your foo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants