Skip to content
Permalink
Browse files

Wrap make program in OpenCL utils

  • Loading branch information
elpaso committed Aug 8, 2018
1 parent 79f0ead commit 16a49cddaa18cb6d0b12335fe24c68cda183e1c0
Showing with 46 additions and 0 deletions.
  1. +32 −0 src/core/qgsopenclutils.cpp
  2. +14 −0 src/core/qgsopenclutils.h
@@ -528,3 +528,35 @@ cl::Program QgsOpenClUtils::buildProgram( const cl::Context &context, const QStr
}
return program;
}

cl::Program QgsOpenClUtils::buildProgram( const cl::Context &context, const QString &source, ExceptionBehavior exceptionBehavior )
{
cl::Program program;
try
{
program = cl::Program( context, source.toStdString( ) );
program.build( "-cl-std=CL1.1" );
}
catch ( cl::BuildError &e )
{
cl::BuildLogType build_logs = e.getBuildLog();
QString build_log;
if ( build_logs.size() > 0 )
build_log = QString::fromStdString( build_logs[0].second );
else
build_log = QObject::tr( "Build logs not available!" );
QString err = QObject::tr( "Error building OpenCL program: %1" )
.arg( build_log );
QgsMessageLog::logMessage( err, LOGMESSAGE_TAG, Qgis::Critical );
if ( exceptionBehavior == Throw )
throw e;
}
catch ( cl::Error &e )
{
QString err = QObject::tr( "Error %1 running OpenCL program in %2" )
.arg( errorText( e.err() ), QString::fromStdString( e.what() ) );
QgsMessageLog::logMessage( err, LOGMESSAGE_TAG, Qgis::Critical );
throw e;
}
return program;
}
@@ -65,6 +65,7 @@ class CORE_EXPORT QgsOpenClUtils

public:

<<<<<<< 79f0eadb05fe4d845ab29045c40c34e1e08b4710
/**
* The ExceptionBehavior enum define how exceptions generated by OpenCL should be treated
*/
@@ -113,6 +114,15 @@ class CORE_EXPORT QgsOpenClUtils
*
* This function must always be called before using QGIS OpenCL utils
*/
=======
enum ExceptionBehavior
{
Catch,
Throw
};

static bool enabled();
>>>>>>> Wrap make program in OpenCL utils
static bool available();

//! Returns true if OpenCL is enabled in the user settings
@@ -166,6 +176,7 @@ class CORE_EXPORT QgsOpenClUtils

//! Returns a string representation from an OpenCL \a errorCode
static QString errorText( const int errorCode );
<<<<<<< 79f0eadb05fe4d845ab29045c40c34e1e08b4710

/**
* Build the program from \a source in the given \a context and depending on \a exceptionBehavior
@@ -181,6 +192,9 @@ class CORE_EXPORT QgsOpenClUtils
* no device were identified or OpenCL support is not available
* and enabled
*/
=======
static cl::Program buildProgram( const cl::Context &context, const QString &source, ExceptionBehavior exceptionBehavior = Catch );
>>>>>>> Wrap make program in OpenCL utils
static cl::Context context();

//! Returns the base path to OpenCL program directory

0 comments on commit 16a49cd

Please sign in to comment.
You can’t perform that action at this time.