C++ API Reference
MOpenCLInfo Class Reference

Global OpenCL information used by Maya. More...

#include <MOpenCLInfo.h>

Static Public Member Functions

static cl_context getOpenCLContext ()
 The method returns the Maya OpenCL context. More...
 
static cl_command_queue getMayaDefaultOpenCLCommandQueue ()
 The method returns the Maya default OpenCL command queue. More...
 
static cl_command_queue createOpenCLCommandQueue ()
 This method creates a new OpenCL command queue. More...
 
static cl_device_id getOpenCLDeviceId ()
 The method returns the Maya OpenCL device ID. More...
 
static MAutoCLKernel getOpenCLKernel (const MString &sourceFilePath, const MString &kernelName)
 This method compiles a dot cl (.cl) file into a cl_program, and then creates a cl_kernel that uses that program. More...
 
static MAutoCLKernel getOpenCLKernelFromString (const MString &programSource, const MString &programName, const MString &kernelName)
 This method compiles a string into a cl_program, and then creates a cl_kernel from one of the kernels in that program. More...
 
static bool releaseOpenCLKernel (const MAutoCLKernel &kernel)
 This method releases a kernel that was obtained from getOpenCLKernel(). More...
 
static void checkCLErrorStatus (cl_int err)
 This method prints an error message to stderr that corresponds with the error received. More...
 
static void appendMessage (MStringArray *messages, const char *format,...)
 This method appends a message to messages. More...
 
static void appendMessage (MStringArray *messages, const MStringResourceId *formatResourceId,...)
 This method appends a message to messages. More...
 
static bool supportsDoublePrecision ()
 This method returns true if the OpenCL device supports double precision floating point operations. More...
 

Detailed Description

Global OpenCL information used by Maya.

This class provides access to all the global information Maya has about OpenCL. This information includes the chosen device ID, context, and command queue. MOpenCLInfo also includes helper methods to handle basic kernel compilation and error status checking.

You can only access MOpenCLInfo after VP2 is initialized. If you access it before VP2 initialization, the behavior of MOpenCLInfo is undefined.

Examples:
basicMorphNode/basicMorphNode.cpp, identityNode/identityNode.cpp, and offsetNode/offsetNode.cpp.

Member Function Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN cl_context getOpenCLContext ( )
static

The method returns the Maya OpenCL context.

This is the same context used by the deformerEvaluator plug-in. This may be the same context used by external libraries integrated with Maya, such as Bullet or OpenSubDiv.

Returns
The OpenCL context used by Maya.
Examples:
basicMorphNode/basicMorphNode.cpp, and offsetNode/offsetNode.cpp.
cl_command_queue getMayaDefaultOpenCLCommandQueue ( )
static

The method returns the Maya default OpenCL command queue.

This is the same command queue that the deformerEvaluator plug-in uses. This may be the same command queue used by external libraries integrated with Maya, such as Bullet or OpenSubDiv.

Returns
The default OpenCL command queue used by Maya.
Examples:
basicMorphNode/basicMorphNode.cpp, identityNode/identityNode.cpp, and offsetNode/offsetNode.cpp.
cl_command_queue createOpenCLCommandQueue ( )
static

This method creates a new OpenCL command queue.

The returned command queue is created using exactly the same parameters and logic as the Maya default OpenCL command queue (returned by getMayaDefaultOpenCLCommandQueue()).

The user must call clReleaseCommandQueue on the returned command queue when the queue is no longer in use.

Returns
The newly created OpenCL command queue.
cl_device_id getOpenCLDeviceId ( )
static

The method returns the Maya OpenCL device ID.

This is the same device ID used by the deformerEvaluator plug-in. This may be the same device ID used by external libraries integrated with Maya such as Bullet or OpenSubDiv.

Returns
The OpenCL device ID used by Maya.
Examples:
identityNode/identityNode.cpp.
MAutoCLKernel getOpenCLKernel ( const MString sourceFilePath,
const MString kernelName 
)
static

This method compiles a dot cl (.cl) file into a cl_program, and then creates a cl_kernel that uses that program.

The sourceFilePath that passes into this method should be the absolute path of the cl file on disk and the kernel name must be an exact match of a kernel in the given file. The cl_program only generates once, even if multiple kernels are generated from the same source file.

If this method returns a non-null kernel, the kernel should be released with releaseOpenCLKernel().

Parameters
[in]sourceFilePathThe absolute path of the cl file on disk.
[in]kernelNameThe name of a kernel inside the cl file.
Returns
A MAutoCLKernel handle corresponding to the named kernel from the file.
Examples:
basicMorphNode/basicMorphNode.cpp, identityNode/identityNode.cpp, and offsetNode/offsetNode.cpp.
MAutoCLKernel getOpenCLKernelFromString ( const MString programSource,
const MString programName,
const MString kernelName 
)
static

This method compiles a string into a cl_program, and then creates a cl_kernel from one of the kernels in that program.

programSource should hold the cl source of the program and the kernelName must be an exact match for a kernel in the program string. programName should uniquely identify a programString. The cl_program is only generated once, even if multiple kernels are generated from the same program source.

If this method returns a non-null kernel, the kernel should be released with releaseOpenCLKernel().

Parameters
[in]programSourceThe openCL source to be compiled
[in]programNameA name which uniquely identifies programSouce
[in]kernelNameThe name of a kernel in the compiled program
Returns
A MAutoCLKernel handle corresponding to the named kernel from the program.
bool releaseOpenCLKernel ( const MAutoCLKernel kernel)
static

This method releases a kernel that was obtained from getOpenCLKernel().

If the kernel is the last one associated with the cl_program program, the program will be released as well.

Parameters
[in]kernelThe kernel to release.
Returns
True if the kernel was successfully released, false otherwise.
Examples:
basicMorphNode/basicMorphNode.cpp, identityNode/identityNode.cpp, and offsetNode/offsetNode.cpp.
void checkCLErrorStatus ( cl_int  err)
static

This method prints an error message to stderr that corresponds with the error received.

If the error is CL_SUCCESS, no message is printed. If the error is any other value, a message is printed to stderr that includes the error type.

Parameters
[in]errThe error to be checked.
Examples:
basicMorphNode/basicMorphNode.cpp, identityNode/identityNode.cpp, and offsetNode/offsetNode.cpp.
void appendMessage ( MStringArray messages,
const char *  format,
  ... 
)
static

This method appends a message to messages.

The message is created using format and the additional arguments . If messages is NULL, this method does nothing.

Parameters
[in]messagesThe list of messages to be added to.
[in]formatC string that contains a format string and follows the same specifications as format in printf.
[in]...Additional arguments to be used to replace a format specifier in the format string.
Examples:
offsetNode/offsetNode.cpp.
void appendMessage ( MStringArray messages,
const MStringResourceId formatResourceId,
  ... 
)
static

This method appends a message to messages.

The message is created using formatResourceId and the additional arguments . If messages is NULL, this method does nothing.

Parameters
[in]messagesThe list of messages to be added to.
[in]formatResourceIdMStringResourceId that contains a format string and follows the same specifications as format in printf.
[in]...Additional arguments to be used to replace a format specifier in the format string.
bool supportsDoublePrecision ( )
static

This method returns true if the OpenCL device supports double precision floating point operations.

For OpenCL 1.1 and lower this method returns true if the extensions cl_khr_fp64 is supported. For OpenCL 1.2 and higher this method returns true if clGetDeviceInfo for CL_DEVICE_DOUBLE_FP_CONFIG returns a non-zero parameter value.


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