diff --git a/Grid/allocator/MemoryManager.cc b/Grid/allocator/MemoryManager.cc index 668030e7a..81ad058ee 100644 --- a/Grid/allocator/MemoryManager.cc +++ b/Grid/allocator/MemoryManager.cc @@ -272,7 +272,6 @@ void MemoryManager::InitMessage(void) { #endif } - void *MemoryManager::Insert(void *ptr,size_t bytes,int type) { #ifdef ALLOCATION_CACHE @@ -286,6 +285,46 @@ void *MemoryManager::Insert(void *ptr,size_t bytes,int type) return ptr; #endif } +void MemoryManager::DropCache(void) +{ + // Release every block held in the allocation caches (the "recent + // allocations" pools: Small/Large/Huge x Cpu/Acc/Shared). Blocks in these + // pools are freed from the caller's point of view but still occupy memory; + // after a large setup phase (SUMMA scratch, coarsening temporaries) they can + // hold gigabytes of device memory that hipMalloc then cannot get. Each pool + // is freed with the call that pairs with its allocator. + for(int sz=0;sz<3;sz++) { + int t; + t = Acc+sz; + for(int e=0;e