Skip to content

Commit a1436e1

Browse files
committed
scalar indexing for unified arrays
1 parent eff363d commit a1436e1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/array.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,19 @@ function Base.unsafe_convert(::Type{ZePtr{T}}, x::oneArray{T}) where {T}
345345
end
346346

347347

348+
## indexing
349+
350+
# Host-accessible arrays can be indexed from CPU, bypassing GPUArrays restrictions
351+
function Base.getindex(x::oneArray{<:Any, <:Any, <:Union{oneL0.HostBuffer,oneL0.SharedBuffer}}, I::Int)
352+
@boundscheck checkbounds(x, I)
353+
unsafe_load(pointer(x, I; type=oneL0.HostBuffer))
354+
end
355+
356+
function Base.setindex!(x::oneArray{<:Any, <:Any, <:Union{oneL0.HostBuffer,oneL0.SharedBuffer}}, v, I::Int)
357+
@boundscheck checkbounds(x, I)
358+
unsafe_store!(pointer(x, I; type=oneL0.HostBuffer), v)
359+
end
360+
348361

349362
## interop with GPU arrays
350363

0 commit comments

Comments
 (0)