Cuda battery library
Loading...
Searching...
No Matches
allocator.hpp File Reference
#include <cassert>
#include <cstddef>
#include <iostream>
#include <type_traits>
#include <inttypes.h>
#include "utility.hpp"

Go to the source code of this file.

Classes

class  battery::pool_allocator
 
class  battery::standard_allocator
 
class  battery::statistics_allocator< Allocator, InternalAllocator >
 

Namespaces

namespace  battery
 

Functions

CUDA void * operator new (size_t bytes, battery::pool_allocator &p)
 
CUDA void operator delete (void *ptr, battery::pool_allocator &p)
 
CUDA void * operator new (size_t bytes, battery::standard_allocator &p)
 
CUDA void operator delete (void *ptr, battery::standard_allocator &p)
 

Detailed Description

We provide several allocators compatible with the data structures provided by this library. The allocators are aimed to be used to distinguish in which memory (shared, global, managed or the "standard" C++ memory) we should allocate data. This allows us to provide uniform interfaces for both host (C++) and device (CUDA) code.

As a general comment, be careful to always deallocate the memory from the side you allocated it, e.g., do not allocate on the host then try to deallocate it on the device. To avoid these kind of mistakes, you should use battery::shared_ptr when passing data to a CUDA kernel, see the manual for examples.

Function Documentation

◆ operator new() [1/2]

CUDA void * operator new ( size_t bytes,
battery::pool_allocator & p )
inline

◆ operator delete() [1/2]

CUDA void operator delete ( void * ptr,
battery::pool_allocator & p )
inline

◆ operator new() [2/2]

CUDA void * operator new ( size_t bytes,
battery::standard_allocator & p )
inline

◆ operator delete() [2/2]

CUDA void operator delete ( void * ptr,
battery::standard_allocator & p )
inline