Loading...
Searching...
No Matches
Opm::gpuistl::PinnedMemoryHolder< T > Class Template Reference

RAII class for pinning host memory using cudaHostRegister. More...

`#include <PinnedMemoryHolder.hpp>`

## Public Member Functions

| PinnedMemoryHolder (T *ptr, std::size_t numberOfElements, unsigned int flags=cudaHostRegisterDefault)
| Constructs a PinnedMemoryHolder and registers the host memory.
| ~PinnedMemoryHolder ()
| Destructor.
| PinnedMemoryHolder (const PinnedMemoryHolder &)=delete
PinnedMemoryHolder & | operator= (const PinnedMemoryHolder &)=delete
| PinnedMemoryHolder (PinnedMemoryHolder &&other) noexcept
PinnedMemoryHolder & | operator= (PinnedMemoryHolder &&other) noexcept
T * | get () const
| Gets the pointer to the pinned memory.
std::size_t | numberOfElements () const
| Gets the number of elements in the pinned memory region.

## Detailed Description

template<class T>
class Opm::gpuistl::PinnedMemoryHolder< T >

RAII class for pinning host memory using cudaHostRegister.

This class registers a given host memory region in its constructor and unregisters it in its destructor. This is useful for speeding up asynchronous memory transfers between host and GPU.

Template Parameters

  T | The type of data pointed to by the host pointer.

## Constructor & Destructor Documentation

## PinnedMemoryHolder()

template<class T>

Opm::gpuistl::PinnedMemoryHolder< T >::PinnedMemoryHolder | ( | T * | ptr,
|  | std::size_t | numberOfElements,
|  | unsigned int | flags = cudaHostRegisterDefault )

inline

Constructs a PinnedMemoryHolder and registers the host memory.

Parameters

  ptr | Pointer to the host memory to be pinned.
  numberOfElements | The number of elements of type T in the memory region.
  flags | Flags for cudaHostRegister. Defaults to cudaHostRegisterDefault.

Exceptions

  std::runtime_error | if cudaHostRegister fails.

## ~PinnedMemoryHolder()

template<class T>

Opm::gpuistl::PinnedMemoryHolder< T >::~PinnedMemoryHolder | ( |  | ) |

inline

Destructor.

Unregisters the host memory.

## Member Function Documentation

## get()

template<class T>

T * Opm::gpuistl::PinnedMemoryHolder< T >::get | ( |  | ) | const

inline

Gets the pointer to the pinned memory.

Returns
  Pointer to the pinned memory, or nullptr if not valid.

## numberOfElements()

template<class T>

std::size_t Opm::gpuistl::PinnedMemoryHolder< T >::numberOfElements | ( |  | ) | const

inline

Gets the number of elements in the pinned memory region.

Returns
  Number of elements.

The documentation for this class was generated from the following file:

- opm/simulators/linalg/gpuistl/PinnedMemoryHolder.hpp