Cuda battery library
|
Go to the source code of this file.
Classes | |
class | battery::root_ptr< T, Allocator > |
Namespaces | |
namespace | battery |
Functions | |
template<class T , class Alloc , class... Args> | |
CUDA NI root_ptr< T, Alloc > | battery::allocate_root (const Alloc &alloc, Args &&... args) |
template<class T , class Alloc , class... Args> | |
CUDA root_ptr< T, Alloc > | battery::make_root (Args &&... args) |
This smart pointer is a variant of shared_ptr where only the first instance has the ownership of the object. This is intended to be used with hierarchical data structures where the root of the hierarchy is the owner of the data, and the root is deleted after the children. A use-case in GPU programming is to distribute shared data over blocks; using shared_ptr would lead to data races since the class is not thread-safe; with root_ptr, only one block is responsible for the deletion.