mirror of
https://github.com/paboyle/Grid.git
synced 2025-05-10 04:25:57 +01:00
Update to memory manager, never have a Cpu Open in the LRU queue. Place as evict next on CPU closure.
This commit is contained in:
parent
135808dcfa
commit
b0bd173899
@ -114,6 +114,11 @@ private:
|
||||
static uint64_t HostToDeviceXfer;
|
||||
static uint64_t DeviceToHostXfer;
|
||||
|
||||
static uint64_t DeviceAccesses;
|
||||
static uint64_t HostAccesses;
|
||||
static uint64_t DeviceAccessBytes;
|
||||
static uint64_t HostAccessBytes;
|
||||
|
||||
private:
|
||||
#ifndef GRID_UVM
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -152,6 +157,7 @@ private:
|
||||
|
||||
// static void LRUupdate(AcceleratorViewEntry &AccCache);
|
||||
static void LRUinsert(AcceleratorViewEntry &AccCache);
|
||||
static void LRUinsertback(AcceleratorViewEntry &AccCache);
|
||||
static void LRUremove(AcceleratorViewEntry &AccCache);
|
||||
|
||||
// manage entries in the table
|
||||
|
@ -86,6 +86,14 @@ void MemoryManager::LRUinsert(AcceleratorViewEntry &AccCache)
|
||||
AccCache.LRU_valid = 1;
|
||||
DeviceLRUBytes+=AccCache.bytes;
|
||||
}
|
||||
void MemoryManager::LRUinsertback(AcceleratorViewEntry &AccCache)
|
||||
{
|
||||
assert(AccCache.LRU_valid==0);
|
||||
LRU.push_back(AccCache.CpuPtr);
|
||||
AccCache.LRU_entry = --LRU.end();
|
||||
AccCache.LRU_valid = 1;
|
||||
DeviceLRUBytes+=AccCache.bytes;
|
||||
}
|
||||
void MemoryManager::LRUremove(AcceleratorViewEntry &AccCache)
|
||||
{
|
||||
assert(AccCache.LRU_valid==1);
|
||||
@ -129,6 +137,7 @@ void MemoryManager::Evict(AcceleratorViewEntry &AccCache)
|
||||
dprintf("MemoryManager: Evict(%llx) %llx\n",(uint64_t)AccCache.CpuPtr,(uint64_t)AccCache.AccPtr);
|
||||
assert(AccCache.accLock==0);
|
||||
assert(AccCache.cpuLock==0);
|
||||
|
||||
if(AccCache.state==AccDirty) {
|
||||
Flush(AccCache);
|
||||
}
|
||||
@ -231,6 +240,9 @@ uint64_t MemoryManager::AcceleratorViewOpen(uint64_t CpuPtr,size_t bytes,ViewMod
|
||||
EntryCreate(CpuPtr,bytes,mode,hint);
|
||||
}
|
||||
|
||||
DeviceAccesses++;
|
||||
DeviceAccessBytes+=bytes;
|
||||
|
||||
auto AccCacheIterator = EntryLookup(CpuPtr);
|
||||
auto & AccCache = AccCacheIterator->second;
|
||||
if (!AccCache.AccPtr) {
|
||||
@ -349,6 +361,10 @@ void MemoryManager::CpuViewClose(uint64_t CpuPtr)
|
||||
assert(AccCache.accLock==0);
|
||||
|
||||
AccCache.cpuLock--;
|
||||
|
||||
if(AccCache.cpuLock==0) {
|
||||
LRUinsertback(AccCache);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Action State StateNext Flush Clone
|
||||
@ -371,6 +387,9 @@ uint64_t MemoryManager::CpuViewOpen(uint64_t CpuPtr,size_t bytes,ViewMode mode,V
|
||||
EntryCreate(CpuPtr,bytes,mode,transient);
|
||||
}
|
||||
|
||||
HostAccesses++;
|
||||
HostAccessBytes+=bytes;
|
||||
|
||||
auto AccCacheIterator = EntryLookup(CpuPtr);
|
||||
auto & AccCache = AccCacheIterator->second;
|
||||
|
||||
@ -416,6 +435,12 @@ uint64_t MemoryManager::CpuViewOpen(uint64_t CpuPtr,size_t bytes,ViewMode mode,V
|
||||
|
||||
AccCache.transient= transient? EvictNext : 0;
|
||||
|
||||
// If view is opened on host remove from LRU
|
||||
// Host close says evict next from device
|
||||
if(AccCache.LRU_valid==1){
|
||||
LRUremove(AccCache);
|
||||
}
|
||||
|
||||
return AccCache.CpuPtr;
|
||||
}
|
||||
void MemoryManager::NotifyDeletion(void *_ptr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user