Skip to content

Commit 3a2b1dc

Browse files
authored
Update to GPUArrays@11.1 (#693)
1 parent e26bb96 commit 3a2b1dc

File tree

5 files changed

+27
-76
lines changed

5 files changed

+27
-76
lines changed

Project.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ UnsafeAtomicsLLVM = "d80eeb9a-aca5-4d75-85e5-170c8b632249"
3535

3636
[compat]
3737
AbstractFFTs = "1.0"
38-
AcceleratedKernels = "0.1, 0.2"
38+
AcceleratedKernels = "0.2"
3939
Adapt = "4"
4040
Atomix = "0.1"
4141
CEnum = "0.4, 0.5"
4242
ExprTools = "0.1"
43-
GPUArrays = "10"
43+
GPUArrays = "11.1"
4444
GPUCompiler = "0.27, 1.0"
4545
KernelAbstractions = "0.9.2"
4646
LLD_jll = "15, 16, 17"

src/AMDGPU.jl

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ include("tls.jl")
114114
include("highlevel.jl")
115115
include("reflection.jl")
116116
include("array.jl")
117-
include("gpuarrays.jl")
118117
include("conversions.jl")
119118
include("broadcast.jl")
120119
include("exception_handler.jl")

src/array.jl

+25-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ mutable struct ROCArray{T, N, B} <: AbstractGPUArray{T, N}
2121
end
2222
end
2323

24-
unsafe_free!(x::ROCArray) = GPUArrays.unsafe_free!(x.buf)
24+
GPUArrays.storage(a::ROCArray) = a.buf
25+
26+
function GPUArrays.derive(
27+
::Type{T}, x::ROCArray, dims::Dims{N}, offset::Int,
28+
) where {N, T}
29+
ref = copy(x.buf)
30+
offset += (x.offset * Base.elsize(x)) ÷ sizeof(T)
31+
ROCArray{T, N}(ref, dims; offset)
32+
end
2533

2634
"""
2735
device(A::ROCArray) -> HIPDevice
@@ -276,3 +284,19 @@ function Base.resize!(A::ROCVector{T}, n::Integer) where T
276284
A.offset = 0
277285
return A
278286
end
287+
288+
# @roc conversion
289+
290+
function Base.convert(
291+
::Type{ROCDeviceArray{T, N, AS.Global}}, a::ROCArray{T, N},
292+
) where {T, N}
293+
# If HostBuffer, use device pointer.
294+
buf = convert(Mem.AbstractAMDBuffer, a.buf[])
295+
ptr = convert(Ptr{T}, typeof(buf) <: Mem.HIPBuffer ?
296+
buf : buf.dev_ptr)
297+
llvm_ptr = AMDGPU.LLVMPtr{T,AS.Global}(ptr + a.offset * sizeof(T))
298+
ROCDeviceArray{T, N, AS.Global}(a.dims, llvm_ptr)
299+
end
300+
301+
Adapt.adapt_storage(::Runtime.Adaptor, x::ROCArray{T,N}) where {T,N} =
302+
convert(ROCDeviceArray{T,N,AS.Global}, x)

src/gpuarrays.jl

-69
This file was deleted.

test/gpuarrays_tests.jl

-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ end
3030
@testitem "gpuarrays - indexing scalar" setup=[TSGPUArrays] begin
3131
gpuarrays_test("indexing scalar")
3232
end
33-
@testitem "gpuarrays - interface" setup=[TSGPUArrays] begin
34-
gpuarrays_test("interface")
35-
end
3633
@testitem "gpuarrays - linalg" setup=[TSGPUArrays] begin
3734
gpuarrays_test("linalg")
3835
end

0 commit comments

Comments
 (0)