20#ifndef OPM_SIMULATORS_LINALG_GPUISTL_PINNEDMEMORYHOLDER_HPP
21#define OPM_SIMULATORS_LINALG_GPUISTL_PINNEDMEMORYHOLDER_HPP
24#include "opm/simulators/linalg/gpuistl/detail/gpu_safe_call.hpp"
26#include <cuda_runtime.h>
28#include <fmt/format.h>
60 if (m_ptr && m_numberOfElements > 0) {
62 OPM_GPU_SAFE_CALL(cudaHostRegister(
static_cast<void*
>(m_ptr), sizeInBytes, flags));
71 if (m_ptr && m_numberOfElements > 0)
72 OPM_GPU_SAFE_CALL(cudaHostUnregister(
static_cast<void*
>(m_ptr)));
82 , m_numberOfElements(other.m_numberOfElements)
84 other.m_ptr =
nullptr;
85 other.m_numberOfElements = 0;
92 if (m_ptr && m_numberOfElements > 0) {
93 OPM_GPU_SAFE_CALL(cudaHostUnregister(
static_cast<void*
>(m_ptr)));
98 m_numberOfElements = other.m_numberOfElements;
101 other.m_ptr =
nullptr;
102 other.m_numberOfElements = 0;
122 return m_numberOfElements;
127 std::size_t m_numberOfElements;
RAII class for pinning host memory using cudaHostRegister.
Definition PinnedMemoryHolder.hpp:46
T * get() const
Gets the pointer to the pinned memory.
Definition PinnedMemoryHolder.hpp:111
PinnedMemoryHolder(T *ptr, std::size_t numberOfElements, unsigned int flags=cudaHostRegisterDefault)
Constructs a PinnedMemoryHolder and registers the host memory.
Definition PinnedMemoryHolder.hpp:56
~PinnedMemoryHolder()
Destructor.
Definition PinnedMemoryHolder.hpp:69
std::size_t numberOfElements() const
Gets the number of elements in the pinned memory region.
Definition PinnedMemoryHolder.hpp:120
A small, fixed‑dimension MiniVector class backed by std::array that can be used in both host and CUDA...
Definition AmgxInterface.hpp:38
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:45