Skip to content

Commit

Permalink
Fix resize! when pool=none is in use (JuliaGPU#2613)
Browse files Browse the repository at this point in the history
  • Loading branch information
luraess authored and avik-pal committed Jan 11, 2025
1 parent d6628c3 commit f93ad96
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/cudadrv/memory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ GPU, and requires explicit calls to `unsafe_copyto!`, which wraps `cuMemcpy`,
for access on the CPU.
"""
function alloc(::Type{DeviceMemory}, bytesize::Integer;
async::Bool=memory_pools_supported(device()),
async::Bool=false,
stream::Union{Nothing,CuStream}=nothing,
pool::Union{Nothing,CuMemoryPool}=nothing)
bytesize == 0 && return DeviceMemory()
Expand Down
4 changes: 2 additions & 2 deletions src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -838,14 +838,14 @@ function Base.resize!(A::CuVector{T}, n::Integer) where T
# replace the data with a new one. this 'unshares' the array.
# as a result, we can safely support resizing unowned buffers.
new_data = context!(context(A)) do
mem = alloc(memory_type(A), bufsize)
mem = pool_alloc(memory_type(A), bufsize)
ptr = convert(CuPtr{T}, mem)
m = min(length(A), n)
if m > 0
synchronize(A)
unsafe_copyto!(ptr, pointer(A), m)
end
DataRef(pool_free, Managed(mem))
DataRef(pool_free, mem)
end
unsafe_free!(A)

Expand Down

0 comments on commit f93ad96

Please sign in to comment.