This repository has been archived by the owner on Mar 12, 2021. It is now read-only.
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.
Statistics functions (var,std) slow #411
Closed
Description
openedon Sep 7, 2019
var/std seem to fall back on indexing the CuArray, instead of a vectorized implementation:
julia> var(c,dims=1)
┌ Warning: Performing scalar operations on GPU arrays: This is very slow, consider disallowing these operations with `allowscalar(false)`
└ @ GPUArrays ~/.julia/packages/GPUArrays/J4c3Q/src/indexing.jl:16
1×4 CuArray{Float32,2}:
0.0646661 0.167767 0.0156315 0.14948
This makes it slower than cpu:
julia> c1 = rand(1000,1000);
julia> c2 = CuArray(c1);
julia> @time std(c1,dims=1);
0.001371 seconds (12 allocations: 16.250 KiB)
julia> @time std(c2,dims=1);
7.945594 seconds (3.01 M allocations: 138.023 MiB, 0.39% gc time)
julia> @time CuArray(std(Array(c2),dims=1))
0.003153 seconds (23 allocations: 7.661 MiB)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment