diff options
author | Tor Lillqvist <tml@collabora.com> | 2014-11-12 20:45:07 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2014-11-12 21:50:02 +0200 |
commit | d12efada389643ab0e13a280246d14caed273029 (patch) | |
tree | 35b004103c39da780d9ad8cb513a3641fb392858 /sc/source | |
parent | af8a6797918fa9f6450dae856f519257da00be3c (diff) |
Refactor and fix checkForKnownBadCompilers()
Change-Id: Ib2ee1a726fd54c34728234bc1a6b25a05b4e98b5
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/opencl/openclwrapper.cxx | 105 |
1 files changed, 45 insertions, 60 deletions
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx index f91e062451de..1db26ec43a0a 100644 --- a/sc/source/core/opencl/openclwrapper.cxx +++ b/sc/source/core/opencl/openclwrapper.cxx @@ -517,81 +517,66 @@ bool OpenCLDevice::initOpenCLRunEnv( GPUEnv *gpuInfo ) namespace { -// based on crashes and hanging during kernel compilation -bool checkForKnownBadCompilers(const OpenCLPlatformInfo& rPlatform, const OpenCLDeviceInfo& rDevice) +bool match(const ScCalcConfig::OpenCLImplMatcher& rListEntry, const OpenCLPlatformInfo& rPlatform, const OpenCLDeviceInfo& rDevice) { - // Check blacklist of known bad OpenCL implementations - - for (auto i = ScInterpreter::GetGlobalConfig().maOpenCLBlackList.cbegin(); - i != ScInterpreter::GetGlobalConfig().maOpenCLBlackList.end(); - ++i) - { - SAL_INFO("sc.opencl", "Looking for match for platform=" << rPlatform << ", device=" << rDevice << " in blacklist entry=" << *i); - #if defined WNT - if (i->maOS != "*" && i->maOS != "Windows") - continue; + if (rListEntry.maOS != "*" && rListEntry.maOS != "Windows") + return false; #elif defined LINUX - if (i->maOS != "*" && i->maOS != "Linux") - continue; + if (rListEntry.maOS != "*" && rListEntry.maOS != "Linux") + return false; #elif defined MACOSX - if (i->maOS != "*" && i->maOS != "OS X") - continue; + if (rListEntry.maOS != "*" && rListEntry.maOS != "OS X") + return false; #endif - // OS version check not yet implemented - - if (i->maPlatformVendor != "*" && i->maPlatformVendor != rDevice.maVendor) - continue; + // OS version check not yet implemented - if (i->maDevice != "*" && i->maDevice != rDevice.maName) - continue; + if (rListEntry.maPlatformVendor != "*" && rListEntry.maPlatformVendor != rPlatform.maVendor) + return false; - 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; + if (rListEntry.maDevice != "*" && rListEntry.maDevice != rDevice.maName) + return false; - // It matches; reject it - SAL_INFO("sc.opencl", "Match! Rejecting"); - return true; - } + if (rListEntry.maDriverVersionMin != "*" && + (comphelper::string::compareVersionStrings(rListEntry.maDriverVersionMin, rDevice.maDriver) > 0 || + (rListEntry.maDriverVersionMax != "" && comphelper::string::compareVersionStrings(rListEntry.maDriverVersionMax, rDevice.maDriver) < 0) || + (rListEntry.maDriverVersionMax == "" && comphelper::string::compareVersionStrings(rListEntry.maDriverVersionMin, rDevice.maDriver) < 0))) + return false; - // Check for whitelist of known good OpenCL implementations + return true; +} - for (auto i = ScInterpreter::GetGlobalConfig().maOpenCLWhiteList.cbegin(); - i != ScInterpreter::GetGlobalConfig().maOpenCLWhiteList.end(); - ++i) +bool match(const ScCalcConfig::OpenCLImplMatcherSet& rList, const OpenCLPlatformInfo& rPlatform, const OpenCLDeviceInfo& rDevice, const char* sKindOfList) +{ + for (auto i = rList.cbegin(); i != rList.end(); ++i) { - SAL_INFO("sc.opencl", "Looking for match for platform=" << rPlatform << ", device=" << rDevice << " in whitelist entry=" << *i); + SAL_INFO("sc.opencl", "Looking for match for platform=" << rPlatform << ", device=" << rDevice << + " in " << sKindOfList << " entry=" << *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 != rPlatform.maVendor) - continue; - - if (i->maDevice != "*" && i->maDevice != rDevice.maName) - continue; + if (match(*i, rPlatform, rDevice)) + { + SAL_INFO("sc.opencl", "Match!"); + return true; + } + } + return false; +} - if (i->maDriverVersionMin != "*" && - (comphelper::string::compareVersionStrings(i->maDriverVersionMin, rDevice.maDriver) > 0 || - comphelper::string::compareVersionStrings(i->maDriverVersionMax, rDevice.maDriver) < 0)) - continue; +// based on crashes and hanging during kernel compilation +bool checkForKnownBadCompilers(const OpenCLPlatformInfo& rPlatform, const OpenCLDeviceInfo& rDevice) +{ + // Check blacklist of known bad OpenCL implementations + if (match(ScInterpreter::GetGlobalConfig().maOpenCLBlackList, rPlatform, rDevice, "blacklist")) + { + SAL_INFO("sc.opencl", "Rejecting"); + return true; + } - // It matches; approve it - SAL_INFO("sc.opencl", "Match! Approving"); + // Check for whitelist of known good OpenCL implementations + if (match(ScInterpreter::GetGlobalConfig().maOpenCLWhiteList, rPlatform, rDevice, "whitelist")) + { + SAL_INFO("sc.opencl", "Approving"); return false; } |