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

Get rid of need to use initial :: for ::opencl to avoid clash with sc::opencl

Rename the global opencl namespace to openclwrapper. Its public API is
after all declared in a file called openclwrapper.hxx. The confusion
started when part of the OpenCL code was moved out from sc some years
ago.

Change-Id: I98ebd8498b2244804411e5de9169eb619f86070b
üst 407a126a
...@@ -335,7 +335,7 @@ OUString AboutDialog::GetVersionString() ...@@ -335,7 +335,7 @@ OUString AboutDialog::GetVersionString()
#if HAVE_FEATURE_OPENCL #if HAVE_FEATURE_OPENCL
OUString aCalcMode = "Calc: "; // Calc calculation mode OUString aCalcMode = "Calc: "; // Calc calculation mode
bool bSWInterp = officecfg::Office::Common::Misc::UseSwInterpreter::get(); bool bSWInterp = officecfg::Office::Common::Misc::UseSwInterpreter::get();
bool bOpenCL = opencl::GPUEnv::isOpenCLEnabled(); bool bOpenCL = openclwrapper::GPUEnv::isOpenCLEnabled();
if (bOpenCL) if (bOpenCL)
aCalcMode += "CL"; aCalcMode += "CL";
else if (bSWInterp) else if (bSWInterp)
......
...@@ -54,7 +54,7 @@ SvxOpenCLTabPage::SvxOpenCLTabPage(vcl::Window* pParent, const SfxItemSet& rSet) ...@@ -54,7 +54,7 @@ SvxOpenCLTabPage::SvxOpenCLTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
mpUseOpenCL->Check(maConfig.mbUseOpenCL); mpUseOpenCL->Check(maConfig.mbUseOpenCL);
mpUseOpenCL->Enable(!officecfg::Office::Common::Misc::UseOpenCL::isReadOnly()); mpUseOpenCL->Enable(!officecfg::Office::Common::Misc::UseOpenCL::isReadOnly());
bool bCLUsed = opencl::GPUEnv::isOpenCLEnabled(); bool bCLUsed = openclwrapper::GPUEnv::isOpenCLEnabled();
mpOclUsed->Show(bCLUsed); mpOclUsed->Show(bCLUsed);
mpOclNotUsed->Show(!bCLUsed); mpOclNotUsed->Show(!bCLUsed);
} }
......
...@@ -49,7 +49,7 @@ bool testOpenCLCompute(const Reference< XDesktop2 > &xDesktop, const OUString &r ...@@ -49,7 +49,7 @@ bool testOpenCLCompute(const Reference< XDesktop2 > &xDesktop, const OUString &r
bool bSuccess = false; bool bSuccess = false;
css::uno::Reference< css::lang::XComponent > xComponent; css::uno::Reference< css::lang::XComponent > xComponent;
sal_uInt64 nKernelFailures = opencl::kernelFailures; sal_uInt64 nKernelFailures = openclwrapper::kernelFailures;
SAL_INFO("opencl", "Starting CL test spreadsheet"); SAL_INFO("opencl", "Starting CL test spreadsheet");
...@@ -99,12 +99,12 @@ bool testOpenCLCompute(const Reference< XDesktop2 > &xDesktop, const OUString &r ...@@ -99,12 +99,12 @@ bool testOpenCLCompute(const Reference< XDesktop2 > &xDesktop, const OUString &r
SAL_WARN("opencl", "OpenCL testing failed - disabling: " << e.Message); SAL_WARN("opencl", "OpenCL testing failed - disabling: " << e.Message);
} }
if (nKernelFailures != opencl::kernelFailures) if (nKernelFailures != openclwrapper::kernelFailures)
{ {
// tdf#100883 - defeat SEH exception handling fallbacks. // tdf#100883 - defeat SEH exception handling fallbacks.
SAL_WARN("opencl", "OpenCL kernels failed to compile, " SAL_WARN("opencl", "OpenCL kernels failed to compile, "
"or took SEH exceptions " "or took SEH exceptions "
<< nKernelFailures << " != " << opencl::kernelFailures); << nKernelFailures << " != " << openclwrapper::kernelFailures);
bSuccess = false; bSuccess = false;
} }
...@@ -119,7 +119,7 @@ bool testOpenCLCompute(const Reference< XDesktop2 > &xDesktop, const OUString &r ...@@ -119,7 +119,7 @@ bool testOpenCLCompute(const Reference< XDesktop2 > &xDesktop, const OUString &r
void Desktop::CheckOpenCLCompute(const Reference< XDesktop2 > &xDesktop) void Desktop::CheckOpenCLCompute(const Reference< XDesktop2 > &xDesktop)
{ {
if (!opencl::canUseOpenCL() || Application::IsSafeModeEnabled()) if (!openclwrapper::canUseOpenCL() || Application::IsSafeModeEnabled())
return; return;
SAL_INFO("opencl", "Initiating test of OpenCL device"); SAL_INFO("opencl", "Initiating test of OpenCL device");
...@@ -128,7 +128,7 @@ void Desktop::CheckOpenCLCompute(const Reference< XDesktop2 > &xDesktop) ...@@ -128,7 +128,7 @@ void Desktop::CheckOpenCLCompute(const Reference< XDesktop2 > &xDesktop)
OUString aDevice = officecfg::Office::Calc::Formula::Calculation::OpenCLDevice::get(); OUString aDevice = officecfg::Office::Calc::Formula::Calculation::OpenCLDevice::get();
OUString aSelectedCLDeviceVersionID; OUString aSelectedCLDeviceVersionID;
if (!opencl::switchOpenCLDevice( if (!openclwrapper::switchOpenCLDevice(
&aDevice, &aDevice,
officecfg::Office::Calc::Formula::Calculation::OpenCLAutoSelect::get(), officecfg::Office::Calc::Formula::Calculation::OpenCLAutoSelect::get(),
false /* bForceEvaluation */, false /* bForceEvaluation */,
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <cstdio> #include <cstdio>
namespace opencl namespace openclwrapper
{ {
struct KernelEnv struct KernelEnv
......
...@@ -10,16 +10,13 @@ ...@@ -10,16 +10,13 @@
#ifndef INCLUDED_OPENCL_INC_OPENCL_DEVICE_HXX #ifndef INCLUDED_OPENCL_INC_OPENCL_DEVICE_HXX
#define INCLUDED_OPENCL_INC_OPENCL_DEVICE_HXX #define INCLUDED_OPENCL_INC_OPENCL_DEVICE_HXX
#include "opencl_device_selection.h" #include <opencl/openclwrapper.hxx>
namespace opencl { #include "opencl_device_selection.h"
ds_device const & getDeviceSelection(OUString const & pFileName, bool bForceSelection); ds_device const & getDeviceSelection(OUString const & pFileName, bool bForceSelection);
struct GPUEnv; void releaseOpenCLEnv( openclwrapper::GPUEnv *gpuInfo );
void releaseOpenCLEnv( GPUEnv *gpuInfo );
}
#endif #endif
......
...@@ -44,7 +44,7 @@ void OpenCLZone::hardDisable() ...@@ -44,7 +44,7 @@ void OpenCLZone::hardDisable()
css::uno::Reference<css::util::XFlushable> xFlushable(xConfProvider, css::uno::UNO_QUERY_THROW); css::uno::Reference<css::util::XFlushable> xFlushable(xConfProvider, css::uno::UNO_QUERY_THROW);
xFlushable->flush(); xFlushable->flush();
releaseOpenCLEnv(&opencl::gpuEnv); releaseOpenCLEnv(&openclwrapper::gpuEnv);
} }
} }
......
...@@ -40,8 +40,6 @@ ...@@ -40,8 +40,6 @@
#define STRINGIFY(...) #__VA_ARGS__"\n" #define STRINGIFY(...) #__VA_ARGS__"\n"
namespace opencl {
namespace { namespace {
void DS_CHECK_STATUS(cl_int status, char const * name) { void DS_CHECK_STATUS(cl_int status, char const * name) {
...@@ -671,6 +669,4 @@ ds_device const & getDeviceSelection( ...@@ -671,6 +669,4 @@ ds_device const & getDeviceSelection(
return selectedDevice; return selectedDevice;
} }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -61,7 +61,13 @@ if( status != CL_SUCCESS ) \ ...@@ -61,7 +61,13 @@ if( status != CL_SUCCESS ) \
using namespace std; using namespace std;
namespace opencl { namespace {
bool bIsInited = false;
}
namespace openclwrapper {
GPUEnv gpuEnv; GPUEnv gpuEnv;
sal_uInt64 kernelFailures = 0; sal_uInt64 kernelFailures = 0;
...@@ -69,8 +75,6 @@ sal_uInt64 kernelFailures = 0; ...@@ -69,8 +75,6 @@ sal_uInt64 kernelFailures = 0;
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];
...@@ -320,38 +324,6 @@ bool initOpenCLAttr( OpenCLEnv * env ) ...@@ -320,38 +324,6 @@ bool initOpenCLAttr( OpenCLEnv * env )
return false; return false;
} }
}
void releaseOpenCLEnv( GPUEnv *gpuInfo )
{
OpenCLZone zone;
if ( !bIsInited )
{
return;
}
for (_cl_command_queue* & i : gpuEnv.mpCmdQueue)
{
if (i)
{
clReleaseCommandQueue(i);
i = nullptr;
}
}
gpuEnv.mnCmdQueuePos = 0;
if ( gpuEnv.mpContext )
{
clReleaseContext( gpuEnv.mpContext );
gpuEnv.mpContext = nullptr;
}
bIsInited = false;
gpuInfo->mnIsUserCreated = 0;
}
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;
...@@ -958,4 +930,32 @@ bool GPUEnv::isOpenCLEnabled() ...@@ -958,4 +930,32 @@ bool GPUEnv::isOpenCLEnabled()
} }
void releaseOpenCLEnv( openclwrapper::GPUEnv *gpuInfo )
{
OpenCLZone zone;
if ( !bIsInited )
{
return;
}
for (_cl_command_queue* & i : openclwrapper::gpuEnv.mpCmdQueue)
{
if (i)
{
clReleaseCommandQueue(i);
i = nullptr;
}
}
openclwrapper::gpuEnv.mnCmdQueuePos = 0;
if ( openclwrapper::gpuEnv.mpContext )
{
clReleaseContext( openclwrapper::gpuEnv.mpContext );
openclwrapper::gpuEnv.mpContext = nullptr;
}
bIsInited = false;
gpuInfo->mnIsUserCreated = 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -26,7 +26,7 @@ OpenCLError::OpenCLError( const std::string& function, cl_int error, const std:: ...@@ -26,7 +26,7 @@ OpenCLError::OpenCLError( const std::string& function, cl_int error, const std::
// CLInterpreterContext::launchKernel() where OpenCLError is // CLInterpreterContext::launchKernel() where OpenCLError is
// caught already uses SAL_WARN() to display it. // caught already uses SAL_WARN() to display it.
// SAL_INFO("sc.opencl", "OpenCL error: " << ::opencl::errorString(mError)); // SAL_INFO("sc.opencl", "OpenCL error: " << openclwrapper::errorString(mError));
} }
Unhandled::Unhandled( const std::string& fn, int ln ) : Unhandled::Unhandled( const std::string& fn, int ln ) :
...@@ -109,7 +109,7 @@ VectorRef::~VectorRef() ...@@ -109,7 +109,7 @@ VectorRef::~VectorRef()
{ {
cl_int err; cl_int err;
err = clReleaseMemObject(mpClmem); err = clReleaseMemObject(mpClmem);
SAL_WARN_IF(err != CL_SUCCESS, "sc.opencl", "clReleaseMemObject failed: " << ::opencl::errorString(err)); SAL_WARN_IF(err != CL_SUCCESS, "sc.opencl", "clReleaseMemObject failed: " << openclwrapper::errorString(err));
} }
} }
......
...@@ -297,7 +297,7 @@ FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic() ...@@ -297,7 +297,7 @@ FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic()
void FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rPlatforms) void FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rPlatforms)
{ {
const std::vector<OpenCLPlatformInfo>& rPlatformsFromWrapper = const std::vector<OpenCLPlatformInfo>& rPlatformsFromWrapper =
::opencl::fillOpenCLInfo(); openclwrapper::fillOpenCLInfo();
rPlatforms.assign(rPlatformsFromWrapper.begin(), rPlatformsFromWrapper.end()); rPlatforms.assign(rPlatformsFromWrapper.begin(), rPlatformsFromWrapper.end());
} }
...@@ -328,7 +328,7 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool ...@@ -328,7 +328,7 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool
} }
OUString aSelectedCLDeviceVersionID; OUString aSelectedCLDeviceVersionID;
bool bSuccess = ::opencl::switchOpenCLDevice(&rDeviceId, bAutoSelect, bForceEvaluation, aSelectedCLDeviceVersionID); bool bSuccess = openclwrapper::switchOpenCLDevice(&rDeviceId, bAutoSelect, bForceEvaluation, aSelectedCLDeviceVersionID);
if (!bSuccess) if (!bSuccess)
return false; return false;
...@@ -350,7 +350,7 @@ void FormulaGroupInterpreter::getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int3 ...@@ -350,7 +350,7 @@ void FormulaGroupInterpreter::getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int3
size_t aDeviceId = static_cast<size_t>(-1); size_t aDeviceId = static_cast<size_t>(-1);
size_t aPlatformId = static_cast<size_t>(-1); size_t aPlatformId = static_cast<size_t>(-1);
::opencl::getOpenCLDeviceInfo(aDeviceId, aPlatformId); openclwrapper::getOpenCLDeviceInfo(aDeviceId, aPlatformId);
rDeviceId = aDeviceId; rDeviceId = aDeviceId;
rPlatformId = aPlatformId; rPlatformId = aPlatformId;
} }
......
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