3#ifndef GPU_MEMORY_MANAGER_H
4#define GPU_MEMORY_MANAGER_H
16 namespace accelerator {
17 class GPUMemoryManager;
18 #if defined(GPUOffloadingSYCL)
53 typedef std::map< int, std::vector<void*> >
FreePages;
90 return reinterpret_cast<T*
>(
allocateRawData(size *
static_cast<int>(
sizeof(T)), device ) );
Singleton that manages persistent memory on the GPUs.
static int _allocatedMemory
_allocatedMemory and _maxMemory are used to track remaining space on the device.
std::map< int, DeviceMemory > _deviceMemory
Map from device number onto memory.
static GPUMemoryManager & getInstance()
void free(void *devicePointer, DeviceType device)
Free does not actually free data, but instead hands the memory block back to the singleton,...
GPUMemoryManager(const GPUMemoryManager ©)=delete
std::map< void *, int > UsedPages
Counterpart of FreePages, i.e.
static tarch::logging::Log _log
void * allocateRawData(int size, DeviceType device)
Return a pointer to new device data of size size bytes on device.
std::map< int, std::vector< void * > > FreePages
Map of pages (memory blocks) per size.
tarch::multicore::BooleanSemaphore _semaphore
virtual ~GPUMemoryManager()
Invoke clear().
void clear()
Idempotent function.
static constexpr int _maxMemory
GPUMemoryManager()=default
T * allocate(int size, DeviceType device)
Have to include this header, as I need access to the SYCL_EXTERNAL keyword.