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

Statistics functions (var,std) slow #411

@denizyuret

Description

@denizyuret

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions