C++ API Reference
MOpenCLUtils Class Reference

Introduced in 2023.0 More...

#include <MOpenCLUtils.h>

Public Types

enum  UploadMode
 Upload mode.
 

Static Public Member Functions

static cl_int uploadToGPU (size_t size, void *host_ptr, MOpenCLBuffer &buffer, UploadMode uploadMode)
 Uploads data to a GPU Buffer. More...
 
template<typename MArrayType , typename ElementType = decltype(MArrayType{}[0]), typename _req = decltype(MArrayType{}.length())>
static cl_int uploadToGPU (const MArrayType &array, MOpenCLBuffer &buffer, UploadMode uploadMode=kBlocking)
 Uploads array data to a GPU Buffer. More...
 
template<typename StdArrayType , typename _req = typename StdArrayType::value_type>
static cl_int uploadToGPU (const StdArrayType &array, MOpenCLBuffer &buffer, UploadMode uploadMode)
 Uploads array data to a GPU Buffer. More...
 
static cl_int uploadToGPU (const MMatrixArray &array, MOpenCLBuffer &buffer, UploadMode uploadMode=kBlocking)
 Uploads an array of matrices to a GPU Buffer. More...
 
static cl_int uploadToGPU (const MObject &object, MOpenCLBuffer &buffer, UploadMode uploadMode, unsigned int *arrayLength=nullptr)
 Uploads generic array data to a GPU Buffer. More...
 
static cl_int uploadToGPUAsUnsignedChar (const MObject &object, MOpenCLBuffer &buffer, unsigned int *arrayLength=nullptr)
 Uploads generic array data to a GPU Buffer as an unsigned char array. More...
 
static cl_int setKernelArgBuffer (cl_kernel kernel, cl_uint argIndex, const MAutoCLMem &buffer, cl_int &errorCode, bool useBuffer=true)
 Used to set the buffer as the argument value for a specific argument of a kernel. More...
 
static cl_int setKernelArgBuffer (cl_kernel kernel, cl_uint argIndex, const MOpenCLBuffer &buffer, cl_int &errorCode, bool useBuffer=true)
 Used to set the buffer as the argument value for a specific argument of a kernel. More...
 
static cl_int setKernelArg (cl_kernel kernel, cl_uint argIndex, size_t argSize, const void *argValue, cl_int &errorCode)
 Used to set the argument value for a specific argument of a kernel. More...
 
template<typename T >
static cl_int setKernelArg (cl_kernel kernel, cl_uint argIndex, T value, cl_int &errorCode)
 Used to set the argument value for a specific argument of a kernel. More...
 
static const char * className ()
 Returns the name of this class. More...
 

Detailed Description

Introduced in 2023.0

2023.0:
Introduced in this version.

OpenCL functionality.

General utilities for OpenCL, containing functions for uploading buffers and managing kernels.

Member Function Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN cl_int uploadToGPU ( size_t  size,
void *  host_ptr,
MOpenCLBuffer buffer,
MOpenCLUtils::UploadMode  uploadMode 
)
static

Uploads data to a GPU Buffer.

Parameters
[in]host_ptrdata to be copied into the OpenCL buffer. Must be at least size bytes.
[in]sizethe size in bytes of the data to write to OpenCL.
[in]bufferthe GPU buffer to which the data should be uploaded
[in]uploadModethe uploadMode specifies whether the upload should happen in blocking or non-blocking mode
Returns
CL_SUCCESS for success, an OpenCL error code otherwise.
  • CL_SUCCESS if the upload was succesfull
Examples:
offsetNode/offsetNode.cpp.
static cl_int uploadToGPU ( const MArrayType &  array,
MOpenCLBuffer buffer,
UploadMode  uploadMode = kBlocking 
)
inlinestatic

Uploads array data to a GPU Buffer.

Parameters
[in]arraythe CPU array to be uploaded
[in]bufferthe GPU buffer to which the data should be uploaded
[in]uploadModethe uploadMode specifies whether the upload should happen in blocking or non-blocking mode
Returns
  • CL_SUCCESS if the upload was succesfull
static cl_int uploadToGPU ( const StdArrayType &  array,
MOpenCLBuffer buffer,
UploadMode  uploadMode 
)
inlinestatic

Uploads array data to a GPU Buffer.

Parameters
[in]arraythe std array to be uploaded
[in]bufferthe GPU buffer to which the data should be uploaded
[in]uploadModethe uploadMode specifies whether the upload should happen in blocking or non-blocking mode
Returns
  • CL_SUCCESS if the upload was succesfull
cl_int uploadToGPU ( const MMatrixArray array,
MOpenCLBuffer buffer,
MOpenCLUtils::UploadMode  uploadMode = kBlocking 
)
static

Uploads an array of matrices to a GPU Buffer.

Parameters
[in]arraythe CPU matrix array to be uploaded
[in]bufferthe GPU buffer to which the data should be uploaded
Returns
CL_SUCCESS if the upload was succesfull
cl_int uploadToGPU ( const MObject object,
MOpenCLBuffer buffer,
UploadMode  uploadMode,
unsigned int *  arrayLength = nullptr 
)
static

Uploads generic array data to a GPU Buffer.

Parameters
[in]arraythe CPU array to be uploaded
[in]bufferthe GPU buffer to which the data should be uploaded
[in]uploadModethe uploadMode specifies whether the upload should happen in blocking or non-blocking mode
[out]arrayLengthwhen non-null this will be set to the length of the array that is being uploaded
Returns
CL_SUCCESS if the upload was succesfull
cl_int uploadToGPUAsUnsignedChar ( const MObject object,
MOpenCLBuffer buffer,
unsigned int *  arrayLength = nullptr 
)
static

Uploads generic array data to a GPU Buffer as an unsigned char array.

If the array data contained in the objects is of type kUintArrayData or kIntArrayData the array will be converted to type unsigned char and uploaded to the GPU. This can be used if the integers are going to be used as booleans or enums.

Parameters
[in]arraythe CPU array to be uploaded
[in]bufferthe GPU buffer to which the data should be uploaded
[out]arrayLengthwhen non-null this will be set to the length of the array that is being uploaded
Returns
CL_SUCCESS if the upload was succesfull
cl_int setKernelArgBuffer ( cl_kernel  kernel,
cl_uint  argIndex,
const MAutoCLMem buffer,
cl_int &  errorCode,
bool  useBuffer = true 
)
static

Used to set the buffer as the argument value for a specific argument of a kernel.

If the specified errorCode is not CL_SUCCES this function will do nothing. It will simply return the error code. Otherwise it will set the argument on the kernel and return the new errorCode.

Parameters
[in]kernelA valid kernel object.
[in]argIndexThe argument index. Arguments to the kernel are referred by indices that go from 0 for the leftmost argument to n - 1, where n is the total number of arguments declared by a kernel.
[in]bufferThe data that should be used as the argument value for the argument specified by argIndex
[in,out]errorCodethe previous error code which will be set to the new result if the previous code was CL_SUCCES
[in]useBufferwhen true the specified buffer is set as the argument, otherwise a nullptr is set.
Returns
returns CL_SUCCESS if the argument was successfully set. Otherwise, it returns an OpenCL error code.
cl_int setKernelArgBuffer ( cl_kernel  kernel,
cl_uint  argIndex,
const MOpenCLBuffer buffer,
cl_int &  errorCode,
bool  useBuffer = true 
)
static

Used to set the buffer as the argument value for a specific argument of a kernel.

If the specified errorCode is not CL_SUCCES this function will do nothing. It will simply return the error code. Otherwise it will set the argument on the kernel and return the new errorCode.

Parameters
[in]kernelA valid kernel object.
[in]argIndexThe argument index. Arguments to the kernel are referred by indices that go from 0 for the leftmost argument to n - 1, where n is the total number of arguments declared by a kernel.
[in]bufferThe data that should be used as the argument value for the argument specified by argIndex
[in,out]errorCodethe previous error code which will be set to the new result if the previous code was CL_SUCCES
[in]useBufferwhen true the specified buffer is set as the argument, otherwise a nullptr is set.
Returns
returns CL_SUCCESS if the argument was successfully set. Otherwise, it returns an OpenCL error code.
cl_int setKernelArg ( cl_kernel  kernel,
cl_uint  argIndex,
size_t  argSize,
const void *  argValue,
cl_int &  errorCode 
)
static

Used to set the argument value for a specific argument of a kernel.

If the specified errorCode is not CL_SUCCES this function will do nothing. It will simply return the error code. Otherwise it will set the argument on the kernel and return the new errorCode.

This is a relatively low level function that interfaces directly with clSetKernelArg

Parameters
[in]kernelA valid kernel object.
[in]argIndexThe argument index. Arguments to the kernel are referred by indices that go from 0 for the leftmost argument to n - 1, where n is the total number of arguments declared by a kernel.
[in]argSizeSpecifies the size of the argument value
[in]argValueA pointer to data that should be used as the argument value for argument specified by argIndex
[in,out]errorCodethe previous error code which will be set to the new result if the previous code was CL_SUCCES
Returns
returns CL_SUCCESS if the argument was successfully set. Otherwise, it returns an OpenCL error code.
static cl_int setKernelArg ( cl_kernel  kernel,
cl_uint  argIndex,
value,
cl_int &  errorCode 
)
inlinestatic

Used to set the argument value for a specific argument of a kernel.

If the specified errorCode is not CL_SUCCES this function will do nothing. It will simply return the error code. Otherwise it will set the argument on the kernel and return the new errorCode.

Parameters
[in]kernelA valid kernel object.
[in]argIndexThe argument index. Arguments to the kernel are referred by indices that go from 0 for the leftmost argument to n - 1, where n is the total number of arguments declared by a kernel.
[in]valueThe data that should be used as the argument value for the argument specified by argIndex
[in,out]errorCodethe previous error code which will be set to the new result if the previous code was CL_SUCCES
Returns
  • CL_SUCCESS returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns an OpenCL error code.
const char * className ( )
static

Returns the name of this class.

Returns
The name of this class.

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