16 #ifndef QGSOPENCLUTILS_H 17 #define QGSOPENCLUTILS_H 21 #define CL_HPP_ENABLE_EXCEPTIONS 25 #define CL_HPP_MINIMUM_OPENCL_VERSION 120 26 #define CL_HPP_TARGET_OPENCL_VERSION 120 27 #define CL_TARGET_OPENCL_VERSION 120 29 #define CL_USE_DEPRECATED_OPENCL_1_1_APIS 30 #define CL_HPP_TARGET_OPENCL_VERSION 220 31 #define CL_TARGET_OPENCL_VERSION 200 36 #include "qgis_core.h" 106 Name = CL_DEVICE_NAME,
107 Vendor = CL_DEVICE_VENDOR,
108 Version = CL_DEVICE_VERSION,
109 Profile = CL_DEVICE_PROFILE,
110 ImageSupport = CL_DEVICE_IMAGE_SUPPORT,
111 Image2dMaxWidth = CL_DEVICE_IMAGE2D_MAX_WIDTH,
112 Image2dMaxHeight = CL_DEVICE_IMAGE2D_MAX_HEIGHT,
113 MaxMemAllocSize = CL_DEVICE_MAX_MEM_ALLOC_SIZE,
114 Type = CL_DEVICE_TYPE
126 static bool available();
129 static bool enabled();
132 static const std::vector<cl::Device> devices();
141 static cl::Device activeDevice( );
148 static QString activePlatformVersion( );
151 static void storePreferredDevice(
const QString deviceId );
154 static QString preferredDevice( );
157 static QString deviceId(
const cl::Device device );
162 static QString deviceDescription(
const cl::Device device );
167 static QString deviceDescription(
const QString deviceId );
170 static void setEnabled(
bool enabled );
173 static QString buildLog( cl::BuildError &error );
176 static QString sourceFromPath(
const QString &path );
179 static QString sourceFromBaseName(
const QString &baseName );
185 static QString errorText(
const int errorCode );
193 static cl::CommandQueue commandQueue();
201 Q_DECL_DEPRECATED
static cl::Program buildProgram(
const cl::Context &context,
const QString &source,
ExceptionBehavior exceptionBehavior = Catch );
207 static cl::Program buildProgram(
const QString &source,
ExceptionBehavior exceptionBehavior = Catch );
217 static cl::Context context();
220 static QString sourcePath();
223 static void setSourcePath(
const QString &value );
226 static QString activeDeviceInfo(
const Info infoType = Info::Name );
229 static QString deviceInfo(
const Info infoType, cl::Device device );
235 template <
typename T>
241 explicit CPLAllocator(
unsigned long size ): mMem( static_cast<T *>( CPLMalloc( sizeof( T ) * size ) ) ) { }
245 CPLFree( static_cast<void *>( mMem ) );
251 CPLFree( static_cast<void *>( mMem ) );
257 reset( static_cast<T *>( CPLMalloc(
sizeof( T ) *size ) ) );
305 static bool activate(
const QString &preferredDeviceId = QString() );
312 static bool sAvailable;
313 static QLatin1String SETTINGS_GLOBAL_ENABLED_KEY;
314 static QLatin1String SETTINGS_DEFAULT_DEVICE_KEY;
315 static QString sSourcePath;
320 #endif // QGSOPENCLUTILS_H
void reset(unsigned long size)
Tiny smart-pointer-like wrapper around CPLMalloc and CPLFree: this is needed because OpenCL C++ API m...
CPLAllocator(unsigned long size)
T & operator[](const int index)
The QgsOpenClUtils class is responsible for common OpenCL operations such as.
Info
The Info enum maps to OpenCL info constants.
ExceptionBehavior
The ExceptionBehavior enum define how exceptions generated by OpenCL should be treated.
HardwareType
The Type enum represent OpenCL device type.
static QLatin1String LOGMESSAGE_TAG
OpenCL string for message logs.
QgsMargins operator*(const QgsMargins &margins, double factor)
Returns a QgsMargins object that is formed by multiplying each component of the given margins by fact...