Skip to content

Bug in map? #198

Description

@alfaromartino

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions