Skip to content

Commit

Permalink
Merge pull request JuliaGPU#198 from JuliaGPU/tb/register_empty
Browse files Browse the repository at this point in the history
Fix argument error with empty register.
  • Loading branch information
maleadt authored Jan 29, 2020
2 parents aa09aca + a76ba3d commit 1a0ab87
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/memory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ specified, the buffer will also be accessible directly from the GPU. These acces
direct, and go through the PCI bus.
"""
function register(::Type{HostBuffer}, ptr::Ptr, bytesize::Integer, flags=0)
bytesize == 0 && throw(ArgumentError())
bytesize == 0 && throw(ArgumentError("Cannot register an empty range of memory."))

CUDAdrv.cuMemHostRegister(ptr, bytesize, flags)

Expand Down
1 change: 1 addition & 0 deletions test/memory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ end
# pinned memory with existing memory
if attribute(dev, CUDAdrv.DEVICE_ATTRIBUTE_HOST_REGISTER_SUPPORTED) != 0
# can only get GPU pointer if the pinned buffer is mapped
@test_throws ArgumentError Mem.register(Mem.Host, pointer(data), 0)
src = Mem.register(Mem.Host, pointer(data), nb)
@test_throws ArgumentError convert(CuPtr{T}, src)
Mem.unregister(src)
Expand Down

0 comments on commit 1a0ab87

Please sign in to comment.