Open nomadbl opened 9 months ago
In particular, I want to hear if there's something I'm missing like some memory contiguous requirements etc.
Not really; support for wrapped arrays in Julia just... isn't great. We have functionality for scalar and vectorized indexing implemented here, https://github.com/JuliaGPU/GPUArrays.jl/blob/master/src/host/indexing.jl, where the vectorized_getindex
functionality in principle supports any kind of array-like GPU input (i.e. not just a JLArray, but also its transpose). However, to make Julia pick up those definitions, we'd need to extend the getindex
definition to cover any wrapped AbstractGPUArrays
, which the type system just isn't great at. We have an Adapt.jl-based AnyGPUArray
type, but that's a horrible union which significantly slows down method deserialization, only covers one level of wrapping, and introduces lots of ambiguities. As such, I'm wary to just extend all our functions from ::AbstractGPUArray
to ::AnyGPUArray
. This probably needs a more fundamental fix, maybe something like https://github.com/JuliaLang/julia/issues/51910.
Ok thanks for your response. For now it looks like the PR I linked will at least alleviate some issues but a more general fix would be nice at some point. Perhaps it is also a matter of time and accumulated experience that's needed...
I wasn't sure how much this issue overlaps with existing ones, so apologies if this is a duplicate. I constantly get into the aforementioned scalar indexing issue when working with
transpose
. I opened a new PR (https://github.com/JuliaLang/julia/pull/52626) on base Julia intended to fix the problem, so I wanted to raise awareness and get feedback from the experts here as well.copying the MWE here to demonstrate the error (which is avoided after the PR changes):
In particular, I want to hear if there's something I'm missing like some memory contiguous requirements etc. Cheers