File MemoryManager.hpp¶
-
namespace Acts
Set the Geometry Context PLUGIN.
Set the Calibration Context PLUGIN.
Convenience functions to ease creation of and Acts::InterpolatedMaterialMap and to avoid code duplication.
Set the Mangetic Field Context PLUGIN.
Convenience functions to ease creation of and Acts::InterpolatedBFieldMap and to avoid code duplication.
Currently implemented for the two most common formats: rz and xyz.
-
namespace Cuda
-
class MemoryManager
- #include </home/docs/checkouts/readthedocs.org/user_builds/acts/checkouts/v19.0.0/Plugins/Cuda/include/Acts/Plugins/Cuda/Utilities/MemoryManager.hpp>
Singleton class used for allocating memory on CUDA device(s)
In order to avoid calling
cudaMalloc
(…) andcudaFree
(…) too many times in the code (which can turn out to be pretty slow), device memory is allocated using this singleton memory manager for theActs::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.
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 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.
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.
Public Functions
-
~MemoryManager()
Destructor, freeing up all allocated memory.
Private Functions
-
MemoryManager()¶
Hide the constructor of the class.
Private Members
-
std::vector<DeviceMemory> m_memory¶
Object holding information about memory allocations on all devices.
-
struct DeviceMemory¶
Struct describing the state of the memory allocation on a particular device.
Public Members
-
std::ptrdiff_t m_maxUsage = 0¶
The maximum amount of memory used at a time during the job.
-
char *m_nextAllocation = nullptr¶
Pointer to the next available memory block in the “current round”.
-
char *m_ptr = nullptr¶
Pointer to the beginning of the memory allocation.
-
std::size_t m_size = 0¶
The amount of memory allocated on the CUDA device.
-
std::ptrdiff_t m_maxUsage = 0¶
-
MemoryManager(const MemoryManager&) = delete
-
class MemoryManager
-
namespace Cuda