Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "StridedViews"
uuid = "4db3bf67-4bd7-4b4e-b153-31dc3fb37143"
authors = ["Lukas Devos <lukas.devos@ugent.be>", "Jutho Haegeman <jutho.haegeman@ugent.be>"]
version = "0.4.2"
version = "0.4.3"

[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Expand All @@ -25,7 +25,7 @@ PackageExtensionCompat = "1"
PtrArrays = "1.2.0"
Random = "1.6"
Test = "1.6"
julia = "1.6"
julia = "1.10"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Expand Down
13 changes: 7 additions & 6 deletions ext/StridedViewsCUDAExt.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
module StridedViewsCUDAExt

using StridedViews
using StridedView: reinterprettype
using CUDA
using CUDA: Adapt
using CUDA: Adapt, CuPtr

const CuStridedView{T,N,A<:CuArray{T}} = StridedView{T,N,A}

function Adapt.adapt_structure(::Type{T}, A::StridedView) where {T}
return StridedView(Adapt.adapt_structure(T, parent(A)),
A.size, A.strides, A.offset,
A.op, reinterprettype(A))
A.size, A.strides, A.offset, A.op)
end

function Base.unsafe_convert(::Type{CUDA.CuPtr{T}}, a::CuStridedView{T}) where {T}
return pointer(a.parent, a.offset + 1)
function Base.pointer(x::CuStridedView{T}) where {T}
return Base.unsafe_convert(CuPtr{T}, pointer(x.parent, x.offset + 1))
end
function Base.unsafe_convert(::Type{CuPtr{T}}, a::CuStridedView{T}) where {T}
return convert(CuPtr{T}, pointer(a))
end

function Base.print_array(io::IO, X::CuStridedView)
Expand Down
Loading