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 200 
   31 #define CL_TARGET_OPENCL_VERSION 200 
   34 #include "qgsconfig.h" 
   36 #ifdef OPENCL_USE_NEW_HEADER 
   37 #include <CL/opencl.hpp> 
   42 #include "qgis_core.h" 
  104     Q_ENUM( HardwareType )
 
  113       Name = CL_DEVICE_NAME,
 
  114       Vendor = CL_DEVICE_VENDOR,
 
  115       Version = CL_DEVICE_VERSION,
 
  116       Profile = CL_DEVICE_PROFILE,
 
  117       ImageSupport = CL_DEVICE_IMAGE_SUPPORT,
 
  118       Image2dMaxWidth = CL_DEVICE_IMAGE2D_MAX_WIDTH,
 
  119       Image2dMaxHeight = CL_DEVICE_IMAGE2D_MAX_HEIGHT,
 
  120       MaxMemAllocSize = CL_DEVICE_MAX_MEM_ALLOC_SIZE,
 
  121       Type = CL_DEVICE_TYPE 
 
  133     static bool available();
 
  136     static bool enabled();
 
  139     static const std::vector<cl::Device> devices();
 
  148     static cl::Device activeDevice( );
 
  155     static QString activePlatformVersion( );
 
  158     static void storePreferredDevice( 
const QString deviceId );
 
  161     static QString preferredDevice( );
 
  164     static QString deviceId( 
const cl::Device device );
 
  169     static QString deviceDescription( 
const cl::Device device );
 
  174     static QString deviceDescription( 
const QString deviceId );
 
  177     static void setEnabled( 
bool enabled );
 
  180     static QString buildLog( cl::BuildError &error );
 
  183     static QString sourceFromPath( 
const QString &path );
 
  186     static QString sourceFromBaseName( 
const QString &baseName );
 
  192     static QString errorText( 
const int errorCode );
 
  200     static cl::CommandQueue commandQueue();
 
  208     Q_DECL_DEPRECATED 
static cl::Program buildProgram( 
const cl::Context &context, 
const QString &source, 
ExceptionBehavior exceptionBehavior = Catch );
 
  214     static cl::Program buildProgram( 
const QString &source, 
ExceptionBehavior exceptionBehavior = Catch );
 
  224     static cl::Context context();
 
  227     static QString sourcePath();
 
  230     static void setSourcePath( 
const QString &value );
 
  233     static QString activeDeviceInfo( 
const Info infoType = Info::Name );
 
  236     static QString deviceInfo( 
const Info infoType, cl::Device device );
 
  242     template <
typename T>
 
  248         explicit CPLAllocator( 
unsigned long size ): mMem( static_cast<T *>( CPLMalloc( sizeof( T ) * size ) ) ) { }
 
  252           CPLFree( 
static_cast<void *
>( mMem ) );
 
  258             CPLFree( 
static_cast<void *
>( mMem ) );
 
  264           reset( 
static_cast<T *
>( CPLMalloc( 
sizeof( T ) *size ) ) );
 
  312     static bool activate( 
const QString &preferredDeviceId = QString() );
 
  319     static bool sAvailable;
 
  320     static QLatin1String SETTINGS_GLOBAL_ENABLED_KEY;
 
  321     static QLatin1String SETTINGS_DEFAULT_DEVICE_KEY;
 
  326 #endif // QGSOPENCLUTILS_H