@@ -393,10 +393,10 @@ an [`OutOfGPUMemoryError`](@ref) if the allocation request cannot be satisfied.
393
393
# (and using Base.@timed/gc_num to exclude that time is too expensive)
394
394
buf, time = _alloc (B, sz; stream)
395
395
396
- memory_use[] += sz
397
- alloc_stats. alloc_count[] += 1
398
- alloc_stats. alloc_bytes[] += sz
399
- alloc_stats. total_time[] += time
396
+ Threads . atomic_add! ( memory_use, sz)
397
+ Threads . atomic_add! ( alloc_stats. alloc_count, 1 )
398
+ Threads . atomic_add! ( alloc_stats. alloc_bytes, sz)
399
+ Threads . atomic_add! ( alloc_stats. total_time, time)
400
400
# NOTE: total_time might be an over-estimation if we trigger GC somewhere else
401
401
402
402
return buf
@@ -445,10 +445,10 @@ Releases a buffer `buf` to the memory pool.
445
445
_free (buf; stream)
446
446
end
447
447
448
- memory_use[] -= sz
449
- alloc_stats. free_count[] += 1
450
- alloc_stats. free_bytes[] += sz
451
- alloc_stats. total_time[] += time
448
+ Threads . atomic_sub! ( memory_use, sz)
449
+ Threads . atomic_add! ( alloc_stats. free_count, 1 )
450
+ Threads . atomic_add! ( alloc_stats. free_bytes, sz)
451
+ Threads . atomic_add! ( alloc_stats. total_time, time)
452
452
catch ex
453
453
Base. showerror_nostdio (ex, " WARNING: Error while freeing $buf " )
454
454
Base. show_backtrace (Core. stdout , catch_backtrace ())
0 commit comments