mirror of
https://github.com/paboyle/Grid.git
synced 2026-08-31 14:59:35 +01:00
Memory manager update to drop cache
This commit is contained in:
@@ -272,7 +272,6 @@ void MemoryManager::InitMessage(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *MemoryManager::Insert(void *ptr,size_t bytes,int type)
|
void *MemoryManager::Insert(void *ptr,size_t bytes,int type)
|
||||||
{
|
{
|
||||||
#ifdef ALLOCATION_CACHE
|
#ifdef ALLOCATION_CACHE
|
||||||
@@ -286,6 +285,46 @@ void *MemoryManager::Insert(void *ptr,size_t bytes,int type)
|
|||||||
return ptr;
|
return ptr;
|
||||||
#endif
|
#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<Ncache[t];e++) {
|
||||||
|
if( Entries[t][e].valid ) {
|
||||||
|
acceleratorFreeDevice(Entries[t][e].address);
|
||||||
|
Entries[t][e].valid = 0; Entries[t][e].bytes = 0; Entries[t][e].address = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CacheBytes[t]=0; Victim[t]=0;
|
||||||
|
t = Shared+sz;
|
||||||
|
for(int e=0;e<Ncache[t];e++) {
|
||||||
|
if( Entries[t][e].valid ) {
|
||||||
|
acceleratorFreeShared(Entries[t][e].address);
|
||||||
|
Entries[t][e].valid = 0; Entries[t][e].bytes = 0; Entries[t][e].address = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CacheBytes[t]=0; Victim[t]=0;
|
||||||
|
t = Cpu+sz;
|
||||||
|
for(int e=0;e<Ncache[t];e++) {
|
||||||
|
if( Entries[t][e].valid ) {
|
||||||
|
#ifdef GRID_UVM
|
||||||
|
acceleratorFreeShared(Entries[t][e].address);
|
||||||
|
#else
|
||||||
|
acceleratorFreeCpu(Entries[t][e].address);
|
||||||
|
#endif
|
||||||
|
Entries[t][e].valid = 0; Entries[t][e].bytes = 0; Entries[t][e].address = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CacheBytes[t]=0; Victim[t]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void *MemoryManager::Insert(void *ptr,size_t bytes,AllocationCacheEntry *entries,int ncache,int &victim, uint64_t &cacheBytes)
|
void *MemoryManager::Insert(void *ptr,size_t bytes,AllocationCacheEntry *entries,int ncache,int &victim, uint64_t &cacheBytes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ public:
|
|||||||
static void Print(void);
|
static void Print(void);
|
||||||
static void PrintAll(void);
|
static void PrintAll(void);
|
||||||
static void EvictAll(void);
|
static void EvictAll(void);
|
||||||
|
static void DropCache(void);
|
||||||
static void PrintState( void* CpuPtr);
|
static void PrintState( void* CpuPtr);
|
||||||
static int isOpen (void* CpuPtr);
|
static int isOpen (void* CpuPtr);
|
||||||
static void ViewClose(void* CpuPtr,ViewMode mode);
|
static void ViewClose(void* CpuPtr,ViewMode mode);
|
||||||
|
|||||||
@@ -967,6 +967,9 @@ int main (int argc, char ** argv)
|
|||||||
// coarsening temporaries) goes back to host, so the solve's working set
|
// coarsening temporaries) goes back to host, so the solve's working set
|
||||||
// starts from a clean device and the cap applies to it alone.
|
// starts from a clean device and the cap applies to it alone.
|
||||||
MemoryManager::EvictAll();
|
MemoryManager::EvictAll();
|
||||||
|
// ...and release the allocation caches' held blocks (setup-era deviceVector
|
||||||
|
// scratch that is "free" to the caller but not to hipMalloc).
|
||||||
|
MemoryManager::DropCache();
|
||||||
MemoryManager::PrintBytes();
|
MemoryManager::PrintBytes();
|
||||||
acceleratorMem();
|
acceleratorMem();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user