Open
Description
Hello, I've recently noticed that GPUArrays don't define a Base.hash
implementation and fallback to the default one. This requires one to @allowscalar
which is slow and also means one has to differentiate between CPU and GPU arrays when calling hash.
MWE:
using GPUArrays, CUDA
A = cu(rand(1024, 1024))
hash(A) # errors
@allowscalar Base.hash(A) # slow
I'm not sure what a good implementation for GPU arrays would be. An inefficient GPU default could be:
Base.hash(arr::T, h) where T <: AbstractGPUArray = mapreduce(hash, hash, arr; init = hash(T, h))
That of course touches every element and works with UInt64
values, but it would be faster than the normal default.
From what I can tell the default Base.hash for arrays is accessing O(log n) elements. I'm not sure how to neatly map such a pattern onto GPUs, if someone has any pointers I'd be happy to implement it
Metadata
Metadata
Assignees
Labels
No labels