99 using Base. ScopedValues
1010end
1111
12- const CacheAllocatorName = ScopedValue ( :none )
12+ const CacheAllocatorName = ScopedValue {Union{Nothing, Symbol}} ( nothing )
1313
1414struct CacheAllocator{T <: AbstractGPUArray }
1515 lock:: ReentrantLock
@@ -178,14 +178,13 @@ end
178178"""
179179 @enable AT name expr
180180
181- Evaluate expression `expr` using `name`d caching allocator
182- for the given array type `AT`.
181+ Evaluate expression `expr` using `name`d caching allocator for the given array type `AT`.
183182
184183When gpu allocation is requested during execution of `expr`,
185184allocator will try to use its "free" cache instead of doing an actual allocation.
186185If no "free" allocation exists, an actual allocation is performed.
187186Before returning allocation to the user, it is marked as busy and
188- will not be used by allocation in the scope defined by `@cache_scope `.
187+ will not be used by allocation in the scope defined by `@enable `.
189188
190189**After** the execution of `expr` all "busy" allocations are marked as "free"
191190thus they can be re-used next time the program enters this scope.
@@ -194,17 +193,16 @@ This is useful to apply in a repeating block of code to avoid relying on
194193GC to free gpu memory in time.
195194
196195`name` is a `Symbol` that defines which allocator to use
197- (`:none` is reserved and means no allocator ).
196+ (`nothing`, which is a default, disables it ).
198197
199198# Example
200199
201- In the following example, each iteration of the for-loop requires `2 GiB`
202- of gpu memory.
200+ In the following example, each iteration of the for-loop requires `2 GiB` of gpu memory.
203201Without caching allocator GC wouldn't be able to free arrays in time
204202resulting in higher memory usage.
205203With caching allocator, memory usage stays at exactly `2 GiB`.
206204
207- See [`@no_cache_scope `](@ref), [`invalidate_cache_allocator !`](@ref).
205+ See [`@disable `](@ref), [`invalidate !`](@ref).
208206```julia
209207n = 1024^3
210208for i in 1:1000
@@ -231,7 +229,7 @@ This is useful to call from within `@enable` to avoid caching arrays.
231229"""
232230macro disable (expr)
233231 quote
234- @with $ (esc (CacheAllocatorName)) => :none $ (esc (expr))
232+ @with $ (esc (CacheAllocatorName)) => nothing $ (esc (expr))
235233 end
236234end
237235
0 commit comments