Analysis Software
Documentation for sPHENIX simulation software
|
#include <acts/blob/sPHENIX/Plugins/Cuda/include/Acts/Plugins/Cuda/Utilities/MemoryManager.hpp>
Classes | |
struct | DeviceMemory |
Public Member Functions | |
~MemoryManager () | |
Destructor, freeing up all allocated memory. | |
Declarations preventing any copies of the singleton object | |
MemoryManager (const MemoryManager &)=delete | |
Disallow copy construction. | |
MemoryManager (MemoryManager &&)=delete | |
Disallow move construction. | |
MemoryManager & | operator= (const MemoryManager &)=delete |
Disallow copy assignment. | |
MemoryManager & | operator= (MemoryManager &&)=delete |
Disallow move assignment. | |
Functions used internally by the Acts code | |
std::size_t | availableMemory (int device=-1) const |
Get the amount of memory still available on a specific device. | |
void * | allocate (std::size_t sizeInBytes, int device=-1) |
Get a pointer to an available memory block on the device. | |
void | reset (int device=-1) |
Reset all allocations. | |
Private Member Functions | |
MemoryManager () | |
Hide the constructor of the class. | |
Private Attributes | |
std::vector< DeviceMemory > | m_memory |
Object holding information about memory allocations on all devices. | |
Functions that the users of Acts may be interacting with | |
void | setMemorySize (std::size_t sizeInBytes, int device=-1) |
Set the amount of memory to use on a particular device. | |
static MemoryManager & | instance () |
Singleton object accessor. | |
Singleton class used for allocating memory on CUDA device(s)
In order to avoid calling cudaMalloc
(...) and cudaFree
(...) too many times in the code (which can turn out to be pretty slow), device memory is allocated using this singleton memory manager for the Acts::Cuda::device_array
arrays.
It is implemented in a very simple way. It allocates a big blob of memory, and then hands out pointers from this blob to anyone that asks for device memory.
The class doesn't handle memory returns in any sophisticated way. It assumes that any calculation will need all allocated memory until the end of that calculation. At which point all of that memory gets re-purpused in one call.
The code is not thread safe currently in any shape or form. But there should be ways of making it at least "thread friendly" later on.
Definition at line 36 of file MemoryManager.hpp.
View newest version in sPHENIX GitHub at line 36 of file MemoryManager.hpp
Acts::Cuda::MemoryManager::~MemoryManager | ( | ) |
Destructor, freeing up all allocated memory.
|
delete |
Disallow copy construction.
|
delete |
Disallow move construction.
|
private |
Hide the constructor of the class.
void* Acts::Cuda::MemoryManager::allocate | ( | std::size_t | sizeInBytes, |
int | device = -1 |
||
) |
Get a pointer to an available memory block on the device.
std::size_t Acts::Cuda::MemoryManager::availableMemory | ( | int | device = -1 | ) | const |
Get the amount of memory still available on a specific device.
|
static |
Singleton object accessor.
Referenced by Acts::Cuda::SeedFinder< external_spacepoint_t >::createSeedsForGroup(), and main().
|
delete |
Disallow copy assignment.
|
delete |
Disallow move assignment.
void Acts::Cuda::MemoryManager::reset | ( | int | device = -1 | ) |
Reset all allocations.
Referenced by Acts::Cuda::SeedFinder< external_spacepoint_t >::createSeedsForGroup().
void Acts::Cuda::MemoryManager::setMemorySize | ( | std::size_t | sizeInBytes, |
int | device = -1 |
||
) |
Set the amount of memory to use on a particular device.
Referenced by main().
|
private |
Object holding information about memory allocations on all devices.
Definition at line 99 of file MemoryManager.hpp.
View newest version in sPHENIX GitHub at line 99 of file MemoryManager.hpp