Skip to content

Commit 92181a0

Browse files
authored
More tests for CuRef/CuRefArray (#2706)
1 parent ab74bfc commit 92181a0

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

test/core/pointer.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,20 @@ end
7777
cuarr = CUDA.CuArray([1])
7878
@test Base.cconvert(CuRef{Int}, cuarr) isa CUDA.CuRefArray{Int, typeof(cuarr)}
7979
@test Base.unsafe_convert(CuRef{Int}, Base.cconvert(CuRef{Int}, cuarr)) == Base.bitcast(CuRef{Int}, pointer(cuarr))
80+
81+
ref = CuRef{Int64}(1)
82+
@test eltype(ref) == Int64
83+
@test convert(CuRef{Int64}, ref) === ref
84+
@test sprint(show, ref) == "CuRefValue{Int64}(1)"
85+
@test ref[] == 1
86+
@test Base.unsafe_convert(CuPtr{Cvoid}, ref) isa CuPtr{Cvoid}
87+
88+
arr_ref = convert(CuRef{Int64}, CUDA.ones(Int64, 1))
89+
@test eltype(arr_ref) == Int64
90+
@test convert(CuRef{Int64}, arr_ref) === arr_ref
91+
@test sprint(show, arr_ref) == "CuRefArray{Int64}(1)"
92+
@test arr_ref[] == 1
93+
arr_ref[] = zero(Int64)
94+
@test arr_ref[] == 0
95+
@test Base.unsafe_convert(CuPtr{Cvoid}, arr_ref) isa CuPtr{Cvoid}
8096
end

0 commit comments

Comments
 (0)