[Libreoffice-commits] core.git: Branch 'feature/calc-pluggable-opencl' - sc/inc sc/source sc/uiconfig

Markus Mohrhard markus.mohrhard at googlemail.com
Fri Sep 13 12:50:44 PDT 2013


 sc/inc/platforminfo.hxx                           |    3 
 sc/source/core/opencl/openclwrapper.cxx           |   21 +++++
 sc/source/ui/optdlg/calcoptionsdlg.cxx            |   38 +++++++--
 sc/source/ui/optdlg/calcoptionsdlg.hxx            |   12 +++
 sc/uiconfig/scalc/ui/formulacalculationoptions.ui |   88 ++++++++++++++++++++++
 5 files changed, 153 insertions(+), 9 deletions(-)

New commits:
commit 4b41e8197841228beaea74222fa1d0c87d6c4c80
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Sep 13 21:28:09 2013 +0200

    show compute units, frequency and memory for opencl devices
    
    Change-Id: Ib322a429a3d29ed985702dc1b5cb9d1cb0a1ac07

diff --git a/sc/inc/platforminfo.hxx b/sc/inc/platforminfo.hxx
index bae6e41..d848525 100644
--- a/sc/inc/platforminfo.hxx
+++ b/sc/inc/platforminfo.hxx
@@ -23,6 +23,9 @@ struct SC_DLLPUBLIC OpenclDeviceInfo
     size_t mnId;
     OUString maName;
     OUString maVendor;
+    size_t mnMemory;
+    size_t mnComputeUnits;
+    size_t mnFrequency;
 };
 
 struct SC_DLLPUBLIC OpenclPlatformInfo
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index a32cf8a..c2c1e45 100644
--- a/sc/source/core/opencl/openclwrapper.cxx
+++ b/sc/source/core/opencl/openclwrapper.cxx
@@ -2654,6 +2654,27 @@ void createDeviceInfo(cl_device_id aDeviceId, OpenclPlatformInfo& rPlatformInfo)
 
     aDeviceInfo.maVendor = OUString::createFromAscii(pVendor);
 
+    cl_ulong nMemSize;
+    nState = clGetDeviceInfo(aDeviceId, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(nMemSize), &nMemSize, NULL);
+    if(nState != CL_SUCCESS)
+        return;
+
+    aDeviceInfo.mnMemory = nMemSize;
+
+    cl_uint nClockFrequency;
+    nState = clGetDeviceInfo(aDeviceId, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(nClockFrequency), &nClockFrequency, NULL);
+    if(nState != CL_SUCCESS)
+        return;
+
+    aDeviceInfo.mnFrequency = nClockFrequency;
+
+    cl_uint nComputeUnits;
+    nState = clGetDeviceInfo(aDeviceId, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(nComputeUnits), &nComputeUnits, NULL);
+    if(nState != CL_SUCCESS)
+        return;
+
+    aDeviceInfo.mnComputeUnits = nComputeUnits;
+
     rPlatformInfo.maDevices.push_back(aDeviceInfo);
 }
 
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index f2b91f8..0b00a04 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -14,10 +14,6 @@
 #include "svtools/svlbitm.hxx"
 #include "svtools/treelistentry.hxx"
 
