Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Implement findall #446

Merged
merged 2 commits into from
Oct 10, 2019
Merged

Implement findall #446

merged 2 commits into from
Oct 10, 2019

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Oct 10, 2019

Not a very fast implementation (see #445), but a big improvement over scalar indexing nonetheless:

# CPU
julia> for i in (100, 1_000, 10_000, 100_000)
       @btime findall($(rand(Bool, i)));
       end
  120.487 ns (1 allocation: 496 bytes)
  1.131 μs (1 allocation: 4.06 KiB)
  36.526 μs (2 allocations: 38.64 KiB)
  392.674 μs (2 allocations: 389.20 KiB)

# GPU
julia> for i in (100, 1_000, 10_000, 100_000)
       @btime findall($(CuArray(rand(Bool, i))));
       end
  127.818 μs (505 allocations: 16.27 KiB)
  162.533 μs (672 allocations: 21.36 KiB)
  210.293 μs (900 allocations: 28.23 KiB)
  243.953 μs (1071 allocations: 33.39 KiB)

# GPU (scalar version)
julia> for i in (100, 1_000, 10_000, 100_000)
       @btime findall($(CuArray(rand(Bool, i))));
       end
  517.373 μs (308 allocations: 16.44 KiB)
  5.182 ms (3496 allocations: 168.83 KiB)
  53.216 ms (39498 allocations: 1.72 MiB)
  538.223 ms (399573 allocations: 17.16 MiB)

cc @ChrisRackauckas

Use the launch configuration API, and eagerly put temporary arrays back in the pool.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant