Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Public Member Functions | List of all members
sham::BufferMirror< T, target, orgin_target > Class Template Reference

A class template for creating a mirrored buffer. More...

#include <shambackends/include/shambackends/BufferMirror.hpp>

Public Member Functions

 BufferMirror (DeviceBuffer< T, orgin_target > &mirrored_buffer)
 Constructs a BufferMirror.
 
 BufferMirror (const BufferMirror &)=delete
 
 BufferMirror (BufferMirror &&)=delete
 
BufferMirroroperator= (const BufferMirror &)=delete
 
BufferMirroroperator= (BufferMirror &&)=delete
 
T * data () const
 Provides access to the mirrored data.
 
u32 size () const
 Returns the size of the mirrored buffer.
 
T & operator[] (u32 i) const
 Accesses the mirrored data at a given index.
 
 ~BufferMirror ()
 Destructor.
 

Detailed Description

template<class T, USMKindTarget target, USMKindTarget orgin_target>
class sham::BufferMirror< T, target, orgin_target >

A class template for creating a mirrored buffer.

This class provides a mechanism to create a mirrored buffer of a specific DeviceBuffer that can be accessed like a normal pointer.

Example of usage :

{
auto acc = f.get_buf().template mirror_to<sham::host>();
auto acc_xyz = xyz.get_buf().template mirror_to<sham::host>();
for (u32 i = 0; i < f.size(); i++) {
Tvec position = acc_xyz[i];
acc[i] =function(position);
}
}
std::uint32_t u32
32 bit unsigned integer
Template Parameters
TThe type of elements in the buffer
targetThe USM kind target for the mirror buffer
orgin_targetThe original USM kind target of the mirrored buffer

Definition at line 51 of file BufferMirror.hpp.

Constructor & Destructor Documentation

◆ BufferMirror()

template<class T , USMKindTarget target, USMKindTarget orgin_target>
sham::BufferMirror< T, target, orgin_target >::BufferMirror ( DeviceBuffer< T, orgin_target > &  mirrored_buffer)
inline

Constructs a BufferMirror.

Initializes the mirrored buffer of the original data and retain a reference to the original buffer

Parameters
mirrored_bufferThe original buffer to be mirrored

Definition at line 67 of file BufferMirror.hpp.

+ Here is the call graph for this function:

◆ ~BufferMirror()

template<class T , USMKindTarget target, USMKindTarget orgin_target>
sham::BufferMirror< T, target, orgin_target >::~BufferMirror ( )
inline

Destructor.

Copies the data from the mirror back to the original buffer.

Definition at line 107 of file BufferMirror.hpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ data()

template<class T , USMKindTarget target, USMKindTarget orgin_target>
T * sham::BufferMirror< T, target, orgin_target >::data ( ) const
inline

Provides access to the mirrored data.

Returns
Pointer to the mirrored data

Definition at line 85 of file BufferMirror.hpp.

◆ operator[]()

template<class T , USMKindTarget target, USMKindTarget orgin_target>
T & sham::BufferMirror< T, target, orgin_target >::operator[] ( u32  i) const
inline

Accesses the mirrored data at a given index.

Parameters
iIndex of the data to access
Returns
Reference to the data at the given index

Definition at line 100 of file BufferMirror.hpp.

◆ size()

template<class T , USMKindTarget target, USMKindTarget orgin_target>
u32 sham::BufferMirror< T, target, orgin_target >::size ( ) const
inline

Returns the size of the mirrored buffer.

Returns
Size of the mirrored buffer

Definition at line 92 of file BufferMirror.hpp.


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