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

Update to new alloc cache interface. #2614

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
13 changes: 7 additions & 6 deletions src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,20 @@ mutable struct CuArray{T,N,M} <: AbstractGPUArray{T,N}
maxsize
end

GPUArrays.cached_alloc((CuArray, CUDA.device(), T, bufsize, M)) do
data = DataRef(pool_free, pool_alloc(M, bufsize))
obj = new{T,N,M}(data, maxsize, 0, dims)
finalizer(unsafe_free!, obj)
return obj
end::CuArray{T, N, M}
data = GPUArrays.cached_alloc((CuArray, device(), M, bufsize)) do
DataRef(pool_free, pool_alloc(M, bufsize))
end
obj = new{T,N,M}(data, maxsize, 0, dims)
finalizer(unsafe_free!, obj)
return obj
end

function CuArray{T,N}(data::DataRef{Managed{M}}, dims::Dims{N};
maxsize::Int=prod(dims) * sizeof(T), offset::Int=0) where {T,N,M}
check_eltype(T)
obj = new{T,N,M}(data, maxsize, offset, dims)
finalizer(unsafe_free!, obj)
return obj
end
end

Expand Down
2 changes: 2 additions & 0 deletions src/memory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ mutable struct Managed{M}
end
end

Base.sizeof(managed::Managed) = sizeof(managed.mem)

# wait for the current owner of memory to finish processing
function synchronize(managed::Managed)
synchronize(managed.stream)
Expand Down
Loading