Skip to content

Commit 1e5f0d6

Browse files
committed
1 parent 7734190 commit 1e5f0d6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/pointer.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,15 @@ Base.:(==)(x::CuPtr, y::CuPtr) = UInt(x) == UInt(y)
7373
Base.:(<)(x::CuPtr, y::CuPtr) = UInt(x) < UInt(y)
7474
Base.:(-)(x::CuPtr, y::CuPtr) = UInt(x) - UInt(y)
7575

76+
if VERSION >= v"1.12.0-DEV.225"
77+
Base.:(+)(x::CuPtr{T}, y::Integer) where T =
78+
reinterpret(CuPtr{T}, Base.add_ptr(reinterpret(Ptr{T}, x), (y % UInt) % UInt))
79+
Base.:(-)(x::CuPtr{T}, y::Integer) where T =
80+
reinterpret(CuPtr{T}, Base.sub_ptr(reinterpret(Ptr{T}, x), (y % UInt) % UInt))
81+
else
7682
Base.:(+)(x::CuPtr, y::Integer) = oftype(x, Base.add_ptr(UInt(x), (y % UInt) % UInt))
7783
Base.:(-)(x::CuPtr, y::Integer) = oftype(x, Base.sub_ptr(UInt(x), (y % UInt) % UInt))
84+
end
7885
Base.:(+)(x::Integer, y::CuPtr) = y + x
7986

8087

@@ -186,8 +193,15 @@ Base.:(==)(x::CuArrayPtr, y::CuArrayPtr) = UInt(x) == UInt(y)
186193
Base.:(<)(x::CuArrayPtr, y::CuArrayPtr) = UInt(x) < UInt(y)
187194
Base.:(-)(x::CuArrayPtr, y::CuArrayPtr) = UInt(x) - UInt(y)
188195

196+
if VERSION >= v"1.12.0-DEV.225"
197+
Base.:(+)(x::CuArrayPtr{T}, y::Integer) where T =
198+
reinterpret(CuArrayPtr{T}, Base.add_ptr(reinterpret(Ptr{T}, x), (y % UInt) % UInt))
199+
Base.:(-)(x::CuArrayPtr{T}, y::Integer) where T =
200+
reinterpret(CuArrayPtr{T}, Base.sub_ptr(reinterpret(Ptr{T}, x), (y % UInt) % UInt))
201+
else
189202
Base.:(+)(x::CuArrayPtr, y::Integer) = oftype(x, Base.add_ptr(UInt(x), (y % UInt) % UInt))
190203
Base.:(-)(x::CuArrayPtr, y::Integer) = oftype(x, Base.sub_ptr(UInt(x), (y % UInt) % UInt))
204+
end
191205
Base.:(+)(x::Integer, y::CuArrayPtr) = y + x
192206

193207

0 commit comments

Comments
 (0)