Template Class CudaManagedAllocator

Nested Relationships

Nested Types

Class Documentation

template<typename T>
class CudaManagedAllocator

Wrapper around cudaMallocManaged to create cuda-managed vectors.

Template Parameters

T – Type allocated by the allocator.

Public Types

using size_type = std::size_t

Type of a size

using pointer = T*

Type of the allocated pointer

using const_pointer = const T*

Type of the allocated const pointer

using value_type = T

Type of the value

Public Functions

CudaManagedAllocator() = default

Default constructor.

CudaManagedAllocator(const CudaManagedAllocator &other) = default

Copy constructor (default).

Parameters

other – The other allocator to copy.

~CudaManagedAllocator() = default

Default destructor.

inline pointer allocate(size_type n, const void *hint = 0) const

Allocates n values of type T.

Parameters
  • n – The size to allocate.

  • hint – Unused.

Returns

The allocated pointer.

inline void deallocate(pointer p, size_type n) const

Free the given pointer.

Parameters
  • p – The pointer to free.

  • n – Unused.

inline bool operator==(const CudaManagedAllocator<T> &other) const

Compares allocators.

Parameters

other – The other allocator to compare.

Returns

True

inline bool operator!=(const CudaManagedAllocator<T> &other) const

Compares allocators.

Parameters

other – The other allocator to compare.

Returns

False

template<typename _Tp1>
struct rebind

Rebind of CudaManagedAllocator.

Template Parameters

_Tp1 – Type allocated by the other allocator.

Public Types

typedef CudaManagedAllocator<_Tp1> other

Type of other allocator