Skip to content

Commit 1389800

Browse files
pxl-thmaleadt
andauthored
Support GPUArrays allocations cache (#2593)
Co-authored-by: Tim Besard <[email protected]>
1 parent 73b28c8 commit 1389800

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Diff for: Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Crayons = "4"
5959
DataFrames = "1"
6060
EnzymeCore = "0.8.2"
6161
ExprTools = "0.1"
62-
GPUArrays = "11.1"
62+
GPUArrays = "11.2"
6363
GPUCompiler = "0.24, 0.25, 0.26, 0.27, 1"
6464
KernelAbstractions = "0.9.2"
6565
LLVM = "9.1"

Diff for: src/array.jl

+7-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ mutable struct CuArray{T,N,M} <: AbstractGPUArray{T,N}
7171
else
7272
maxsize
7373
end
74-
data = DataRef(pool_free, pool_alloc(M, bufsize))
75-
obj = new{T,N,M}(data, maxsize, 0, dims)
76-
finalizer(unsafe_free!, obj)
74+
75+
GPUArrays.cached_alloc((CuArray, CUDA.device(), T, bufsize, M)) do
76+
data = DataRef(pool_free, pool_alloc(M, bufsize))
77+
obj = new{T,N,M}(data, maxsize, 0, dims)
78+
finalizer(unsafe_free!, obj)
79+
return obj
80+
end::CuArray{T, N, M}
7781
end
7882

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

0 commit comments

Comments
 (0)