diff --git a/Grid/allocator/MemoryManager.h b/Grid/allocator/MemoryManager.h index eafcd83f..740d8d92 100644 --- a/Grid/allocator/MemoryManager.h +++ b/Grid/allocator/MemoryManager.h @@ -170,6 +170,7 @@ private: public: static void Print(void); + static void PrintState( void* CpuPtr); static int isOpen (void* CpuPtr); static void ViewClose(void* CpuPtr,ViewMode mode); static void *ViewOpen (void* CpuPtr,size_t bytes,ViewMode mode,ViewAdvise hint); diff --git a/Grid/allocator/MemoryManagerCache.cc b/Grid/allocator/MemoryManagerCache.cc index 72111dbd..61dc1125 100644 --- a/Grid/allocator/MemoryManagerCache.cc +++ b/Grid/allocator/MemoryManagerCache.cc @@ -474,6 +474,35 @@ int MemoryManager::isOpen (void* _CpuPtr) } } +void MemoryManager::PrintState(void* _CpuPtr) +{ + uint64_t CpuPtr = (uint64_t)_CpuPtr; + + if ( EntryPresent(CpuPtr) ){ + auto AccCacheIterator = EntryLookup(CpuPtr); + auto & AccCache = AccCacheIterator->second; + std::string str; + if ( AccCache.state==Empty ) str = std::string("Empty"); + if ( AccCache.state==CpuDirty ) str = std::string("CpuDirty"); + if ( AccCache.state==AccDirty ) str = std::string("AccDirty"); + if ( AccCache.state==Consistent)str = std::string("Consistent"); + if ( AccCache.state==EvictNext) str = std::string("EvictNext"); + + std::cout << GridLogMessage << "--------------------------------------------" << std::endl; + std::cout << GridLogMessage << "CpuAddr\t\tAccAddr\t\tState\t\tcpuLock\taccLock\tLRU_valid "<Device memory movement not currently managed by Grid." << std::endl; +}; void MemoryManager::Print(void){}; void MemoryManager::NotifyDeletion(void *ptr){}; diff --git a/Grid/lattice/Lattice_base.h b/Grid/lattice/Lattice_base.h index 3ad9f913..9c3d723f 100644 --- a/Grid/lattice/Lattice_base.h +++ b/Grid/lattice/Lattice_base.h @@ -88,6 +88,13 @@ public: LatticeView accessor(*( (LatticeAccelerator *) this),mode); accessor.ViewClose(); } + + // Helper function to print the state of this object in the AccCache + void PrintCacheState(void) + { + MemoryManager::PrintState(this->_odata); + } + ///////////////////////////////////////////////////////////////////////////////// // Return a view object that may be dereferenced in site loops. // The view is trivially copy constructible and may be copied to an accelerator device