@@ -69,7 +69,7 @@ function unsafe_free!(cache::AllocCache)
6969 for (_, pool) in cache. busy
7070 isempty(pool) || error(
7171 " Invalidating allocations cache that's currently in use. " *
72- " Invalidating inside `@enable ` is not allowed."
72+ " Invalidating inside `@cached ` is not allowed."
7373 )
7474 end
7575 for (_, pool) in cache. free
9393const ALLOC_CACHE = ScopedValue{Union{Nothing, AllocCache}}(nothing )
9494
9595"""
96- @enable (cache, expr)
96+ @cached (cache, expr)
9797
9898Evaluate expression `expr` using allocations cache `cache`.
9999
100100When gpu allocation is requested during execution of `expr`,
101101it will first check if there's "free" cache instead of performing an actual allocation.
102102If no "free" allocation exists, an actual allocation is performed.
103103Before returning allocation to the user, it is marked as busy and
104- will not be used by allocation in the scope defined by `@enable `.
104+ will not be used by allocation in the scope defined by `@cached `.
105105
106106**After** the execution of `expr` all "busy" allocations are marked as "free"
107107thus they can be re-used next time the program enters this scope.
@@ -120,7 +120,7 @@ With caching allocator, memory usage stays at exactly `8 GiB`.
120120cache = GPUArrays.AllocCache(CuArray)
121121n = 1024^3
122122for i in 1:1000
123- GPUArrays.@enable cache begin
123+ GPUArrays.@cached cache begin
124124 sin.(CUDA.rand(Float32, n))
125125 end
126126end
129129GPUArrays.unsafe_free!(cache)
130130```
131131
132- See [`@disable `](@ref).
132+ See [`@uncached `](@ref).
133133"""
134- macro enable (cache, expr)
134+ macro cached (cache, expr)
135135 return quote
136136 res = @with $ (esc(ALLOC_CACHE)) => $ (esc(cache)) $ (esc(expr))
137137 free_busy!($ (esc(cache)))
@@ -140,12 +140,12 @@ macro enable(cache, expr)
140140end
141141
142142"""
143- disable (expr)
143+ uncached (expr)
144144
145145Evaluate expression `expr` without using allocations cache.
146- This is useful to call from within `@enable ` to avoid caching some allocations.
146+ This is useful to call from within `@cached ` to avoid caching some allocations.
147147"""
148- macro disable (expr)
148+ macro uncached (expr)
149149 return quote
150150 @with $ (esc(ALLOC_CACHE)) => nothing $ (esc(expr))
151151 end
0 commit comments