Skip to content

Commit 8bebc17

Browse files
authored
Merge pull request #259 from JuliaGPU/tb/copyto_empty
Avoid calling copyto kernel with no threads.
2 parents 88114d4 + 8c0f7f4 commit 8bebc17

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/device/execution.jl

+3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ function gpu_call(kernel::Base.Callable, args...;
5757
end
5858

5959
if total_threads !== nothing
60+
@assert total_threads > 0
6061
gpu_call(backend(target), kernel, args, total_threads; name=name)
6162
else
63+
@assert threads > 0
64+
@assert blocks > 0
6265
gpu_call(backend(target), kernel, args, threads, blocks; name=name)
6366
end
6467
end

src/host/abstractarray.jl

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ function Base.copyto!(dest::AbstractGPUArray{T, N}, destcrange::CartesianIndices
136136
throw(DimensionMismatch("Ranges don't match their size. Found: $shape, $(size(srccrange))"))
137137
end
138138
len = length(destcrange)
139+
len == 0 && return dest
139140

140141
dest_offsets = first(destcrange) - one(CartesianIndex{N})
141142
src_offsets = first(srccrange) - one(CartesianIndex{N})

test/testsuite/base.jl

+4
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,9 @@ function test_base(AT)
158158
inds = rand(1:100, 150, 150)
159159
@test compare(x->permutedims(view(x, inds, :), (3, 2, 1)), AT, rand(100, 100))
160160
end
161+
162+
@testset "circshift" begin
163+
@test compare(x->circshift(x, (0,1)), AT, reshape(Vector(1:16), (4,4)))
164+
end
161165
end
162166
end

0 commit comments

Comments
 (0)