DPC++ Runtime
Runtime libraries for oneAPI DPC++
_pi_mem Struct Referenceabstract

PI Mem mapping to CUDA memory allocations, both data and texture/surface. More...

#include <cuda/pi_cuda.hpp>

Inheritance diagram for _pi_mem:
Collaboration diagram for _pi_mem:

Classes

struct  Mapping
 
union  mem_
 A PI Memory object represents either plain memory allocations ("Buffers" in OpenCL) or typed allocations ("Images" in OpenCL). More...
 

Public Types

enum  mem_type { mem_type::buffer, mem_type::surface, mem_type::buffer, mem_type::surface }
 
enum  mem_type { mem_type::buffer, mem_type::surface, mem_type::buffer, mem_type::surface }
 
enum  access_mode_t { unknown, read_write, read_only, write_only }
 
using pi_context = _pi_context *
 
using pi_context = _pi_context *
 

Public Member Functions

 _pi_mem (pi_context ctxt, pi_mem parent, mem_::buffer_mem_::alloc_mode mode, CUdeviceptr ptr, void *host_ptr, size_t size)
 Constructs the PI MEM handler for a non-typed allocation ("buffer") More...
 
 _pi_mem (pi_context ctxt, CUarray array, CUsurfObject surf, pi_mem_type image_type, void *host_ptr)
 Constructs the PI allocation for an Image object (surface in CUDA) More...
 
 ~_pi_mem ()
 
bool is_buffer () const noexcept
 
bool is_sub_buffer () const noexcept
 
bool is_image () const noexcept
 
pi_context get_context () const noexcept
 
pi_uint32 increment_reference_count () noexcept
 
pi_uint32 decrement_reference_count () noexcept
 
pi_uint32 get_reference_count () const noexcept
 
 ~_pi_mem ()
 
 _pi_mem (pi_context ctxt, pi_mem parent, mem_::buffer_mem_::alloc_mode mode, hipDeviceptr_t ptr, void *host_ptr, size_t size)
 Constructs the PI MEM handler for a non-typed allocation ("buffer") More...
 
 _pi_mem (pi_context ctxt, hipArray *array, hipSurfaceObject_t surf, pi_mem_type image_type, void *host_ptr)
 Constructs the PI allocation for an Image object. More...
 
 ~_pi_mem ()
 
bool is_buffer () const noexcept
 
bool is_sub_buffer () const noexcept
 
bool is_image () const noexcept
 
pi_context get_context () const noexcept
 
pi_uint32 increment_reference_count () noexcept
 
pi_uint32 decrement_reference_count () noexcept
 
pi_uint32 get_reference_count () const noexcept
 
virtual pi_result getZeHandle (char *&ZeHandle, access_mode_t, pi_device Device=nullptr)=0
 
virtual pi_result getZeHandlePtr (char **&ZeHandlePtr, access_mode_t, pi_device Device=nullptr)=0
 
virtual bool isImage () const =0
 
virtual ~_pi_mem ()=default
 

Public Attributes

pi_context context_
 
std::atomic_uint32_t refCount_
 Reference counting of the handler. More...
 
enum _pi_mem::mem_type mem_type_
 
union _pi_mem::mem_ mem_
 
pi_context Context
 
charMapHostPtr = nullptr
 
std::mutex SurfaceLock
 
unsigned int SurfaceIndex
 
std::unordered_map< void *, MappingMappings
 
std::mutex MappingsMutex
 
cm_surface_ptr_t SurfacePtr
 

Protected Member Functions

 _pi_mem (pi_context ctxt, char *HostPtr, cm_surface_ptr_t SurfacePtrArg, unsigned int SurfaceIdxArg)
 
 _pi_mem (pi_context Ctx)
 

Detailed Description

PI Mem mapping to CUDA memory allocations, both data and texture/surface.

PI Mem mapping to HIP memory allocations, both data and texture/surface.

Represents non-SVM allocations on the CUDA backend. Keeps tracks of all mapped regions used for Map/Unmap calls. Only one region can be active at the same time per allocation.

Represents non-SVM allocations on the HIP backend. Keeps tracks of all mapped regions used for Map/Unmap calls. Only one region can be active at the same time per allocation.

Definition at line 221 of file pi_cuda.hpp.

Member Typedef Documentation

◆ pi_context [1/2]

Definition at line 194 of file pi_hip.hpp.

◆ pi_context [2/2]

Definition at line 224 of file pi_cuda.hpp.

Member Enumeration Documentation

◆ access_mode_t

Enumerator
unknown 
read_write 
read_only 
write_only 

Definition at line 1026 of file pi_level_zero.hpp.

◆ mem_type [1/2]

enum _pi_mem::mem_type
strong
Enumerator
buffer 
surface 
buffer 
surface 

Definition at line 201 of file pi_hip.hpp.

◆ mem_type [2/2]

enum _pi_mem::mem_type
strong
Enumerator
buffer 
surface 
buffer 
surface 

Definition at line 231 of file pi_cuda.hpp.

Constructor & Destructor Documentation

◆ _pi_mem() [1/6]

_pi_mem::_pi_mem ( pi_context  ctxt,
pi_mem  parent,
mem_::buffer_mem_::alloc_mode  mode,
CUdeviceptr  ptr,
void *  host_ptr,
size_t  size 
)
inline

Constructs the PI MEM handler for a non-typed allocation ("buffer")

Definition at line 331 of file pi_cuda.hpp.

◆ _pi_mem() [2/6]

_pi_mem::_pi_mem ( pi_context  ctxt,
CUarray  array,
CUsurfObject  surf,
pi_mem_type  image_type,
void *  host_ptr 
)
inline

Constructs the PI allocation for an Image object (surface in CUDA)

Definition at line 350 of file pi_cuda.hpp.

◆ ~_pi_mem() [1/4]

◆ ~_pi_mem() [2/4]

_pi_mem::~_pi_mem ( )

◆ _pi_mem() [3/6]

_pi_mem::_pi_mem ( pi_context  ctxt,
char HostPtr,
cm_surface_ptr_t  SurfacePtrArg,
unsigned int  SurfaceIdxArg 
)
inlineprotected

Definition at line 172 of file pi_esimd_emulator.hpp.

◆ _pi_mem() [4/6]

_pi_mem::_pi_mem ( pi_context  ctxt,
pi_mem  parent,
mem_::buffer_mem_::alloc_mode  mode,
hipDeviceptr_t  ptr,
void *  host_ptr,
size_t  size 
)
inline

Constructs the PI MEM handler for a non-typed allocation ("buffer")

Definition at line 312 of file pi_hip.hpp.

◆ _pi_mem() [5/6]

_pi_mem::_pi_mem ( pi_context  ctxt,
hipArray *  array,
hipSurfaceObject_t  surf,
pi_mem_type  image_type,
void *  host_ptr 
)
inline

Constructs the PI allocation for an Image object.

Definition at line 331 of file pi_hip.hpp.

◆ ~_pi_mem() [3/4]

◆ ~_pi_mem() [4/4]

virtual _pi_mem::~_pi_mem ( )
virtualdefault

◆ _pi_mem() [6/6]

_pi_mem::_pi_mem ( pi_context  Ctx)
inlineprotected

Definition at line 1044 of file pi_level_zero.hpp.

Member Function Documentation

◆ decrement_reference_count() [1/2]

pi_uint32 _pi_mem::decrement_reference_count ( )
inlinenoexcept

Definition at line 364 of file pi_hip.hpp.

References refCount_.

◆ decrement_reference_count() [2/2]

pi_uint32 _pi_mem::decrement_reference_count ( )
inlinenoexcept

Definition at line 385 of file pi_cuda.hpp.

References refCount_.

Referenced by cuda_piMemRelease(), and hip_piMemRelease().

◆ get_context() [1/2]

pi_context _pi_mem::get_context ( ) const
inlinenoexcept

Definition at line 360 of file pi_hip.hpp.

References context_.

◆ get_context() [2/2]

pi_context _pi_mem::get_context ( ) const
inlinenoexcept

Definition at line 381 of file pi_cuda.hpp.

References context_.

◆ get_reference_count() [1/2]

pi_uint32 _pi_mem::get_reference_count ( ) const
inlinenoexcept

Definition at line 366 of file pi_hip.hpp.

References refCount_.

◆ get_reference_count() [2/2]

pi_uint32 _pi_mem::get_reference_count ( ) const
inlinenoexcept

Definition at line 387 of file pi_cuda.hpp.

References refCount_.

Referenced by cuda_piMemRetain(), and hip_piMemRetain().

◆ getZeHandle()

◆ getZeHandlePtr()

virtual pi_result _pi_mem::getZeHandlePtr ( char **&  ZeHandlePtr,
access_mode_t  ,
pi_device  Device = nullptr 
)
pure virtual

Implemented in _pi_image, and _pi_buffer.

◆ increment_reference_count() [1/2]

pi_uint32 _pi_mem::increment_reference_count ( )
inlinenoexcept

Definition at line 362 of file pi_hip.hpp.

References refCount_.

◆ increment_reference_count() [2/2]

pi_uint32 _pi_mem::increment_reference_count ( )
inlinenoexcept

Definition at line 383 of file pi_cuda.hpp.

References refCount_.

Referenced by cuda_piMemRetain(), and hip_piMemRetain().

◆ is_buffer() [1/2]

bool _pi_mem::is_buffer ( ) const
inlinenoexcept

Definition at line 352 of file pi_hip.hpp.

References buffer, and mem_type_.

◆ is_buffer() [2/2]

bool _pi_mem::is_buffer ( ) const
inlinenoexcept

Definition at line 373 of file pi_cuda.hpp.

References buffer, and mem_type_.

Referenced by cuda_piMemBufferPartition(), hip_piMemBufferPartition(), and is_sub_buffer().

◆ is_image() [1/2]

bool _pi_mem::is_image ( ) const
inlinenoexcept

Definition at line 358 of file pi_hip.hpp.

References mem_type_, and surface.

◆ is_image() [2/2]

bool _pi_mem::is_image ( ) const
inlinenoexcept

Definition at line 379 of file pi_cuda.hpp.

References mem_type_, and surface.

◆ is_sub_buffer() [1/2]

bool _pi_mem::is_sub_buffer ( ) const
inlinenoexcept

◆ is_sub_buffer() [2/2]

bool _pi_mem::is_sub_buffer ( ) const
inlinenoexcept

◆ isImage()

Member Data Documentation

◆ Context

pi_context _pi_mem::Context

Definition at line 139 of file pi_esimd_emulator.hpp.

Referenced by piMemGetInfo().

◆ context_

pi_context _pi_mem::context_

◆ MapHostPtr

char* _pi_mem::MapHostPtr = nullptr

◆ Mappings

std::unordered_map<void *, Mapping> _pi_mem::Mappings

Definition at line 162 of file pi_esimd_emulator.hpp.

Referenced by piEnqueueMemBufferMap(), and piEnqueueMemUnmap().

◆ MappingsMutex

std::mutex _pi_mem::MappingsMutex

Definition at line 164 of file pi_esimd_emulator.hpp.

Referenced by piEnqueueMemBufferMap(), and piEnqueueMemUnmap().

◆ mem_

◆ mem_type_

◆ refCount_

std::atomic_uint32_t _pi_mem::refCount_

Reference counting of the handler.

Definition at line 230 of file pi_cuda.hpp.

Referenced by decrement_reference_count(), get_reference_count(), and increment_reference_count().

◆ SurfaceIndex

unsigned int _pi_mem::SurfaceIndex

Definition at line 148 of file pi_esimd_emulator.hpp.

Referenced by piMemRelease(), and sycl_get_cm_surface_index().

◆ SurfaceLock

std::mutex _pi_mem::SurfaceLock

Definition at line 144 of file pi_esimd_emulator.hpp.

Referenced by sycl_get_cm_buffer_params(), and sycl_get_cm_image_params().

◆ SurfacePtr

cm_surface_ptr_t _pi_mem::SurfacePtr

Definition at line 166 of file pi_esimd_emulator.hpp.

Referenced by piEnqueueMemBufferRead(), and piEnqueueMemImageRead().


The documentation for this struct was generated from the following files: