Skip to content
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 Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Crayons = "4"
DataFrames = "1"
EnzymeCore = "0.8.2"
ExprTools = "0.1"
GPUArrays = "11.2"
GPUArrays = "11.2.1"
GPUCompiler = "0.24, 0.25, 0.26, 0.27, 1"
KernelAbstractions = "0.9.2"
LLVM = "9.1"
Expand Down
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