Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resize! when pool=none is in use #2613

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading