![]() |
Shamrock 2025.10.0
Astrophysical Code
|
Class for holding a USM pointer. More...
#include <shambackends/include/shambackends/USMPtrHolder.hpp>
Public Member Functions | |
| void | free_ptr () |
| Free the held pointer. | |
| ~USMPtrHolder () | |
| USM pointer holder destructor. | |
| USMPtrHolder (const USMPtrHolder &other)=delete | |
| Deleted copy constructor. | |
| USMPtrHolder (USMPtrHolder &&other) noexcept | |
| Move constructor. | |
| USMPtrHolder & | operator= (const USMPtrHolder &other)=delete |
| Deleted copy assignment operator. | |
| USMPtrHolder & | operator= (USMPtrHolder &&other) noexcept |
| Move assignment operator. | |
| template<class T > | |
| T * | ptr_cast () const |
| Cast the USM pointer to the given type. | |
| void * | get_raw_ptr () const |
| Get the raw pointer of the USM allocation. | |
| size_t | get_bytesize () const |
| Get the size of the USM allocation (in byte) | |
| DeviceScheduler & | get_dev_scheduler () const |
| Get the SYCL context used for allocation/freeing the USM buffer. | |
| std::shared_ptr< DeviceScheduler > & | get_dev_scheduler_ptr () |
| Get the SYCL context used for allocation/freeing the USM buffer. | |
| const std::shared_ptr< DeviceScheduler > & | get_dev_scheduler_ptr () const |
| Get the SYCL context used for allocation/freeing the USM buffer. | |
Static Public Member Functions | |
| static USMPtrHolder | create (size_t sz, std::shared_ptr< DeviceScheduler > dev_sched, std::optional< size_t > alignment=std::nullopt) |
| Create a USM pointer holder. | |
| static USMPtrHolder | create_nullptr (std::shared_ptr< DeviceScheduler > dev_sched) |
Class for holding a USM pointer.
This class is a simple RAII wrapper around a USM (Unified Shared Memory) pointer. It is a move-only class that manages the lifetime of the USM buffer.
The USM buffer can be either a device, shared or host buffer, depending on the template parameter target.
The move constructor and move assignment operator are deleted to prevent accidental copies of the class.
Definition at line 59 of file USMPtrHolder.hpp.
| sham::USMPtrHolder< target >::~USMPtrHolder | ( | ) |
USM pointer holder destructor.
Frees the USM pointer if not equall to nullptr
Definition at line 55 of file USMPtrHolder.cpp.
|
inlinenoexcept |
Move constructor.
Moves the contents of the other USMPtrHolder into this one, leaving the other one with a nullptr USM pointer, which disable the destructor.
| other | The USMPtrHolder to be moved from |
Definition at line 112 of file USMPtrHolder.hpp.
|
static |
Create a USM pointer holder.
Allocate a USM buffer of the given size using the provided SYCL queue. The USM buffer can be either a device, shared or host buffer, depending on the template parameter target.
| sz | The size of the USM buffer to be allocated |
| dev_sched | The Device Scheduler used to allocate/free the USM buffer |
| alignment | The alignment of the USM buffer (optional) |
Definition at line 25 of file USMPtrHolder.cpp.
|
static |
Definition at line 36 of file USMPtrHolder.cpp.
| void sham::USMPtrHolder< target >::free_ptr | ( | ) |
Free the held pointer.
Definition at line 47 of file USMPtrHolder.cpp.
|
inline |
Get the size of the USM allocation (in byte)
Definition at line 167 of file USMPtrHolder.hpp.
|
inline |
Get the SYCL context used for allocation/freeing the USM buffer.
Definition at line 174 of file USMPtrHolder.hpp.
|
inline |
Get the SYCL context used for allocation/freeing the USM buffer.
Definition at line 181 of file USMPtrHolder.hpp.
|
inline |
Get the SYCL context used for allocation/freeing the USM buffer.
Definition at line 190 of file USMPtrHolder.hpp.
|
inline |
Get the raw pointer of the USM allocation.
This method returns the raw pointer to the USM allocation. The caller must be careful with the type and the usage of the returned pointer.
Definition at line 160 of file USMPtrHolder.hpp.
|
inlinenoexcept |
Move assignment operator.
Moves the contents of the other USMPtrHolder into this one, leaving the other one in a valid but unspecified state. The other USMPtrHolder will not free the USM buffer on destruction.
| other | The USMPtrHolder to be moved from |
Definition at line 130 of file USMPtrHolder.hpp.
|
inline |
Cast the USM pointer to the given type.
| T | The type to cast the USM buffer pointer to |
Definition at line 144 of file USMPtrHolder.hpp.
Here is the call graph for this function: