QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
The QgsOpenClUtils class is responsible for common OpenCL operations such as. More...
#include <qgsopenclutils.h>
Classes | |
struct | CPLAllocator |
Tiny smart-pointer-like wrapper around CPLMalloc and CPLFree: this is needed because OpenCL C++ API may throw exceptions. More... | |
Public Types | |
enum | ExceptionBehavior { Catch , Throw } |
The ExceptionBehavior enum define how exceptions generated by OpenCL should be treated. More... | |
enum | HardwareType { CPU , GPU , Other } |
The Type enum represent OpenCL device type. More... | |
enum | Info { Name = CL_DEVICE_NAME , Vendor = CL_DEVICE_VENDOR , Version = CL_DEVICE_VERSION , Profile = CL_DEVICE_PROFILE , ImageSupport = CL_DEVICE_IMAGE_SUPPORT , Image2dMaxWidth = CL_DEVICE_IMAGE2D_MAX_WIDTH , Image2dMaxHeight = CL_DEVICE_IMAGE2D_MAX_HEIGHT , MaxMemAllocSize = CL_DEVICE_MAX_MEM_ALLOC_SIZE , Type = CL_DEVICE_TYPE } |
The Info enum maps to OpenCL info constants. More... | |
Static Public Member Functions | |
static cl::Device | activeDevice () |
Returns the active device. | |
static QString | activeDeviceInfo (const Info infoType=Info::Name) |
Returns infoType information about the active (default) device. | |
static QString | activePlatformVersion () |
Returns the active platform OpenCL version string (e.g. | |
static bool | available () |
Checks whether a suitable OpenCL platform and device is available on this system and initialize the QGIS OpenCL system by activating the preferred device if specified in the user the settings, if no preferred device was set or the preferred device could not be found the first GPU device is activated, the first CPU device acts as a fallback if none of the previous could be found. | |
static QString | buildLog (cl::BuildError &error) |
Extract and return the build log error from error. | |
static Q_DECL_DEPRECATED cl::Program | buildProgram (const cl::Context &context, const QString &source, ExceptionBehavior exceptionBehavior=Catch) |
Build the program from source in the given context and depending on exceptionBehavior can throw or catch the exceptions. | |
static cl::Program | buildProgram (const QString &source, ExceptionBehavior exceptionBehavior=Catch) |
Build the program from source, depending on exceptionBehavior can throw or catch the exceptions. | |
static cl::CommandQueue | commandQueue () |
Create an OpenCL command queue from the default context. | |
static cl::Context | context () |
Context factory. | |
static QString | deviceDescription (const cl::Device device) |
Returns a formatted description for the device. | |
static QString | deviceDescription (const QString deviceId) |
Returns a formatted description for the device identified by deviceId. | |
static QString | deviceId (const cl::Device device) |
Create a string identifier from a device. | |
static QString | deviceInfo (const Info infoType, cl::Device device) |
Returns infoType information about the device. | |
static const std::vector< cl::Device > | devices () |
Returns a list of OpenCL devices found on this sysytem. | |
static bool | enabled () |
Returns true if OpenCL is enabled in the user settings. | |
static QString | errorText (const int errorCode) |
Returns a string representation from an OpenCL errorCode. | |
static QString | preferredDevice () |
Read from the settings the preferred device identifier. | |
static void | setEnabled (bool enabled) |
Set the OpenCL user setting to enabled. | |
static void | setSourcePath (const QString &value) |
Set the base path to OpenCL program directory. | |
static QString | sourceFromBaseName (const QString &baseName) |
Returns the full path to a an OpenCL source file from the baseName ('.cl' extension is automatically appended) | |
static QString | sourceFromPath (const QString &path) |
Read an OpenCL source file from path. | |
static QString | sourcePath () |
Returns the base path to OpenCL program directory. | |
static void | storePreferredDevice (const QString deviceId) |
Store in the settings the preferred deviceId device identifier. | |
Static Public Attributes | |
static QLatin1String | LOGMESSAGE_TAG = QLatin1String( "OpenCL" ) |
OpenCL string for message logs. | |
The QgsOpenClUtils class is responsible for common OpenCL operations such as.
Usage:
Definition at line 79 of file qgsopenclutils.h.
The ExceptionBehavior enum define how exceptions generated by OpenCL should be treated.
Enumerator | |
---|---|
Catch | Write errors in the message log and silently fail. |
Throw | Write errors in the message log and re-throw exceptions. |
Definition at line 88 of file qgsopenclutils.h.
The Type enum represent OpenCL device type.
Enumerator | |
---|---|
CPU | |
GPU | |
Other |
Definition at line 97 of file qgsopenclutils.h.
enum QgsOpenClUtils::Info |
The Info enum maps to OpenCL info constants.
Enumerator | |
---|---|
Name | |
Vendor | |
Version | |
Profile | |
ImageSupport | |
Image2dMaxWidth | |
Image2dMaxHeight | |
MaxMemAllocSize | |
Type |
Definition at line 111 of file qgsopenclutils.h.
|
static |
Returns the active device.
The active device is set as the default device for all OpenCL operations, once it is set it cannot be changed until QGIS is restarted (this is due to the way the underlying OpenCL library is built).
Definition at line 301 of file qgsopenclutils.cpp.
|
static |
Returns infoType information about the active (default) device.
Definition at line 237 of file qgsopenclutils.cpp.
|
static |
Returns the active platform OpenCL version string (e.g.
1.1, 2.0 etc.) or a blank string if there is no active platform.
Definition at line 306 of file qgsopenclutils.cpp.
|
static |
Checks whether a suitable OpenCL platform and device is available on this system and initialize the QGIS OpenCL system by activating the preferred device if specified in the user the settings, if no preferred device was set or the preferred device could not be found the first GPU device is activated, the first CPU device acts as a fallback if none of the previous could be found.
This function must always be called before using QGIS OpenCL utils
Definition at line 494 of file qgsopenclutils.cpp.
|
static |
Extract and return the build log error from error.
Definition at line 532 of file qgsopenclutils.cpp.
|
static |
Build the program from source in the given context and depending on exceptionBehavior can throw or catch the exceptions.
Definition at line 673 of file qgsopenclutils.cpp.
|
static |
Build the program from source, depending on exceptionBehavior can throw or catch the exceptions.
Definition at line 679 of file qgsopenclutils.cpp.
|
static |
Create an OpenCL command queue from the default context.
This wrapper is required in order to prevent a crash when running on OpenCL platforms < 2
Definition at line 638 of file qgsopenclutils.cpp.
|
static |
Context factory.
Definition at line 659 of file qgsopenclutils.cpp.
|
static |
Returns a formatted description for the device.
Definition at line 461 of file qgsopenclutils.cpp.
|
static |
Returns a formatted description for the device identified by deviceId.
Definition at line 484 of file qgsopenclutils.cpp.
|
static |
Create a string identifier from a device.
Definition at line 330 of file qgsopenclutils.cpp.
|
static |
Returns infoType information about the device.
Definition at line 242 of file qgsopenclutils.cpp.
|
static |
Returns a list of OpenCL devices found on this sysytem.
Definition at line 44 of file qgsopenclutils.cpp.
|
static |
Returns true
if OpenCL is enabled in the user settings.
Definition at line 296 of file qgsopenclutils.cpp.
|
static |
Returns a string representation from an OpenCL errorCode.
Definition at line 541 of file qgsopenclutils.cpp.
|
static |
Read from the settings the preferred device identifier.
Definition at line 325 of file qgsopenclutils.cpp.
|
static |
Set the OpenCL user setting to enabled.
Definition at line 500 of file qgsopenclutils.cpp.
|
static |
Set the base path to OpenCL program directory.
Definition at line 232 of file qgsopenclutils.cpp.
|
static |
Returns the full path to a an OpenCL source file from the baseName ('.cl' extension is automatically appended)
Definition at line 526 of file qgsopenclutils.cpp.
|
static |
Read an OpenCL source file from path.
Definition at line 507 of file qgsopenclutils.cpp.
|
static |
Returns the base path to OpenCL program directory.
Definition at line 227 of file qgsopenclutils.cpp.
|
static |
Store in the settings the preferred deviceId device identifier.
Definition at line 320 of file qgsopenclutils.cpp.
|
static |
OpenCL string for message logs.
Definition at line 189 of file qgsopenclutils.h.