Skip to content

Commit

Permalink
Support GPUArrays allocations cache (#2593)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Besard <[email protected]>
  • Loading branch information
pxl-th and maleadt authored Jan 9, 2025
1 parent 73b28c8 commit 1389800
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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.1"
GPUArrays = "11.2"
GPUCompiler = "0.24, 0.25, 0.26, 0.27, 1"
KernelAbstractions = "0.9.2"
LLVM = "9.1"
Expand Down
10 changes: 7 additions & 3 deletions src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ mutable struct CuArray{T,N,M} <: AbstractGPUArray{T,N}
else
maxsize
end
data = DataRef(pool_free, pool_alloc(M, bufsize))
obj = new{T,N,M}(data, maxsize, 0, dims)
finalizer(unsafe_free!, obj)

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}
end

function CuArray{T,N}(data::DataRef{Managed{M}}, dims::Dims{N};
Expand Down

0 comments on commit 1389800

Please sign in to comment.