DotMP
Public Types | Public Member Functions | Properties | Private Attributes | List of all members
DotMP.GPU.Buffer< T > Class Template Reference

Buffer to manage GPU memory. Should only be created on the CPU. More...

Inheritance diagram for DotMP.GPU.Buffer< T >:
Inheritance graph
[legend]
Collaboration diagram for DotMP.GPU.Buffer< T >:
Collaboration graph
[legend]

Public Types

enum class  Behavior { To , From , ToFrom , NoCopy }
 Specifies the behavior of the buffer. More...
 

Public Member Functions

 Buffer (T[] data, Buffer.Behavior behavior)
 Constructor for buffer object. Allocates a 1D array on the GPU and makes it available for the next GPU kernel. More...
 
unsafe Buffer (T[,] data, Buffer.Behavior behavior)
 Constructor for buffer object. Allocates a 2D array on the GPU and makes it available for the next GPU kernel. More...
 
unsafe Buffer (T[,,] data, Buffer.Behavior behavior)
 Constructor for buffer object. Allocates a 3D array on the GPU and makes it available for the next GPU kernel. More...
 
void Dispose ()
 Dispose of the buffer, freeing GPU memory and copying any relevant data back to the CPU. More...
 

Properties

int Dimensions [get, private set]
 The number of dimensions in the array. More...
 
ArrayView1D< T, Stride1D.Dense > View [get]
 Get the view of the memory for the GPU. More...
 
ValueTuple< int, int > Strides [get]
 Gets the Y and Z strides of the array. More...
 

Private Attributes

MemoryBuffer1D< T, Stride1D.Dense > buf
 The ILGPU buffer for arrays. More...
 
Buffer.Behavior behavior
 Behavior of the data, as specified by Behavior. More...
 
T[] data1d
 The CPU 1D array, so that we can copy the data back. More...
 
T[,] data2d
 The CPU 2D array, so that we can copy the data back. More...
 
T[,,] data3d
 The CPU 3D array, so that we can copy the data back. More...
 
int stride_y
 Stride of Y dimension. More...
 
int stride_z
 Stride of Z dimension. More...
 

Detailed Description

Buffer to manage GPU memory. Should only be created on the CPU.

Type Constraints
T :unmanaged 

Member Enumeration Documentation

◆ Behavior

Specifies the behavior of the buffer.

Enumerator
To 

Specifies that data should be transfered to the GPU, but not from it.

From 

Specifies that data should be transfered from the GPU, but not to it.

ToFrom 

Specifies that data should be transfered both to and from the GPU.

NoCopy 

Specifies that the data shouldn't be transfered to or from the GPU. For internal use.

Constructor & Destructor Documentation

◆ Buffer() [1/3]

DotMP.GPU.Buffer< T >.Buffer ( T[]  data,
Buffer< T >.Behavior  behavior 
)
inline

Constructor for buffer object. Allocates a 1D array on the GPU and makes it available for the next GPU kernel.

Parameters
dataThe data to allocate on the GPU.
behaviorThe behavior of the data, see Behavior.

◆ Buffer() [2/3]

unsafe DotMP.GPU.Buffer< T >.Buffer ( data[,],
Buffer< T >.Behavior  behavior 
)
inline

Constructor for buffer object. Allocates a 2D array on the GPU and makes it available for the next GPU kernel.

Parameters
dataThe data to allocate on the GPU.
behaviorThe behavior of the data, see Behavior.

◆ Buffer() [3/3]

unsafe DotMP.GPU.Buffer< T >.Buffer ( data[,,],
Buffer< T >.Behavior  behavior 
)
inline

Constructor for buffer object. Allocates a 3D array on the GPU and makes it available for the next GPU kernel.

Parameters
dataThe data to allocate on the GPU.
behaviorThe behavior of the data, see Behavior.

Member Function Documentation

◆ Dispose()

void DotMP.GPU.Buffer< T >.Dispose ( )
inline

Dispose of the buffer, freeing GPU memory and copying any relevant data back to the CPU.

Member Data Documentation

◆ behavior

Buffer.Behavior DotMP.GPU.Buffer< T >.behavior
private

Behavior of the data, as specified by Behavior.

◆ buf

MemoryBuffer1D<T, Stride1D.Dense> DotMP.GPU.Buffer< T >.buf
private

The ILGPU buffer for arrays.

◆ data1d

T [] DotMP.GPU.Buffer< T >.data1d
private

The CPU 1D array, so that we can copy the data back.

◆ data2d

T [,] DotMP.GPU.Buffer< T >.data2d
private

The CPU 2D array, so that we can copy the data back.

◆ data3d

T [,,] DotMP.GPU.Buffer< T >.data3d
private

The CPU 3D array, so that we can copy the data back.

◆ stride_y

int DotMP.GPU.Buffer< T >.stride_y
private

Stride of Y dimension.

◆ stride_z

int DotMP.GPU.Buffer< T >.stride_z
private

Stride of Z dimension.

Property Documentation

◆ Dimensions

int DotMP.GPU.Buffer< T >.Dimensions
getprivate setpackage

The number of dimensions in the array.

◆ Strides

ValueTuple<int, int> DotMP.GPU.Buffer< T >.Strides
getpackage

Gets the Y and Z strides of the array.

◆ View

ArrayView1D<T, Stride1D.Dense> DotMP.GPU.Buffer< T >.View
getpackage

Get the view of the memory for the GPU.


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