Skip to content

Commit 8460cf8

Browse files
authored
Update to new alloc cache interface. (#2614)
1 parent fe0419a commit 8460cf8

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
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.2"
62+
GPUArrays = "11.2.1"
6363
GPUCompiler = "0.24, 0.25, 0.26, 0.27, 1"
6464
KernelAbstractions = "0.9.2"
6565
LLVM = "9.1"

src/array.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,20 @@ mutable struct CuArray{T,N,M} <: AbstractGPUArray{T,N}
7272
maxsize
7373
end
7474

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}
75+
data = GPUArrays.cached_alloc((CuArray, device(), M, bufsize)) do
76+
DataRef(pool_free, pool_alloc(M, bufsize))
77+
end
78+
obj = new{T,N,M}(data, maxsize, 0, dims)
79+
finalizer(unsafe_free!, obj)
80+
return obj
8181
end
8282

8383
function CuArray{T,N}(data::DataRef{Managed{M}}, dims::Dims{N};
8484
maxsize::Int=prod(dims) * sizeof(T), offset::Int=0) where {T,N,M}
8585
check_eltype(T)
8686
obj = new{T,N,M}(data, maxsize, offset, dims)
8787
finalizer(unsafe_free!, obj)
88+
return obj
8889
end
8990
end
9091

src/memory.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,8 @@ mutable struct Managed{M}
516516
end
517517
end
518518

519+
Base.sizeof(managed::Managed) = sizeof(managed.mem)
520+
519521
# wait for the current owner of memory to finish processing
520522
function synchronize(managed::Managed)
521523
synchronize(managed.stream)

0 commit comments

Comments
 (0)