From 7fec8c13ee90ddbd5b450e79fd72b1a6624d1c2c Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Mon, 2 Mar 2026 16:30:53 +0100 Subject: [PATCH 1/3] Update Project.toml Bump version of `Strided` and required version of dependency `StridedViews` --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 3472e21..e5bba9d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Strided" uuid = "5e0ebb24-38b0-5f93-81fe-25c709ecae67" -version = "2.3.2" +version = "2.3.3" authors = ["Lukas Devos ", "Maarten Van Damme ", "Jutho Haegeman "] [deps] @@ -28,7 +28,7 @@ JLArrays = "0.3.1" GPUArrays = "11.4.1" LinearAlgebra = "1.6" Random = "1.6" -StridedViews = "0.4.5" +StridedViews = "0.4.6" Test = "1.6" TupleTools = "1.6" julia = "1.6" From df791808de191278155099dc0c02e6c1924c1698 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Mon, 2 Mar 2026 13:23:24 -0500 Subject: [PATCH 2/3] Make the copy to AbstractArray more general --- ext/StridedGPUArraysExt.jl | 7 +++++++ ext/StridedJLArraysExt.jl | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ext/StridedGPUArraysExt.jl b/ext/StridedGPUArraysExt.jl index 409ad5e..d51a034 100644 --- a/ext/StridedGPUArraysExt.jl +++ b/ext/StridedGPUArraysExt.jl @@ -12,4 +12,11 @@ function Base.Broadcast.BroadcastStyle(gpu_sv::StridedView{T, N, TA}) where {T, return typeof(raw_style)(Val(N)) # sets the dimensionality correctly end +function Base.copy!(dst::AbstractArray{TD, ND}, src::StridedView{TS, NS, TAS, FS}) where {TD <: Number, ND, TS <: Number, NS, TAS <: AbstractGPUArray{TS}, FS <: ALL_FS} + bc_style = Base.Broadcast.BroadcastStyle(TAS) + bc = Base.Broadcast.Broadcasted(bc_style, identity, (src,), axes(dst)) + GPUArrays._copyto!(dst, bc) + return dst +end + end diff --git a/ext/StridedJLArraysExt.jl b/ext/StridedJLArraysExt.jl index 1ea05b5..9ab5b3f 100644 --- a/ext/StridedJLArraysExt.jl +++ b/ext/StridedJLArraysExt.jl @@ -13,11 +13,4 @@ function Base.copy!(dst::StridedView{TD, ND, TAD, FD}, src::StridedView{TS, NS, return dst end -function Base.copy!(dst::AbstractArray{TD, ND}, src::StridedView{TS, NS, TAS, FS}) where {TD <: Number, ND, TS <: Number, NS, TAS <: JLArray{TS}, FS <: ALL_FS} - bc_style = Base.Broadcast.BroadcastStyle(TAS) - bc = Base.Broadcast.Broadcasted(bc_style, identity, (src,), axes(dst)) - GPUArrays._copyto!(dst, bc) - return dst -end - end From 5e02673a7b393bef954dd7534c1bb42948b9f777 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Tue, 3 Mar 2026 10:45:56 +0100 Subject: [PATCH 3/3] Add test for new GPUArrays copy --- test/amd.jl | 3 +++ test/cuda.jl | 3 +++ test/jlarrays.jl | 3 +++ 3 files changed, 9 insertions(+) diff --git a/test/amd.jl b/test/amd.jl index fc77c49..53fdc61 100644 --- a/test/amd.jl +++ b/test/amd.jl @@ -7,12 +7,15 @@ for T in (Float32, Float64, Complex{Float32}, Complex{Float64}) A1 = ROCMatrix(randn(T, (m1, m2))) end A2 = similar(A1) + zA1 = ROCMatrix(f1(zeros(T, (m1, m2)))) + zA2 = ROCMatrix(f2(zeros(T, (m1, m2)))) A1c = copy(A1) A2c = copy(A2) B1 = f1(StridedView(A1c)) B2 = f2(StridedView(A2c)) axes(f1(A1)) == axes(f2(A2)) || continue @test collect(ROCMatrix(copy!(f2(A2), f1(A1)))) == AMDGPU.Adapt.adapt(Vector{T}, copy!(B2, B1)) + @test copy!(zA1, f1(A1)) == copy!(zA2, B1) end end end diff --git a/test/cuda.jl b/test/cuda.jl index 695fec9..5787572 100644 --- a/test/cuda.jl +++ b/test/cuda.jl @@ -3,12 +3,15 @@ for T in (Float32, Float64, Complex{Float32}, Complex{Float64}) for m1 in (0, 16, 32), m2 in (0, 16, 32) A1 = CUDA.randn(T, (m1, m2)) A2 = similar(A1) + zA1 = CuMatrix(f1(zeros(T, (m1, m2)))) + zA2 = CuMatrix(f2(zeros(T, (m1, m2)))) A1c = copy(A1) A2c = copy(A2) B1 = f1(StridedView(A1c)) B2 = f2(StridedView(A2c)) axes(f1(A1)) == axes(f2(A2)) || continue @test collect(CuMatrix(copy!(f2(A2), f1(A1)))) == CUDA.Adapt.adapt(Vector{T}, copy!(B2, B1)) + @test copy!(zA1, f1(A1)) == copy!(zA2, B1) end end end diff --git a/test/jlarrays.jl b/test/jlarrays.jl index 9848347..beb4b58 100644 --- a/test/jlarrays.jl +++ b/test/jlarrays.jl @@ -3,12 +3,15 @@ for T in (Float32, Float64, Complex{Float32}, Complex{Float64}) for m1 in (0, 16, 32), m2 in (0, 16, 32) A1 = JLArray(randn(T, (m1, m2))) A2 = similar(A1) + zA1 = JLArray(f1(zeros(T, (m1, m2)))) + zA2 = JLArray(f2(zeros(T, (m1, m2)))) A1c = copy(A1) A2c = copy(A2) B1 = f1(StridedView(A1c)) B2 = f2(StridedView(A2c)) axes(f1(A1)) == axes(f2(A2)) || continue @test collect(Matrix(copy!(f2(A2), f1(A1)))) == JLArrays.Adapt.adapt(Vector{T}, copy!(B2, B1)) + @test copy!(zA1, f1(A1)) == copy!(zA2, B1) end end end