officecfg/registry/schema/org/openoffice/Office/Calc.xcs | 8 +- sc/inc/calcconfig.hxx | 16 +--- sc/source/core/opencl/openclwrapper.cxx | 51 +++++++++------ sc/source/core/tool/calcconfig.cxx | 12 +-- sc/source/core/tool/formulaopt.cxx | 6 - sc/source/ui/optdlg/calcoptionsdlg.cxx | 25 ++----- sc/source/ui/optdlg/calcoptionsdlg.hxx | 3 sc/uiconfig/scalc/ui/formulacalculationoptions.ui | 31 +-------- 8 files changed, 62 insertions(+), 90 deletions(-)
New commits: commit 92c5e9b2812571329a758d54b15273f5fc68f95c Author: Tor Lillqvist <t...@collabora.com> Date: Thu Nov 20 14:55:37 2014 +0200 Use regexps in the OpenCL blacklist/whitelist Drop version number bounds, use regexps instead. Not entirely ideal, but as vendors are free to put arbitrary stuff into the driver version string (part of which might be numbers, part free text, part significant, part just informative), just comparing against lower and upper bounds with strverscmp() was not ideal either. Change-Id: Ic4ef4d8e15f79f1c96e6e03f6c01e62ae92dc2fc diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs index aa44d84..c7aac17 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs @@ -1392,16 +1392,16 @@ <prop oor:name="OpenCLBlackList" oor:type="oor:string-list" oor:nillable="false"> <!-- UIHints: Tools - Options Spreadsheet Formula --> <info> - <desc>Combinations of (OS, OS version, OpenCL platform vendor, OpenCL device name, OpenCL driver version) that are known to be bad. Each entry is a string consisting of six parts separated by slashes. In case a slash, percent or semicolon occurs inside a part, it is replaced by a percent followed by the corresponding number as two hex digits. Any part might contain a single asterisk as a wildcard, matching any value, but there is no more generic regexp support. Has higher priority than OpenCLWhiteList.</desc> + <desc>Combinations of (OS, OS version, OpenCL platform vendor, OpenCL device name, OpenCL driver version) that are known to be bad. Each entry is a string consisting of five parts separated by slashes. An empty part matches anything. In case a slash, percent or semicolon occurs inside a part, it is replaced by a percent followed by the corresponding number as two hex digits. The parts except OS can contain regular expressions. Inside these regular expressions the usual characters .*()[]\ are special and should be quoted with a backslash to be interpreted literally. OS should be just one of "Linux", "OS X" (including the space) or "Windows" (without quotes). Has higher priority than OpenCLWhiteList.</desc> </info> - <value oor:separator=";">Windows/*/Intel(R) Corporation/*/9.17.10.2884/</value> + <value oor:separator=";">Windows//Intel\(R\) Corporation//9\.17\.10\.2884</value> </prop> <prop oor:name="OpenCLWhiteList" oor:type="oor:string-list" oor:nillable="false"> <!-- UIHints: Tools - Options Spreadsheet Formula --> <info> - <desc>Like OpenCLWhiteList, but for combinations known to be good.</desc> + <desc>Like OpenCLBlackList, but for combinations known to be good.</desc> </info> - <value oor:separator=";">Linux/*/Advanced Micro Devices, Inc./*/1445.5 (sse2,avx)/;*/*/Advanced Micro Devices, Inc./*/*/;*/*/Intel(R) Corporation/*/*/;*/*/NVIDIA Corporation/*/*/</value> + <value oor:separator=";">Linux//Advanced Micro Devices, Inc\.//1445\.5 \(sse2,avx\);//Advanced Micro Devices, Inc\.//;//Intel\(R\) Corporation//;//NVIDIA Corporation//</value> </prop> </group> <group oor:name="Syntax"> diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx index 40a33b6..2b93fa3 100644 --- a/sc/inc/calcconfig.hxx +++ b/sc/inc/calcconfig.hxx @@ -47,8 +47,7 @@ struct SC_DLLPUBLIC ScCalcConfig OUString maOSVersion; OUString maPlatformVendor; OUString maDevice; - OUString maDriverVersionMin; - OUString maDriverVersionMax; + OUString maDriverVersion; OpenCLImplMatcher() { @@ -58,14 +57,12 @@ struct SC_DLLPUBLIC ScCalcConfig const OUString& rOSVersion, const OUString& rPlatformVendor, const OUString& rDevice, - const OUString& rDriverVersionMin, - const OUString& rDriverVersionMax) + const OUString& rDriverVersion) : maOS(rOS), maOSVersion(rOSVersion), maPlatformVendor(rPlatformVendor), maDevice(rDevice), - maDriverVersionMin(rDriverVersionMin), - maDriverVersionMax(rDriverVersionMax) + maDriverVersion(rDriverVersion) { } @@ -75,8 +72,7 @@ struct SC_DLLPUBLIC ScCalcConfig maOSVersion == r.maOSVersion && maPlatformVendor == r.maPlatformVendor && maDevice == r.maDevice && - maDriverVersionMin == r.maDriverVersionMin && - maDriverVersionMax == r.maDriverVersionMax; + maDriverVersion == r.maDriverVersion; } bool operator!=(const OpenCLImplMatcher& r) const { @@ -92,9 +88,7 @@ struct SC_DLLPUBLIC ScCalcConfig (maPlatformVendor == r.maPlatformVendor && (maDevice < r.maDevice || (maDevice == r.maDevice && - (maDriverVersionMin < r.maDriverVersionMin || - (maDriverVersionMin == r.maDriverVersionMin && - maDriverVersionMax < r.maDriverVersionMax)))))))))); + (maDriverVersion < r.maDriverVersion))))))))); } }; diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx index 87cc1c5..1e4bb7a 100644 --- a/sc/source/core/opencl/openclwrapper.cxx +++ b/sc/source/core/opencl/openclwrapper.cxx @@ -9,24 +9,26 @@ #include <config_folders.h> +#include "calcconfig.hxx" +#include "interpre.hxx" +#include "opencl_device.hxx" #include "openclwrapper.hxx" #include <comphelper/string.hxx> -#include <rtl/ustring.hxx> -#include <rtl/strbuf.hxx> -#include <rtl/digest.h> +#include <osl/file.hxx> #include <rtl/bootstrap.hxx> -#include <boost/scoped_array.hpp> - +#include <rtl/digest.h> +#include <rtl/strbuf.hxx> +#include <rtl/ustring.hxx> #include <sal/config.h> -#include <osl/file.hxx> -#include "calcconfig.hxx" -#include "interpre.hxx" -#include "opencl_device.hxx" + +#include <boost/scoped_array.hpp> +#include <unicode/regex.h> #include <stdio.h> #include <stdlib.h> #include <string.h> + #include <cmath> #ifdef _WIN32 @@ -517,31 +519,44 @@ bool OpenCLDevice::initOpenCLRunEnv( GPUEnv *gpuInfo ) namespace { +bool match(const OUString& rPattern, const OUString& rInput) +{ + if (rPattern == "") + return true; + + UErrorCode nIcuError(U_ZERO_ERROR); + icu::UnicodeString sIcuPattern(reinterpret_cast<const UChar*>(rPattern.getStr()), rPattern.getLength()); + icu::UnicodeString sIcuInput(reinterpret_cast<const UChar*>(rInput.getStr()), rInput.getLength()); + RegexMatcher aMatcher(sIcuPattern, sIcuInput, 0, nIcuError); + + if (nIcuError == U_ZERO_ERROR && aMatcher.matches(nIcuError) && nIcuError == U_ZERO_ERROR) + return true; + + return false; +} + bool match(const ScCalcConfig::OpenCLImplMatcher& rListEntry, const OpenCLPlatformInfo& rPlatform, const OpenCLDeviceInfo& rDevice) { #if defined WNT - if (rListEntry.maOS != "*" && rListEntry.maOS != "Windows") + if (rListEntry.maOS != "" && rListEntry.maOS != "Windows") return false; #elif defined LINUX - if (rListEntry.maOS != "*" && rListEntry.maOS != "Linux") + if (rListEntry.maOS != "" && rListEntry.maOS != "Linux") return false; #elif defined MACOSX - if (rListEntry.maOS != "*" && rListEntry.maOS != "OS X") + if (rListEntry.maOS != "" && rListEntry.maOS != "OS X") return false; #endif // OS version check not yet implemented - if (rListEntry.maPlatformVendor != "*" && rListEntry.maPlatformVendor != rPlatform.maVendor) + if (!match(rListEntry.maPlatformVendor, rPlatform.maVendor)) return false; - if (rListEntry.maDevice != "*" && rListEntry.maDevice != rDevice.maName) + if (!match(rListEntry.maDevice, rDevice.maName)) return false; - 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))) + if (!match(rListEntry.maDriverVersion, rDevice.maDriver)) return false; return true; diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx index 69abb2d..7c9ace9 100644 --- a/sc/source/core/tool/calcconfig.cxx +++ b/sc/source/core/tool/calcconfig.cxx @@ -69,15 +69,15 @@ void ScCalcConfig::setOpenCLConfigToDefault() // This entry we have had for some time (when blacklisting was // done elsewhere in the code), so presumably there is a known // good reason for it. - maOpenCLBlackList.insert(OpenCLImplMatcher("Windows", "*", "Intel(R) Corporation", "*", "9.17.10.2884", "")); + maOpenCLBlackList.insert(OpenCLImplMatcher("Windows", "", "Intel\\(R\\) Corporation", "", "9\\.17\\.10\\.2884")); // This is what I have tested on Linux and it works for our unit tests. - maOpenCLWhiteList.insert(OpenCLImplMatcher("Linux", "*", "Advanced Micro Devices, Inc.", "*", "1445.5 (sse2,avx)", "")); + maOpenCLWhiteList.insert(OpenCLImplMatcher("Linux", "", "Advanced Micro Devices, Inc\\.", "", "1445\\.5 \\(sse2,avx\\)")); // For now, assume that AMD, Intel and NVIDIA drivers are good - maOpenCLWhiteList.insert(OpenCLImplMatcher("*", "*", "Advanced Micro Devices, Inc.", "*", "*", "")); - maOpenCLWhiteList.insert(OpenCLImplMatcher("*", "*", "Intel(R) Corporation", "*", "*", "")); - maOpenCLWhiteList.insert(OpenCLImplMatcher("*", "*", "NVIDIA Corporation", "*", "*", "")); + maOpenCLWhiteList.insert(OpenCLImplMatcher("", "", "Advanced Micro Devices, Inc\\.", "", "")); + maOpenCLWhiteList.insert(OpenCLImplMatcher("", "", "Intel\\(R\\) Corporation", "", "")); + maOpenCLWhiteList.insert(OpenCLImplMatcher("", "", "NVIDIA Corporation", "", "")); } void ScCalcConfig::reset() @@ -122,7 +122,7 @@ std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig::OpenCLImplMa "OSVersion=" << rImpl.maOSVersion << "," "PlatformVendor=" << rImpl.maPlatformVendor << "," "Device=" << rImpl.maDevice << "," - "DriverVersion=[" << rImpl.maDriverVersionMin << "," << rImpl.maDriverVersionMax << "]" + "DriverVersion=" << rImpl.maDriverVersion << "}"; return rStream; diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx index c5ff895..9f05a01 100644 --- a/sc/source/core/tool/formulaopt.cxx +++ b/sc/source/core/tool/formulaopt.cxx @@ -293,8 +293,7 @@ css::uno::Sequence<OUString> SetOfOpenCLImplMatcherToStringSequence(std::set<ScC (*i).maOSVersion.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B") + "/" + (*i).maPlatformVendor.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B") + "/" + (*i).maDevice.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B") + "/" + - (*i).maDriverVersionMin.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B") + "/" + - (*i).maDriverVersionMax.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B"); + (*i).maDriverVersion.replaceAll("%", "%25").replaceAll("/", "%2F").replaceAll(";", "%3B"); } return result; @@ -337,8 +336,7 @@ std::set<ScCalcConfig::OpenCLImplMatcher> StringSequenceToSetOfOpenCLImplMatcher m.maOSVersion = getToken(*i, index); m.maPlatformVendor = getToken(*i, index); m.maDevice = getToken(*i, index); - m.maDriverVersionMin = getToken(*i, index); - m.maDriverVersionMax = getToken(*i, index); + m.maDriverVersion = getToken(*i, index); result.insert(m); } diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx index 046fd7f..acf9318 100644 --- a/sc/source/ui/optdlg/calcoptionsdlg.cxx +++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx @@ -160,8 +160,7 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(vcl::Window* pParent, const ScCalcConfi get(mpOSVersion, "osversion"); get(mpPlatformVendor, "platformvendor"); get(mpDevice, "opencldevice"); - get(mpDriverVersionMin, "opencldriverversionmin"); - get(mpDriverVersionMax, "opencldriverversionmax"); + get(mpDriverVersion, "opencldriverversion"); get(mpListNewButton, "listbox-new"); get(mpListDeleteButton, "listbox-delete"); get(mpTestButton, "test"); @@ -178,8 +177,7 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(vcl::Window* pParent, const ScCalcConfi mpOSVersion->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl)); mpPlatformVendor->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl)); mpDevice->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl)); - mpDriverVersionMin->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl)); - mpDriverVersionMax->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl)); + mpDriverVersion->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl)); mpOpenCLWhiteAndBlackListBox->set_height_request(4* mpOpenCLWhiteAndBlackListBox->GetTextHeight()); mpOpenCLWhiteAndBlackListBox->SetStyle(mpOpenCLWhiteAndBlackListBox->GetStyle() | WB_CLIPCHILDREN | WB_FORCE_MAKEVISIBLE); @@ -332,10 +330,7 @@ OUString format(const ScCalcConfig::OpenCLImplMatcher& rImpl) rImpl.maOSVersion + " " + rImpl.maPlatformVendor + " " + rImpl.maDevice + " " + - (rImpl.maDriverVersionMax != "" ? - OUString("[") + rImpl.maDriverVersionMin + "," + rImpl.maDriverVersionMax + "]" : - rImpl.maDriverVersionMin) - ); + rImpl.maDriverVersion); } void fillListBox(ListBox* pListBox, const ScCalcConfig::OpenCLImplMatcherSet& rSet) @@ -809,13 +804,9 @@ void ScCalcOptionsDialog::EditFieldValueChanged(Control *pCtrl) { newImpl.maDevice = sVal; } - else if (&rEdit == mpDriverVersionMin) + else if (&rEdit == mpDriverVersion) { - newImpl.maDriverVersionMin = sVal; - } - else if (&rEdit == mpDriverVersionMax) - { - newImpl.maDriverVersionMax = sVal; + newImpl.maDriverVersion = sVal; } else assert(false && "rEdit does not match any of the Edit fields"); @@ -924,8 +915,7 @@ IMPL_LINK(ScCalcOptionsDialog, OpenCLWhiteAndBlackListSelHdl, Control*, ) mpOSVersion->SetText(impl.maOSVersion); mpPlatformVendor->SetText(impl.maPlatformVendor); mpDevice->SetText(impl.maDevice); - mpDriverVersionMin->SetText(impl.maDriverVersionMin); - mpDriverVersionMax->SetText(impl.maDriverVersionMax); + mpDriverVersion->SetText(impl.maDriverVersion); return 0; } @@ -939,8 +929,7 @@ IMPL_LINK( ScCalcOptionsDialog, ListNewClickHdl, PushButton*, ) mpOSVersion->SetText(""); mpPlatformVendor->SetText(""); mpDevice->SetText(""); - mpDriverVersionMin->SetText(""); - mpDriverVersionMax->SetText(""); + mpDriverVersion->SetText(""); rSet.insert(aEmpty); #if HAVE_FEATURE_OPENCL diff --git a/sc/source/ui/optdlg/calcoptionsdlg.hxx b/sc/source/ui/optdlg/calcoptionsdlg.hxx index e1a1370..705873c 100644 --- a/sc/source/ui/optdlg/calcoptionsdlg.hxx +++ b/sc/source/ui/optdlg/calcoptionsdlg.hxx @@ -83,8 +83,7 @@ private: Edit* mpOSVersion; Edit* mpPlatformVendor; Edit* mpDevice; - Edit* mpDriverVersionMin; - Edit* mpDriverVersionMax; + Edit* mpDriverVersion; PushButton* mpListNewButton; PushButton* mpListDeleteButton; PushButton* mpTestButton; diff --git a/sc/uiconfig/scalc/ui/formulacalculationoptions.ui b/sc/uiconfig/scalc/ui/formulacalculationoptions.ui index 5d359eb..a157f8d 100644 --- a/sc/uiconfig/scalc/ui/formulacalculationoptions.ui +++ b/sc/uiconfig/scalc/ui/formulacalculationoptions.ui @@ -302,12 +302,12 @@ </packing> </child> <child> - <object class="GtkLabel" id="opencldriverversionminlabel"> + <object class="GtkLabel" id="opencldriverversionlabel"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="xalign">0</property> - <property name="label" translatable="yes">OpenCL Driver Version Lower Bound</property> - <property name="mnemonic_widget">opencldriverversionmin:border</property> + <property name="label" translatable="yes">OpenCL Driver Version</property> + <property name="mnemonic_widget">opencldriverversion:border</property> </object> <packing> <property name="left_attach">0</property> @@ -315,7 +315,7 @@ </packing> </child> <child> - <object class="GtkEntry" id="opencldriverversionmin:border"> + <object class="GtkEntry" id="opencldriverversion:border"> <property name="visible">True</property> <property name="can_focus">True</property> </object> @@ -324,29 +324,6 @@ <property name="top_attach">9</property> </packing> </child> - <child> - <object class="GtkLabel" id="opencldriverversionmaxlabel"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">OpenCL Driver Version Upper Bound</property> - <property name="mnemonic_widget">opencldriverversionmax:border</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">10</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="opencldriverversionmax:border"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">11</property> - </packing> - </child> </object> <packing> <property name="left_attach">1</property> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits