UraniumCompute 0.1.0
A GPU accelerated parallel task scheduler
UN::MemoryMapHelper< T > Class Template Reference

Helper class for memory mapping, implements indexing operators and bound checking. More...

#include <IDeviceMemory.h>

Public Member Functions

 MemoryMapHelper (MemoryMapHelper &&other) noexcept
 
T & operator[] (USize index)
 
UInt64 Length () const
 Get size of the mapped data as a number of elements of type T.
 
UInt64 ByteSize () const
 Get size of the mapped data in bytes.
 
bool IsValid () const
 Check if an instance of the class is in valid state.
 
 operator bool () const
 Check if an instance of the class is in valid state.
 
T * Data () const
 Get a pointer to the mapped memory.
 
T * begin ()
 
T * end ()
 

Static Public Member Functions

static MemoryMapHelper Map (const DeviceMemorySlice &memorySlice)
 Map the device memory slice. More...
 
static MemoryMapHelper Map (IDeviceMemory *pMemory, UInt64 byteOffset=0, UInt64 byteSize=IDeviceMemory::WholeSize)
 Map the device memory. More...
 

Detailed Description

template<class T>
class UN::MemoryMapHelper< T >

Helper class for memory mapping, implements indexing operators and bound checking.

Member Function Documentation

◆ Map() [1/2]

template<class T >
static MemoryMapHelper UN::MemoryMapHelper< T >::Map ( const DeviceMemorySlice memorySlice)
inlinestatic

Map the device memory slice.

The function returns an instance of MemoryMapHelper that can be invalid if the memory map operation did not succeed. Check it like this:

if (auto mapHelper = MemoryMapHelper<float>::Map(...))
{
// Use mapHelper here...
}
Helper class for memory mapping, implements indexing operators and bound checking.
Definition: IDeviceMemory.h:220
Parameters
memorySlice- The device memory slice to map.
Returns
An instance of MemoryMapHelper.

◆ Map() [2/2]

template<class T >
static MemoryMapHelper UN::MemoryMapHelper< T >::Map ( IDeviceMemory pMemory,
UInt64  byteOffset = 0,
UInt64  byteSize = IDeviceMemory::WholeSize 
)
inlinestatic

Map the device memory.

The function returns an instance of MemoryMapHelper that can be invalid if the memory map operation did not succeed. Check it like this:

if (auto mapHelper = MemoryMapHelper<float>::Map(...))
{
// Use mapHelper here...
}
Parameters
pMemory- The device memory to map.
byteOffset- Byte offset of the memory to map.
byteSize- Size of the part of the memory to map.
Returns
An instance of MemoryMapHelper.

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