Skip to content

Commit 99cc895

Browse files
committed
A few more tests and fix dim of CuTextureArray in copyto
1 parent 5a08b8d commit 99cc895

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/texture.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ CuTextureArray(A::AbstractArray{T,N}) where {T,N} = CuTextureArray{T,N}(A)
104104

105105
## memory operations
106106

107-
function Base.copyto!(dst::CuTextureArray{T,1}, src::Union{Array{T,1}, CuArray{T,1}, CuTextureArray{T,3}}) where {T}
107+
function Base.copyto!(dst::CuTextureArray{T,1}, src::Union{Array{T,1}, CuArray{T,1}, CuTextureArray{T,1}}) where {T}
108108
size(dst) == size(src) || throw(DimensionMismatch("source and destination sizes must match"))
109109
Base.unsafe_copyto!(pointer(dst), pointer(src), length(dst))
110110
return dst

test/base/texture.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ end
8484
@test Array(fetch_all(tex1D)) == a1D
8585
@test sizeof(texarr1D) == sizeof(a1D)
8686
@test eltype(texarr1D) == Float32
87+
h_arr_1D = zeros(Float32, length(a1D))
88+
Base.unsafe_copyto!(pointer(h_arr_1D), pointer(texarr1D), length(h_arr_1D))
89+
@test h_arr_1D == a1D
90+
cu_arr_1D = CUDA.zeros(Float32, length(a1D))
91+
Base.unsafe_copyto!(pointer(cu_arr_1D), pointer(texarr1D), length(cu_arr_1D))
92+
@test Array(cu_arr_1D) == a1D
8793

8894
texarr2D = CuTextureArray(a2D)
8995
tex2D = CuTexture(texarr2D)
@@ -100,7 +106,6 @@ end
100106
@test sizeof(texarr2D) == sizeof(a2D)
101107
@test eltype(texarr2D) == Float32
102108

103-
104109
tex2D_dir = CuTexture(CuTextureArray(a2D))
105110
@test Array(fetch_all(tex2D_dir)) == a2D
106111

@@ -111,6 +116,7 @@ end
111116
tex3D_2 = CuTexture(texarr3D_2)
112117
@test Array(fetch_all(tex3D_2)) == a3D
113118
texarr3D_3 = CuTextureArray{Float32, 3}(texarr3D)
119+
copyto!(texarr2D_3, texarr2D_2)
114120
tex3D_3 = CuTexture(texarr3D_3)
115121
@test Array(fetch_all(tex3D_3)) == a3D
116122
@test sizeof(texarr3D) == sizeof(a3D)

0 commit comments

Comments
 (0)