C++ API Reference
|
Introduced in 2023.0 More...
#include <MOpenCLUtils.h>
Public Member Functions | |
MOpenCLKernelInfo () | |
Construct a MOpenCLKernelInfo with a NULL MAutoCLKernel. | |
virtual | ~MOpenCLKernelInfo () |
Destructor. | |
void | reset () |
Releases the kernel and stops the managing its lifetime. | |
const size_t * | localWorkSize () const |
Returns the array of unsigned values that describe the number of work-items that make up a work-group that will execute the kernel function. | |
const size_t * | globalWorkSize () const |
Returns the array of unsigned values that describe the number of global work-items that will execute the kernel function. | |
size_t | elementCount () const |
Returns elementCount to be used by the kernel. | |
MAutoCLKernel & | kernel () |
Returns the kernel. | |
cl_kernel | get () const |
This method returns the current cl_kernel whose lifetime is being managed by the auto pointer of the kerner. More... | |
bool | isNull () const |
This method checks if the object manages a null kernel object. More... | |
bool | loadOrUpdate (const MString &fileName, const MString &kernelName, int elementCount=0) |
Initializes or updates the OpenCL kernel. More... | |
bool | loadKernel (const MString &fileName, const MString &kernelName, int elementCount=0) |
Initializes the OpenCL kernel. More... | |
bool | updateWorkSize (int elementCount) |
Updates the work size of the OpenCL kernel. More... | |
void | invalidateWorkSize () |
Invalidates the work size of the OpenCL kernel. More... | |
cl_int | setKernelArgBuffer (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 this kernel. More... | |
cl_int | setKernelArgBuffer (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 this kernel. More... | |
template<typename T > | |
cl_int | setKernelArg (cl_uint argIndex, T value, cl_int &errorCode) |
Used to set the argument value for a specific argument of this kernel. More... | |
cl_int | enqueueKernel (MAutoCLEventList &eventWaitList, MAutoCLEvent &event) |
Enqueue the execution of a kernel. More... | |
Static Public Member Functions | |
static const char * | className () |
Returns the name of this class. More... | |
Introduced in 2023.0
OpenCL functionality.
Wrapper for a MAutoCLKernel that will keep track of the work size and the element count. It also contains utility functions to more easily manage the loading, updating and argument setting of the kernel.
cl_kernel get | ( | ) | const |
bool isNull | ( | ) | const |
This method checks if the object manages a null kernel object.
Initializes or updates the OpenCL kernel.
If the kernel has not been loaded it will load the kernel given the parameters. Otherwise it will check if the work sizes of the kernel need to be updated according to the elementCount. If the kernel was already loaded and the elementCount has not changed this function will do nothing.
[in] | fileName | Name of the file holding the kernel. |
[in] | kernelName | Name of the kernel to load. |
[in] | elementCount | Number of element to be processed by this kernel, or 0 if the global work size value does not need to be computed. |
Initializes the OpenCL kernel.
[in] | fileName | Name of the file holding the kernel. |
[in] | kernelName | Name of the kernel to load. |
[in] | elementCount | Number of element to be processed by this kernel, or 0 if the global work size value does not need to be computed. |
bool updateWorkSize | ( | int | elementCount | ) |
Updates the work size of the OpenCL kernel.
[in] | elementCount | Number of element to be processed by this kernel. |
void invalidateWorkSize | ( | ) |
Invalidates the work size of the OpenCL kernel.
This ensures that a consecutive call to loadOrUpdate or updateWorkSize will recompute the work size for the kernel
cl_int setKernelArgBuffer | ( | 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 this 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.
[in] | argIndex | The 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] | buffer | The data that should be used as the argument value for the argument specified by argIndex |
[in,out] | errorCode | the previous error code which will be set to the new result if the previous code was CL_SUCCES |
[in] | useBuffer | when true the specified buffer is set as the argument, otherwise a nullptr is set. |
cl_int setKernelArgBuffer | ( | 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 this 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.
[in] | argIndex | The 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] | buffer | The data that should be used as the argument value for the argument specified by argIndex |
[in,out] | errorCode | the previous error code which will be set to the new result if the previous code was CL_SUCCES |
[in] | useBuffer | when true the specified buffer is set as the argument, otherwise a nullptr is set. |
|
inline |
Used to set the argument value for a specific argument of this 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.
[in] | argIndex | The 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] | value | The data that should be used as the argument value for the argument specified by argIndex |
[in,out] | errorCode | the previous error code which will be set to the new result if the previous code was CL_SUCCES |
cl_int enqueueKernel | ( | MAutoCLEventList & | eventWaitList, |
MAutoCLEvent & | event | ||
) |
Enqueue the execution of a kernel.
This method enqueues the execution of the specified kernel. It will use the work sizes from the kernel info and execute on the default Maya OpenCL command queue.
[in] | eventWaitList | The events that must be completed before this can be executed |
[out] | event | The new event that can be used later to wait for the result of this execution |
|
static |
Returns the name of this class.