summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2014-11-12 19:03:32 +0200
committerTor Lillqvist <tml@collabora.com>2014-11-12 21:50:02 +0200
commit2057d6c19c1c874f00eadef663d612a0f09fd09f (patch)
tree64eff2248a3d8040f97bcfdff07579272276eaf9
parent6e77fd94bbe764a6e52ce5af7d9c4a8d16fef61a (diff)
Add first whitelist and blacklist check attempt to checkForKnownBadCompilers()
Not sure if that is the right place for it. Change-Id: I246bb6191513f5c1557b9f211915becce0908d24
-rw-r--r--sc/source/core/opencl/openclwrapper.cxx86
1 files changed, 74 insertions, 12 deletions
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index e6a0f7dd8c36..c30737158eea 100644
--- a/sc/source/core/opencl/openclwrapper.cxx
+++ b/sc/source/core/opencl/openclwrapper.cxx
@@ -11,6 +11,7 @@
#include "openclwrapper.hxx"
+#include <comphelper/string.hxx>
#include <rtl/ustring.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/digest.h>
@@ -19,6 +20,8 @@
#include <sal/config.h>
#include <osl/file.hxx>
+#include "calcconfig.hxx"
+#include "interpre.hxx"
#include "opencl_device.hxx"
#include <stdio.h>
@@ -515,23 +518,82 @@ bool OpenCLDevice::initOpenCLRunEnv( GPUEnv *gpuInfo )
namespace {
// based on crashes and hanging during kernel compilation
-bool checkForKnownBadCompilers(const OpenCLDeviceInfo& rInfo)
+bool checkForKnownBadCompilers(const OpenCLPlatformInfo& rPlatform, const OpenCLDeviceInfo& rDevice)
{
+ // Check blacklist of known bad OpenCL implementations
- struct {
- const char* pVendorName; const char* pDriverVersion;
- } aBadOpenCLCompilers[] = {
- { "Intel(R) Corporation", "9.17.10.2884" }
- };
+ for (auto i = ScInterpreter::GetGlobalConfig().maOpenCLBlackList.cbegin();
+ i != ScInterpreter::GetGlobalConfig().maOpenCLBlackList.end();
+ ++i)
+ {
+#if defined WNT
+ if (i->maOS != "*" && i->maOS != "Windows")
+ continue;
+#elif defined LINUX
+ if (i->maOS != "*" && i->maOS != "Linux")
+ continue;
+#elif defined MACOSX
+ if (i->maOS != "*" && i->maOS != "OS X")
+ continue;
+#endif
+
+ // OS version check not yet implemented
+
+ if (i->maPlatformVendor != "*" && i->maPlatformVendor != rDevice.maVendor)
+ continue;
+
+ if (i->maDevice != "*" && i->maDevice != rDevice.maName)
+ continue;
+
+ if (i->maDriverVersionMin != "*" &&
+ (comphelper::string::compareVersionStrings(i->maDriverVersionMin, rDevice.maDriver) > 0 ||
+ (i->maDriverVersionMax != "" && comphelper::string::compareVersionStrings(i->maDriverVersionMax, rDevice.maDriver) < 0) ||
+ (i->maDriverVersionMax == "" && comphelper::string::compareVersionStrings(i->maDriverVersionMin, rDevice.maDriver) < 0)))
+ continue;
+
+ // It matches; reject it
+ SAL_INFO("sc.opencl", "Match for platform=" << rPlatform << ", device=" << rDevice << " in blacklist=" << *i);
+ return true;
+ }
+
+ // Check for whitelist of known good OpenCL implementations
- for(size_t i = 0; i < SAL_N_ELEMENTS(aBadOpenCLCompilers); ++i)
+ for (auto i = ScInterpreter::GetGlobalConfig().maOpenCLWhiteList.cbegin();
+ i != ScInterpreter::GetGlobalConfig().maOpenCLWhiteList.end();
+ ++i)
{
- if(rInfo.maVendor == OUString::createFromAscii(aBadOpenCLCompilers[i].pVendorName) &&
- rInfo.maDriver == OUString::createFromAscii(aBadOpenCLCompilers[i].pDriverVersion))
- return true;
+#if defined WNT
+ if (i->maOS != "*" && i->maOS != "Windows")
+ continue;
+#elif defined LINUX
+ if (i->maOS != "*" && i->maOS != "Linux")
+ continue;
+#elif defined MACOSX
+ if (i->maOS != "*" && i->maOS != "OS X")
+ continue;
+#endif
+
+ // OS version check not yet implemented
+
+ if (i->maPlatformVendor != "*" && i->maPlatformVendor != rPlatform.maVendor)
+ continue;
+
+ if (i->maDevice != "*" && i->maDevice != rDevice.maName)
+ continue;
+
+ if (i->maDriverVersionMin != "*" &&
+ (comphelper::string::compareVersionStrings(i->maDriverVersionMin, rDevice.maDriver) > 0 ||
+ comphelper::string::compareVersionStrings(i->maDriverVersionMax, rDevice.maDriver) < 0))
+ continue;
+
+ // It matches; approve it
+ SAL_INFO("sc.opencl", "Match for platform=" << rPlatform << ", device=" << rDevice << " in whitelist=" << *i);
+ return false;
}
- return false;
+ // Fallback: reject
+ SAL_INFO("sc.opencl", "Fallback: rejecting platform=" << rPlatform << ", device=" << rDevice);
+ return true;
}
void createDeviceInfo(cl_device_id aDeviceId, OpenCLPlatformInfo& rPlatformInfo)
@@ -590,7 +652,7 @@ void createDeviceInfo(cl_device_id aDeviceId, OpenCLPlatformInfo& rPlatformInfo)
aDeviceInfo.mnComputeUnits = nComputeUnits;
- if(!checkForKnownBadCompilers(aDeviceInfo))
+ if(!checkForKnownBadCompilers(rPlatformInfo, aDeviceInfo))
rPlatformInfo.maDevices.push_back(aDeviceInfo);
}