-#if HAVE_FEATURE_OPENCL
-#include "platforminfo.hxx"
-#endif
-
 namespace {
 
 typedef enum {
@@ -118,11 +114,15 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(Window* pParent, const ScCalcConfig& rC
     get(mpOpenclInfoList, "opencl_list");
     get(mpBtnAutomaticSelectionTrue, "automatic_select_true");
     get(mpBtnAutomaticSelectionFalse, "automatic_select_false");
+    get(mpFtFrequency, "frequency");
+    get(mpFtComputeUnits, "compute_units");
+    get(mpFtMemory, "memory");
 
     mpOpenclInfoList->set_height_request(4* mpOpenclInfoList->GetTextHeight());
     mpOpenclInfoList->SetStyle(mpOpenclInfoList->GetStyle() | WB_CLIPCHILDREN | WB_FORCE_MAKEVISIBLE);
     mpOpenclInfoList->SetHighlightRange();
     mpOpenclInfoList->GetParent()->Hide();
+    mpOpenclInfoList->SetSelectHdl(LINK(this, ScCalcOptionsDialog, DeviceSelHdl));
 
     mpBtnAutomaticSelectionTrue->SetToggleHdl(LINK(this, ScCalcOptionsDialog, BtnAutomaticSelectHdl));
 
@@ -195,14 +195,15 @@ void ScCalcOptionsDialog::fillOpenclList()
 {
     mpOpenclInfoList->SetUpdateMode(false);
     mpOpenclInfoList->Clear();
-    std::vector<sc::OpenclPlatformInfo> aPlatformInfo = sc::listAllOpenclPlatforms();
-    for(std::vector<sc::OpenclPlatformInfo>::const_iterator it = aPlatformInfo.begin(),
-            itEnd = aPlatformInfo.end(); it != itEnd; ++it)
+    maPlatformInfo = sc::listAllOpenclPlatforms();
+    for(std::vector<sc::OpenclPlatformInfo>::iterator it = maPlatformInfo.begin(),
+            itEnd = maPlatformInfo.end(); it != itEnd; ++it)
     {
-        for(std::vector<sc::OpenclDeviceInfo>::const_iterator
+        for(std::vector<sc::OpenclDeviceInfo>::iterator
                 itr = it->maDevices.begin(), itrEnd = it->maDevices.end(); itr != itrEnd; ++itr)
         {
-            mpOpenclInfoList->InsertEntry(it->maVendor + " " + itr->maName);
+            SvTreeListEntry* pEntry = mpOpenclInfoList->InsertEntry(it->maVendor + " " + itr->maName);
+            pEntry->SetUserData(&(*itr));
         }
     }
 
@@ -299,6 +300,7 @@ void ScCalcOptionsDialog::SelectionChanged()
                 bValue = maConfig.mbOpenCLEnabled;
                 mpFtAnnotation->SetText(maDescOpenCLEnabled);
                 mpOpenclInfoList->GetParent()->Show();
+                setOptimalLayoutSize();
                 if(bValue)
                     mpOpenclInfoList->GetParent()->Enable();
                 else
@@ -356,6 +358,18 @@ void ScCalcOptionsDialog::OpenclAutomaticSelectionChanged()
     maConfig.mbOpenCLAutoSelect = bValue;
 }
 
+void ScCalcOptionsDialog::SelectedDeviceChanged()
+{
+#if HAVE_FEATURE_OPENCL
+    SvTreeListEntry* pEntry = mpOpenclInfoList->GetModel()->GetView(0)->FirstSelected();
+    sc::OpenclDeviceInfo* pInfo = reinterpret_cast<sc::OpenclDeviceInfo*>(pEntry->GetUserData());
+    assert(pInfo);
+    mpFtFrequency->SetText(OUString::number(pInfo->mnFrequency));
+    mpFtComputeUnits->SetText(OUString::number(pInfo->mnComputeUnits));
+    mpFtMemory->SetText(OUString::number(pInfo->mnMemory/1024/1024));
+#endif
+}
+
 void ScCalcOptionsDialog::RadioValueChanged()
 {
     sal_uInt16 nSelected = mpLbSettings->GetSelectEntryPos();
@@ -424,5 +438,11 @@ IMPL_LINK_NOARG(ScCalcOptionsDialog, BtnAutomaticSelectHdl)
     return 0;
 }
 
+IMPL_LINK_NOARG(ScCalcOptionsDialog, DeviceSelHdl)
+{
+    SelectedDeviceChanged();
+    return 0;
+}
+
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.hxx b/sc/source/ui/optdlg/calcoptionsdlg.hxx
index 8fade8d..3d6b755 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.hxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.hxx
@@ -20,6 +20,10 @@
 
 #include "calcconfig.hxx"
 
+#if HAVE_FEATURE_OPENCL
+#include "platforminfo.hxx"
+#endif
+
 class ScCalcOptionsDialog : public ModalDialog
 {
 public:
@@ -29,6 +33,7 @@ public:
     DECL_LINK( SettingsSelHdl, Control* );
     DECL_LINK( BtnToggleHdl, void* );
     DECL_LINK( BtnAutomaticSelectHdl, void* );
+    DECL_LINK( DeviceSelHdl, void* );
 
     const ScCalcConfig& GetConfig() const;
 
@@ -38,6 +43,7 @@ private:
     void ListOptionValueChanged();
     void RadioValueChanged();
     void OpenclAutomaticSelectionChanged();
+    void SelectedDeviceChanged();
 #if HAVE_FEATURE_OPENCL
     void fillOpenclList();
 #endif
@@ -55,6 +61,9 @@ private:
     RadioButton* mpBtnFalse;
 
     FixedText* mpFtAnnotation;
+    FixedText* mpFtFrequency;
+    FixedText* mpFtComputeUnits;
+    FixedText* mpFtMemory;
 
     SvTreeListBox* mpOpenclInfoList;
     RadioButton* mpBtnAutomaticSelectionTrue;
@@ -78,6 +87,9 @@ private:
     OUString maDescOpenCLEnabled;
 
     ScCalcConfig maConfig;
+#if HAVE_FEATURE_OPENCL
+    std::vector<sc::OpenclPlatformInfo> maPlatformInfo;
+#endif
 };
 
 #endif
diff --git a/sc/uiconfig/scalc/ui/formulacalculationoptions.ui b/sc/uiconfig/scalc/ui/formulacalculationoptions.ui
index a848051..c5bd7dc 100644
--- a/sc/uiconfig/scalc/ui/formulacalculationoptions.ui
+++ b/sc/uiconfig/scalc/ui/formulacalculationoptions.ui
@@ -4,6 +4,7 @@
   <!-- interface-requires LibreOffice 1.0 -->
   <object class="GtkDialog" id="FormulaCalculationOptions">
     <property name="can_focus">False</property>
+    <property name="vexpand">True</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes">Detailed Calculation Settings</property>
     <property name="type_hint">dialog</property>
@@ -368,6 +369,93 @@
                     <property name="height">1</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkGrid" id="grid5">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkLabel" id="frequency_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Frequency:</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="compute_units_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Compute Units:</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="memory_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Memory (in MB):</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="frequency">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="compute_units">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="memory">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">2</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="left_attach">0</property>


More information about the Libreoffice-commits mailing list