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

findmax slow #606

Closed
saswatpp opened this issue Feb 24, 2020 · 2 comments
Closed

findmax slow #606

saswatpp opened this issue Feb 24, 2020 · 2 comments
Labels

Comments

@saswatpp
Copy link

findmax function is slower than cpu counter part. CuArrays.allowscalar(false) seems to worsen the condition.

julia> a = [1.0 2.0 3.0; 1.2 4.2 5.3] |> gpu
2×3 CuArray{Float32,2,Nothing}:
 1.0  2.0  3.0
 1.2  4.2  5.3

julia> b = [1.0 2.0 3.0; 1.2 4.2 5.3]
2×3 Array{Float64,2}:
 1.0  2.0  3.0
 1.2  4.2  5.3

julia> @time findmax(b)
  0.000003 seconds (5 allocations: 192 bytes)
(5.3, CartesianIndex(2, 3))

julia> @time findmax(a)
  0.026677 seconds (224 allocations: 7.500 KiB)
(5.3f0, CartesianIndex(2, 3))

julia> CuArrays.allowscalar(false)

julia> @time findmax(a)
  0.648799 seconds (224 allocations: 7.500 KiB)
(5.3f0, CartesianIndex(2, 3))
@saswatpp saswatpp added the bug label Feb 24, 2020
@saswatpp
Copy link
Author

Arrays too small for gpu operation comparision. Mybad. Ofcourse Results are good on very large arrays.

@maleadt
Copy link
Member

maleadt commented Feb 25, 2020

CuArrays.allowscalar(false) seems to worsen the condition.

That would be unlikely here. FWIW, you better use BenchmarkTools in the future, e.g. @btime CuArrays.@sync ...

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

No branches or pull requests

2 participants