Kaydet (Commit) 598f25c8 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Clean up confusing OpenCL code a bit

Get rid of the silly OpenCLDevice class that had only static members. We can
as well just use namespacing. Remove functions only used internally in
openclwrapper.cxx from the now public openclwrapper.hxx header.

Change-Id: If7336edd262c772564dc13e64113d72d0b52428c
üst a02a54f5
...@@ -68,25 +68,10 @@ struct GPUEnv ...@@ -68,25 +68,10 @@ struct GPUEnv
bool mnAmdFp64Flag; bool mnAmdFp64Flag;
}; };
class OPENCL_DLLPUBLIC OpenCLDevice extern OPENCL_DLLPUBLIC GPUEnv gpuEnv;
{ OPENCL_DLLPUBLIC bool generatBinFromKernelSource( cl_program program, const char * clFileName );
public: OPENCL_DLLPUBLIC bool buildProgramFromBinary(const char* buildOption, GPUEnv* gpuEnv, const char* filename, int idx);
static GPUEnv gpuEnv; OPENCL_DLLPUBLIC void setKernelEnv( KernelEnv *envInfo );
static bool bIsInited;
static OString maCacheFolder;
static bool initOpenCLRunEnv( GPUEnv *gpu );
static void releaseOpenCLEnv( GPUEnv *gpuInfo );
static bool initOpenCLRunEnv( int argc );
static bool generatBinFromKernelSource( cl_program program, const char * clFileName );
static bool writeBinaryToFile( const OString& rName, const char* birary, size_t numBytes );
static std::vector<boost::shared_ptr<osl::File> > binaryGenerated( const char * clFileName, cl_context context);
static bool buildProgramFromBinary(const char* buildOption, GPUEnv* gpuEnv, const char* filename, int idx);
static bool initOpenCLAttr( OpenCLEnv * env );
static void setKernelEnv( KernelEnv *envInfo );
};
OPENCL_DLLPUBLIC const std::vector<OpenCLPlatformInfo>& fillOpenCLInfo(); OPENCL_DLLPUBLIC const std::vector<OpenCLPlatformInfo>& fillOpenCLInfo();
/** /**
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "opencl_device_selection.h" #include "opencl_device_selection.h"
namespace OpenCLDevice { namespace opencl {
ds_device getDeviceSelection(const char* pFileName, bool bForceSelection = false); ds_device getDeviceSelection(const char* pFileName, bool bForceSelection = false);
bool selectedDeviceIsOpenCL(ds_device device); bool selectedDeviceIsOpenCL(ds_device device);
......
...@@ -44,9 +44,8 @@ ...@@ -44,9 +44,8 @@
SAL_INFO("opencl.device", "Error code is " << status << " at " name); \ SAL_INFO("opencl.device", "Error code is " << status << " at " name); \
} }
namespace OpenCLDevice { namespace opencl {
bool bIsInited = false;
bool bIsDeviceSelected = false; bool bIsDeviceSelected = false;
ds_device selectedDevice; ds_device selectedDevice;
......
...@@ -48,11 +48,12 @@ using namespace std; ...@@ -48,11 +48,12 @@ using namespace std;
namespace opencl { namespace opencl {
GPUEnv OpenCLDevice::gpuEnv; GPUEnv gpuEnv;
bool OpenCLDevice::bIsInited = false;
namespace { namespace {
bool bIsInited = false;
OString generateMD5(const void* pData, size_t length) OString generateMD5(const void* pData, size_t length)
{ {
sal_uInt8 pBuffer[RTL_DIGEST_LENGTH_MD5]; sal_uInt8 pBuffer[RTL_DIGEST_LENGTH_MD5];
...@@ -81,11 +82,11 @@ OString getCacheFolder() ...@@ -81,11 +82,11 @@ OString getCacheFolder()
return rtl::OUStringToOString(url, RTL_TEXTENCODING_UTF8); return rtl::OUStringToOString(url, RTL_TEXTENCODING_UTF8);
} }
} OString maCacheFolder = getCacheFolder();
OString OpenCLDevice::maCacheFolder = getCacheFolder(); }
void OpenCLDevice::setKernelEnv( KernelEnv *envInfo ) void setKernelEnv( KernelEnv *envInfo )
{ {
envInfo->mpkContext = gpuEnv.mpContext; envInfo->mpkContext = gpuEnv.mpContext;
envInfo->mpkCmdQueue = gpuEnv.mpCmdQueue; envInfo->mpkCmdQueue = gpuEnv.mpCmdQueue;
...@@ -121,13 +122,11 @@ OString createFileName(cl_device_id deviceId, const char* clFileName) ...@@ -121,13 +122,11 @@ OString createFileName(cl_device_id deviceId, const char* clFileName)
OString aString = OString(deviceName) + driverVersion + platformVersion; OString aString = OString(deviceName) + driverVersion + platformVersion;
OString aHash = generateMD5(aString.getStr(), aString.getLength()); OString aHash = generateMD5(aString.getStr(), aString.getLength());
return OpenCLDevice::maCacheFolder + fileName + "-" + return maCacheFolder + fileName + "-" +
aHash + ".bin"; aHash + ".bin";
} }
} std::vector<boost::shared_ptr<osl::File> > binaryGenerated( const char * clFileName, cl_context context )
std::vector<boost::shared_ptr<osl::File> > OpenCLDevice::binaryGenerated( const char * clFileName, cl_context context )
{ {
size_t numDevices=0; size_t numDevices=0;
...@@ -170,7 +169,7 @@ std::vector<boost::shared_ptr<osl::File> > OpenCLDevice::binaryGenerated( const ...@@ -170,7 +169,7 @@ std::vector<boost::shared_ptr<osl::File> > OpenCLDevice::binaryGenerated( const
return aGeneratedFiles; return aGeneratedFiles;
} }
bool OpenCLDevice::writeBinaryToFile( const OString& rFileName, const char* binary, size_t numBytes ) bool writeBinaryToFile( const OString& rFileName, const char* binary, size_t numBytes )
{ {
osl::File file(rtl::OStringToOUString(rFileName, RTL_TEXTENCODING_UTF8)); osl::File file(rtl::OStringToOUString(rFileName, RTL_TEXTENCODING_UTF8));
osl::FileBase::RC status = file.open( osl::FileBase::RC status = file.open(
...@@ -187,7 +186,9 @@ bool OpenCLDevice::writeBinaryToFile( const OString& rFileName, const char* bina ...@@ -187,7 +186,9 @@ bool OpenCLDevice::writeBinaryToFile( const OString& rFileName, const char* bina
return true; return true;
} }
bool OpenCLDevice::generatBinFromKernelSource( cl_program program, const char * clFileName ) }
bool generatBinFromKernelSource( cl_program program, const char * clFileName )
{ {
cl_uint numDevices; cl_uint numDevices;
...@@ -251,7 +252,9 @@ bool OpenCLDevice::generatBinFromKernelSource( cl_program program, const char * ...@@ -251,7 +252,9 @@ bool OpenCLDevice::generatBinFromKernelSource( cl_program program, const char *
return true; return true;
} }
bool OpenCLDevice::initOpenCLAttr( OpenCLEnv * env ) namespace {
bool initOpenCLAttr( OpenCLEnv * env )
{ {
if ( gpuEnv.mnIsUserCreated ) if ( gpuEnv.mnIsUserCreated )
return true; return true;
...@@ -266,7 +269,7 @@ bool OpenCLDevice::initOpenCLAttr( OpenCLEnv * env ) ...@@ -266,7 +269,7 @@ bool OpenCLDevice::initOpenCLAttr( OpenCLEnv * env )
return false; return false;
} }
void OpenCLDevice::releaseOpenCLEnv( GPUEnv *gpuInfo ) void releaseOpenCLEnv( GPUEnv *gpuInfo )
{ {
if ( !bIsInited ) if ( !bIsInited )
{ {
...@@ -290,8 +293,6 @@ void OpenCLDevice::releaseOpenCLEnv( GPUEnv *gpuInfo ) ...@@ -290,8 +293,6 @@ void OpenCLDevice::releaseOpenCLEnv( GPUEnv *gpuInfo )
return; return;
} }
namespace {
bool buildProgram(const char* buildOption, GPUEnv* gpuInfo, int idx) bool buildProgram(const char* buildOption, GPUEnv* gpuInfo, int idx)
{ {
cl_int clStatus; cl_int clStatus;
...@@ -342,7 +343,7 @@ bool buildProgram(const char* buildOption, GPUEnv* gpuInfo, int idx) ...@@ -342,7 +343,7 @@ bool buildProgram(const char* buildOption, GPUEnv* gpuInfo, int idx)
return false; return false;
} }
OString aBuildLogFileURL = OpenCLDevice::maCacheFolder + "kernel-build.log"; OString aBuildLogFileURL = maCacheFolder + "kernel-build.log";
osl::File aBuildLogFile(rtl::OStringToOUString(aBuildLogFileURL, RTL_TEXTENCODING_UTF8)); osl::File aBuildLogFile(rtl::OStringToOUString(aBuildLogFileURL, RTL_TEXTENCODING_UTF8));
osl::FileBase::RC status = aBuildLogFile.open( osl::FileBase::RC status = aBuildLogFile.open(
osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
...@@ -361,7 +362,7 @@ bool buildProgram(const char* buildOption, GPUEnv* gpuInfo, int idx) ...@@ -361,7 +362,7 @@ bool buildProgram(const char* buildOption, GPUEnv* gpuInfo, int idx)
} }
bool OpenCLDevice::buildProgramFromBinary(const char* buildOption, GPUEnv* gpuInfo, const char* filename, int idx) bool buildProgramFromBinary(const char* buildOption, GPUEnv* gpuInfo, const char* filename, int idx)
{ {
size_t numDevices; size_t numDevices;
cl_int clStatus = clGetContextInfo( gpuInfo->mpContext, CL_CONTEXT_DEVICES, cl_int clStatus = clGetContextInfo( gpuInfo->mpContext, CL_CONTEXT_DEVICES,
...@@ -428,45 +429,6 @@ bool OpenCLDevice::buildProgramFromBinary(const char* buildOption, GPUEnv* gpuIn ...@@ -428,45 +429,6 @@ bool OpenCLDevice::buildProgramFromBinary(const char* buildOption, GPUEnv* gpuIn
return buildProgram(buildOption, gpuInfo, idx); return buildProgram(buildOption, gpuInfo, idx);
} }
bool OpenCLDevice::initOpenCLRunEnv( int argc )
{
if ( ( argc > MAX_CLFILE_NUM ) || ( argc < 0 ) )
return true;
if ( !bIsInited )
{
if ( !gpuEnv.mnIsUserCreated )
memset( &gpuEnv, 0, sizeof(gpuEnv) );
//initialize devices, context, command_queue
bool status = initOpenCLRunEnv( &gpuEnv );
if ( status )
{
return true;
}
//initialize program, kernelName, kernelCount
if( getenv( "SC_FLOAT" ) )
{
gpuEnv.mnKhrFp64Flag = false;
gpuEnv.mnAmdFp64Flag = false;
}
if( gpuEnv.mnKhrFp64Flag )
{
SAL_INFO("opencl", "Use Khr double");
}
else if( gpuEnv.mnAmdFp64Flag )
{
SAL_INFO("opencl", "Use AMD double type");
}
else
{
SAL_INFO("opencl", "USE float type");
}
bIsInited = true;
}
return false;
}
namespace { namespace {
void checkDeviceForDoubleSupport(cl_device_id deviceId, bool& bKhrFp64, bool& bAmdFp64) void checkDeviceForDoubleSupport(cl_device_id deviceId, bool& bKhrFp64, bool& bAmdFp64)
...@@ -501,9 +463,7 @@ void checkDeviceForDoubleSupport(cl_device_id deviceId, bool& bKhrFp64, bool& bA ...@@ -501,9 +463,7 @@ void checkDeviceForDoubleSupport(cl_device_id deviceId, bool& bKhrFp64, bool& bA
} }
} }
} bool initOpenCLRunEnv( GPUEnv *gpuInfo )
bool OpenCLDevice::initOpenCLRunEnv( GPUEnv *gpuInfo )
{ {
bool bKhrFp64 = false; bool bKhrFp64 = false;
bool bAmdFp64 = false; bool bAmdFp64 = false;
...@@ -516,7 +476,44 @@ bool OpenCLDevice::initOpenCLRunEnv( GPUEnv *gpuInfo ) ...@@ -516,7 +476,44 @@ bool OpenCLDevice::initOpenCLRunEnv( GPUEnv *gpuInfo )
return false; return false;
} }
namespace { bool initOpenCLRunEnv( int argc )
{
if ( ( argc > MAX_CLFILE_NUM ) || ( argc < 0 ) )
return true;
if ( !bIsInited )
{
if ( !gpuEnv.mnIsUserCreated )
memset( &gpuEnv, 0, sizeof(gpuEnv) );
//initialize devices, context, command_queue
bool status = initOpenCLRunEnv( &gpuEnv );
if ( status )
{
return true;
}
//initialize program, kernelName, kernelCount
if( getenv( "SC_FLOAT" ) )
{
gpuEnv.mnKhrFp64Flag = false;
gpuEnv.mnAmdFp64Flag = false;
}
if( gpuEnv.mnKhrFp64Flag )
{
SAL_INFO("opencl", "Use Khr double");
}
else if( gpuEnv.mnAmdFp64Flag )
{
SAL_INFO("opencl", "Use AMD double type");
}
else
{
SAL_INFO("opencl", "USE float type");
}
bIsInited = true;
}
return false;
}
// based on crashes and hanging during kernel compilation // based on crashes and hanging during kernel compilation
void createDeviceInfo(cl_device_id aDeviceId, OpenCLPlatformInfo& rPlatformInfo) void createDeviceInfo(cl_device_id aDeviceId, OpenCLPlatformInfo& rPlatformInfo)
...@@ -725,12 +722,12 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv ...@@ -725,12 +722,12 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
OUString path; OUString path;
osl::FileBase::getSystemPathFromFileURL(url,path); osl::FileBase::getSystemPathFromFileURL(url,path);
OString dsFileName = rtl::OUStringToOString(path, RTL_TEXTENCODING_UTF8); OString dsFileName = rtl::OUStringToOString(path, RTL_TEXTENCODING_UTF8);
ds_device pSelectedDevice = ::OpenCLDevice::getDeviceSelection(dsFileName.getStr(), bForceEvaluation); ds_device pSelectedDevice = getDeviceSelection(dsFileName.getStr(), bForceEvaluation);
pDeviceId = pSelectedDevice.oclDeviceID; pDeviceId = pSelectedDevice.oclDeviceID;
} }
if(OpenCLDevice::gpuEnv.mpDevID == pDeviceId) if(gpuEnv.mpDevID == pDeviceId)
{ {
// we don't need to change anything // we don't need to change anything
// still the same device // still the same device
...@@ -769,13 +766,13 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv ...@@ -769,13 +766,13 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
return false; return false;
} }
OpenCLDevice::releaseOpenCLEnv(&OpenCLDevice::gpuEnv); releaseOpenCLEnv(&gpuEnv);
OpenCLEnv env; OpenCLEnv env;
env.mpOclPlatformID = platformId; env.mpOclPlatformID = platformId;
env.mpOclContext = context; env.mpOclContext = context;
env.mpOclDevsID = pDeviceId; env.mpOclDevsID = pDeviceId;
env.mpOclCmdQueue = command_queue; env.mpOclCmdQueue = command_queue;
OpenCLDevice::initOpenCLAttr(&env); initOpenCLAttr(&env);
// why do we need this at all? // why do we need this at all?
...@@ -783,10 +780,10 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv ...@@ -783,10 +780,10 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
// initialisation below.) Because otherwise the code crashes in // initialisation below.) Because otherwise the code crashes in
// initOpenCLRunEnv(). Confused? You should be. // initOpenCLRunEnv(). Confused? You should be.
OpenCLDevice::gpuEnv.mpArryDevsID = (cl_device_id*) malloc( sizeof(cl_device_id) ); gpuEnv.mpArryDevsID = (cl_device_id*) malloc( sizeof(cl_device_id) );
OpenCLDevice::gpuEnv.mpArryDevsID[0] = pDeviceId; gpuEnv.mpArryDevsID[0] = pDeviceId;
return !OpenCLDevice::initOpenCLRunEnv(0); return !initOpenCLRunEnv(0);
} }
void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId) void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId)
...@@ -795,7 +792,7 @@ void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId) ...@@ -795,7 +792,7 @@ void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId)
if (status < 0) if (status < 0)
return; return;
cl_device_id id = OpenCLDevice::gpuEnv.mpDevID; cl_device_id id = gpuEnv.mpDevID;
findDeviceInfoFromDeviceId(id, rDeviceId, rPlatformId); findDeviceInfoFromDeviceId(id, rDeviceId, rPlatformId);
} }
......
...@@ -114,7 +114,7 @@ size_t VectorRef::Marshal( cl_kernel k, int argno, int, cl_program ) ...@@ -114,7 +114,7 @@ size_t VectorRef::Marshal( cl_kernel k, int argno, int, cl_program )
} }
// Obtain cl context // Obtain cl context
KernelEnv kEnv; KernelEnv kEnv;
::opencl::OpenCLDevice::setKernelEnv(&kEnv); ::opencl::setKernelEnv(&kEnv);
cl_int err; cl_int err;
if (pHostBuffer) if (pHostBuffer)
{ {
...@@ -205,7 +205,7 @@ public: ...@@ -205,7 +205,7 @@ public:
// marshaling // marshaling
// Obtain cl context // Obtain cl context
KernelEnv kEnv; KernelEnv kEnv;
::opencl::OpenCLDevice::setKernelEnv(&kEnv); ::opencl::setKernelEnv(&kEnv);
// Pass the scalar result back to the rest of the formula kernel // Pass the scalar result back to the rest of the formula kernel
cl_int err = clSetKernelArg(k, argno, sizeof(cl_uint), (void*)&hashCode); cl_int err = clSetKernelArg(k, argno, sizeof(cl_uint), (void*)&hashCode);
if (CL_SUCCESS != err) if (CL_SUCCESS != err)
...@@ -389,7 +389,7 @@ size_t DynamicKernelStringArgument::Marshal( cl_kernel k, int argno, int, cl_pro ...@@ -389,7 +389,7 @@ size_t DynamicKernelStringArgument::Marshal( cl_kernel k, int argno, int, cl_pro
FormulaToken* ref = mFormulaTree->GetFormulaToken(); FormulaToken* ref = mFormulaTree->GetFormulaToken();
// Obtain cl context // Obtain cl context
KernelEnv kEnv; KernelEnv kEnv;
::opencl::OpenCLDevice::setKernelEnv(&kEnv); ::opencl::setKernelEnv(&kEnv);
cl_int err; cl_int err;
formula::VectorRefArray vRef; formula::VectorRefArray vRef;
size_t nStrings = 0; size_t nStrings = 0;
...@@ -1132,7 +1132,7 @@ public: ...@@ -1132,7 +1132,7 @@ public:
assert(Base::mpClmem == NULL); assert(Base::mpClmem == NULL);
// Obtain cl context // Obtain cl context
KernelEnv kEnv; KernelEnv kEnv;
::opencl::OpenCLDevice::setKernelEnv(&kEnv); ::opencl::setKernelEnv(&kEnv);
cl_int err; cl_int err;
size_t nInput = mpDVR->GetArrayLength(); size_t nInput = mpDVR->GetArrayLength();
size_t nCurWindowSize = mpDVR->GetRefRowSize(); size_t nCurWindowSize = mpDVR->GetRefRowSize();
...@@ -1913,7 +1913,7 @@ public: ...@@ -1913,7 +1913,7 @@ public:
{ {
// Obtain cl context // Obtain cl context
KernelEnv kEnv; KernelEnv kEnv;
::opencl::OpenCLDevice::setKernelEnv(&kEnv); ::opencl::setKernelEnv(&kEnv);
cl_int err; cl_int err;
cl_mem pClmem2; cl_mem pClmem2;
...@@ -1971,7 +1971,7 @@ public: ...@@ -1971,7 +1971,7 @@ public:
{ {
// Obtain cl context // Obtain cl context
KernelEnv kEnv; KernelEnv kEnv;
::opencl::OpenCLDevice::setKernelEnv(&kEnv); ::opencl::setKernelEnv(&kEnv);
cl_int err; cl_int err;
DynamicKernelArgument* Arg = mvSubArguments[0].get(); DynamicKernelArgument* Arg = mvSubArguments[0].get();
DynamicKernelSlidingArgument<VectorRef>* slidingArgPtr = DynamicKernelSlidingArgument<VectorRef>* slidingArgPtr =
...@@ -3282,11 +3282,11 @@ public: ...@@ -3282,11 +3282,11 @@ public:
DynamicKernelSoPArguments>(mpRoot, new OpNop); DynamicKernelSoPArguments>(mpRoot, new OpNop);
std::stringstream decl; std::stringstream decl;
if (::opencl::OpenCLDevice::gpuEnv.mnKhrFp64Flag) if (::opencl::gpuEnv.mnKhrFp64Flag)
{ {
decl << "#pragma OPENCL EXTENSION cl_khr_fp64: enable\n"; decl << "#pragma OPENCL EXTENSION cl_khr_fp64: enable\n";
} }
else if (::opencl::OpenCLDevice::gpuEnv.mnAmdFp64Flag) else if (::opencl::gpuEnv.mnAmdFp64Flag)
{ {
decl << "#pragma OPENCL EXTENSION cl_amd_fp64: enable\n"; decl << "#pragma OPENCL EXTENSION cl_amd_fp64: enable\n";
} }
...@@ -3355,7 +3355,7 @@ public: ...@@ -3355,7 +3355,7 @@ public:
{ {
// Obtain cl context // Obtain cl context
KernelEnv kEnv; KernelEnv kEnv;
::opencl::OpenCLDevice::setKernelEnv(&kEnv); ::opencl::setKernelEnv(&kEnv);
cl_int err; cl_int err;
// The results // The results
mpResClmem = clCreateBuffer(kEnv.mpkContext, mpResClmem = clCreateBuffer(kEnv.mpkContext,
...@@ -3417,7 +3417,7 @@ void DynamicKernel::CreateKernel() ...@@ -3417,7 +3417,7 @@ void DynamicKernel::CreateKernel()
// Compile kernel here!!! // Compile kernel here!!!
// Obtain cl context // Obtain cl context
KernelEnv kEnv; KernelEnv kEnv;
::opencl::OpenCLDevice::setKernelEnv(&kEnv); ::opencl::setKernelEnv(&kEnv);
const char* src = mFullProgramSrc.c_str(); const char* src = mFullProgramSrc.c_str();
static std::string lastOneKernelHash = ""; static std::string lastOneKernelHash = "";
static std::string lastSecondKernelHash = ""; static std::string lastSecondKernelHash = "";
...@@ -3439,11 +3439,11 @@ void DynamicKernel::CreateKernel() ...@@ -3439,11 +3439,11 @@ void DynamicKernel::CreateKernel()
{ {
clReleaseProgram(lastSecondProgram); clReleaseProgram(lastSecondProgram);
} }
if (::opencl::OpenCLDevice::buildProgramFromBinary("", if (::opencl::buildProgramFromBinary("",
&::opencl::OpenCLDevice::gpuEnv, KernelHash.c_str(), 0)) &::opencl::gpuEnv, KernelHash.c_str(), 0))
{ {
mpProgram = ::opencl::OpenCLDevice::gpuEnv.mpArryPrograms[0]; mpProgram = ::opencl::gpuEnv.mpArryPrograms[0];
::opencl::OpenCLDevice::gpuEnv.mpArryPrograms[0] = NULL; ::opencl::gpuEnv.mpArryPrograms[0] = NULL;
} }
else else
{ {
...@@ -3452,7 +3452,7 @@ void DynamicKernel::CreateKernel() ...@@ -3452,7 +3452,7 @@ void DynamicKernel::CreateKernel()
if (err != CL_SUCCESS) if (err != CL_SUCCESS)
throw OpenCLError(err, __FILE__, __LINE__); throw OpenCLError(err, __FILE__, __LINE__);
err = clBuildProgram(mpProgram, 1, err = clBuildProgram(mpProgram, 1,
::opencl::OpenCLDevice::gpuEnv.mpArryDevsID, "", NULL, NULL); ::opencl::gpuEnv.mpArryDevsID, "", NULL, NULL);
if (err != CL_SUCCESS) if (err != CL_SUCCESS)
{ {
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
...@@ -3460,7 +3460,7 @@ void DynamicKernel::CreateKernel() ...@@ -3460,7 +3460,7 @@ void DynamicKernel::CreateKernel()
{ {
cl_build_status stat; cl_build_status stat;
cl_int e = clGetProgramBuildInfo( cl_int e = clGetProgramBuildInfo(
mpProgram, ::opencl::OpenCLDevice::gpuEnv.mpArryDevsID[0], mpProgram, ::opencl::gpuEnv.mpArryDevsID[0],
CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status),
&stat, 0); &stat, 0);
SAL_WARN_IF( SAL_WARN_IF(
...@@ -3472,7 +3472,7 @@ void DynamicKernel::CreateKernel() ...@@ -3472,7 +3472,7 @@ void DynamicKernel::CreateKernel()
{ {
size_t n; size_t n;
e = clGetProgramBuildInfo( e = clGetProgramBuildInfo(
mpProgram, ::opencl::OpenCLDevice::gpuEnv.mpArryDevsID[0], mpProgram, ::opencl::gpuEnv.mpArryDevsID[0],
CL_PROGRAM_BUILD_LOG, 0, 0, &n); CL_PROGRAM_BUILD_LOG, 0, 0, &n);
SAL_WARN_IF( SAL_WARN_IF(
e != CL_SUCCESS || n == 0, "sc.opencl", e != CL_SUCCESS || n == 0, "sc.opencl",
...@@ -3483,7 +3483,7 @@ void DynamicKernel::CreateKernel() ...@@ -3483,7 +3483,7 @@ void DynamicKernel::CreateKernel()
{ {
std::vector<char> log(n); std::vector<char> log(n);
e = clGetProgramBuildInfo( e = clGetProgramBuildInfo(
mpProgram, ::opencl::OpenCLDevice::gpuEnv.mpArryDevsID[0], mpProgram, ::opencl::gpuEnv.mpArryDevsID[0],
CL_PROGRAM_BUILD_LOG, n, &log[0], 0); CL_PROGRAM_BUILD_LOG, n, &log[0], 0);
SAL_WARN_IF( SAL_WARN_IF(
e != CL_SUCCESS || n == 0, "sc.opencl", e != CL_SUCCESS || n == 0, "sc.opencl",
...@@ -3502,7 +3502,7 @@ void DynamicKernel::CreateKernel() ...@@ -3502,7 +3502,7 @@ void DynamicKernel::CreateKernel()
throw OpenCLError(err, __FILE__, __LINE__); throw OpenCLError(err, __FILE__, __LINE__);
} }
// Generate binary out of compiled kernel. // Generate binary out of compiled kernel.
::opencl::OpenCLDevice::generatBinFromKernelSource(mpProgram, ::opencl::generatBinFromKernelSource(mpProgram,
(mKernelSignature + GetMD5()).c_str()); (mKernelSignature + GetMD5()).c_str());
} }
lastSecondKernelHash = lastOneKernelHash; lastSecondKernelHash = lastOneKernelHash;
...@@ -3668,7 +3668,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, ...@@ -3668,7 +3668,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
{ {
// Obtain cl context // Obtain cl context
KernelEnv kEnv; KernelEnv kEnv;
::opencl::OpenCLDevice::setKernelEnv(&kEnv); ::opencl::setKernelEnv(&kEnv);
// Run the kernel. // Run the kernel.
pKernel->Launch(xGroup->mnLength); pKernel->Launch(xGroup->mnLength);
// Map results back // Map results back
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment