Kaydet (Commit) c8c1479a authored tarafından Markus Mohrhard's avatar Markus Mohrhard

inital work on showing available opencl platforms/devices

Change-Id: I7e9beb3abeee42b19788980d43fb1ab5140e3e65
üst 4ca847ce
...@@ -35,6 +35,7 @@ $(eval $(call gb_Library_use_libraries,scopencl,\ ...@@ -35,6 +35,7 @@ $(eval $(call gb_Library_use_libraries,scopencl,\
$(eval $(call gb_Library_add_exception_objects,scopencl,\ $(eval $(call gb_Library_add_exception_objects,scopencl,\
sc/source/core/opencl/formulagroupcl \ sc/source/core/opencl/formulagroupcl \
sc/source/core/opencl/platforminfo \
sc/source/core/opencl/openclwrapper \ sc/source/core/opencl/openclwrapper \
sc/source/core/opencl/clcc/clew \ sc/source/core/opencl/clcc/clew \
)) ))
......
...@@ -35,6 +35,7 @@ $(eval $(call gb_Library_use_libraries,scui,\ ...@@ -35,6 +35,7 @@ $(eval $(call gb_Library_use_libraries,scui,\
i18nlangtag \ i18nlangtag \
sal \ sal \
sc \ sc \
scopencl \
sfx \ sfx \
sot \ sot \
svl \ svl \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef SC_PLATFORM_INFO_HXX
#define SC_PLATFORM_INFO_HXX
#include <vector>
#include <rtl/ustring.hxx>
#include "scdllapi.h"
namespace sc {
struct SC_DLLPUBLIC OpenclDeviceInfo
{
size_t mnId;
OUString maName;
OUString maVendor;
};
struct SC_DLLPUBLIC OpenclPlatformInfo
{
void* mnId;
OUString maVendor;
OUString maName;
std::vector<OpenclDeviceInfo> maDevices;
};
SC_DLLPUBLIC std::vector<OpenclPlatformInfo> listAllOpenclPlatforms();
}
#endif
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#include "openclwrapper.hxx" #include "openclwrapper.hxx"
#include <rtl/ustring.hxx>
#include <boost/scoped_array.hpp>
#include "sal/config.h" #include "sal/config.h"
#include "oclkernels.hxx" #include "oclkernels.hxx"
...@@ -2628,6 +2631,92 @@ int OclCalc::oclHostMatrixInverse32Bits( const char* aKernelName, float *fpOclMa ...@@ -2628,6 +2631,92 @@ int OclCalc::oclHostMatrixInverse32Bits( const char* aKernelName, float *fpOclMa
return 0; return 0;
} }
namespace {
void createDeviceInfo(cl_device_id aDeviceId, OpenclPlatformInfo& rPlatformInfo)
{
OpenclDeviceInfo aDeviceInfo;
char pName[64];
cl_int nState = clGetDeviceInfo(aDeviceId, CL_DEVICE_NAME, 64, pName, NULL);
if(nState != CL_SUCCESS)
return;
aDeviceInfo.maName = OUString::createFromAscii(pName);
char pVendor[64];
nState = clGetDeviceInfo(aDeviceId, CL_DEVICE_VENDOR, 64, pName, NULL);
if(nState != CL_SUCCESS)
return;
aDeviceInfo.maVendor = OUString::createFromAscii(pVendor);
rPlatformInfo.maDevices.push_back(aDeviceInfo);
}
bool createPlatformInfo(cl_platform_id nPlatformId, OpenclPlatformInfo& rPlatformInfo)
{
rPlatformInfo.mnId = nPlatformId;
char pName[64];
cl_int nState = clGetPlatformInfo(nPlatformId, CL_PLATFORM_NAME, 64,
pName, NULL);
if(nState != CL_SUCCESS)
return false;
rPlatformInfo.maName = OUString::createFromAscii(pName);
char pVendor[64];
nState = clGetPlatformInfo(nPlatformId, CL_PLATFORM_VENDOR, 64,
pVendor, NULL);
if(nState != CL_SUCCESS)
return false;
rPlatformInfo.maVendor = OUString::createFromAscii(pName);
cl_uint nDevices;
nState = clGetDeviceIDs(nPlatformId, CL_DEVICE_TYPE_ALL, 0, NULL, &nDevices);
if(nState != CL_SUCCESS)
return false;
boost::scoped_array<cl_device_id> pDevices(new cl_device_id[nDevices]);
nState = clGetDeviceIDs(nPlatformId, CL_DEVICE_TYPE_ALL, nDevices, pDevices.get(), NULL);
if(nState != CL_SUCCESS)
return false;
for(size_t i = 0; i < nDevices; ++i)
{
createDeviceInfo(pDevices[i], rPlatformInfo);
}
return true;
}
}
void fillOpenCLInfo(std::vector<OpenclPlatformInfo>& rPlatforms)
{
int status = clewInit("libOpenCL.so");
if (status < 0)
return;
cl_uint nPlatforms;
cl_int nState = clGetPlatformIDs(0, NULL, &nPlatforms);
if(nState != CL_SUCCESS)
return;
boost::scoped_array<cl_platform_id> pPlatforms(new cl_platform_id[nPlatforms]);
nState = clGetPlatformIDs(nPlatforms, pPlatforms.get(), NULL);
if(nState != CL_SUCCESS)
return;
for(size_t i = 0; i < nPlatforms; ++i)
{
OpenclPlatformInfo aPlatformInfo;
if(createPlatformInfo(pPlatforms[i], aPlatformInfo))
rPlatforms.push_back(aPlatformInfo);
}
}
}} }}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <formula/opcode.hxx> #include <formula/opcode.hxx>
#include <sal/detail/log.h> #include <sal/detail/log.h>
#include <cassert> #include <cassert>
#include "platforminfo.hxx"
#include "clcc/clew.h" #include "clcc/clew.h"
...@@ -279,6 +280,8 @@ public: ...@@ -279,6 +280,8 @@ public:
friend class agency; friend class agency;
}; };
void fillOpenCLInfo(std::vector<OpenclPlatformInfo>& rPlatforms);
}} }}
#endif #endif
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "platforminfo.hxx"
#include "openclwrapper.hxx"
namespace sc {
std::vector<OpenclPlatformInfo> listAllOpenclPlatforms()
{
std::vector<OpenclPlatformInfo> aPlatforms;
opencl::fillOpenCLInfo(aPlatforms);
return aPlatforms;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#include <config_features.h>
#include "calcoptionsdlg.hxx" #include "calcoptionsdlg.hxx"
#include "sc.hrc" #include "sc.hrc"
#include "scresid.hxx" #include "scresid.hxx"
...@@ -16,6 +14,10 @@ ...@@ -16,6 +14,10 @@
#include "svtools/svlbitm.hxx" #include "svtools/svlbitm.hxx"
#include "svtools/treelistentry.hxx" #include "svtools/treelistentry.hxx"
#if HAVE_FEATURE_OPENCL
#include "platforminfo.hxx"
#endif
namespace { namespace {
typedef enum { typedef enum {
...@@ -113,6 +115,14 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(Window* pParent, const ScCalcConfig& rC ...@@ -113,6 +115,14 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(Window* pParent, const ScCalcConfig& rC
get(mpFtAnnotation, "annotation"); get(mpFtAnnotation, "annotation");
get(mpBtnTrue, "true"); get(mpBtnTrue, "true");
get(mpBtnFalse, "false"); get(mpBtnFalse, "false");
get(mpOpenclInfoList, "opencl_list");
get(mpBtnAutomaticSelectionTrue, "automatic_select_true");
get(mpBtnAutomaticSelectionFalse, "automatic_select_false");
mpOpenclInfoList->set_height_request(4* mpOpenclInfoList->GetTextHeight());
mpOpenclInfoList->SetStyle(mpOpenclInfoList->GetStyle() | WB_CLIPCHILDREN | WB_FORCE_MAKEVISIBLE);
mpOpenclInfoList->SetHighlightRange();
mpOpenclInfoList->GetParent()->Hide();
maCaptionStringRefSyntax = get<Window>("ref_syntax_caption")->GetText(); maCaptionStringRefSyntax = get<Window>("ref_syntax_caption")->GetText();
maDescStringRefSyntax = get<Window>("ref_syntax_desc")->GetText(); maDescStringRefSyntax = get<Window>("ref_syntax_desc")->GetText();
...@@ -177,6 +187,36 @@ void ScCalcOptionsDialog::setValueAt(size_t nPos, const OUString &rValue) ...@@ -177,6 +187,36 @@ void ScCalcOptionsDialog::setValueAt(size_t nPos, const OUString &rValue)
pModel->InvalidateEntry(pEntry); pModel->InvalidateEntry(pEntry);
} }
#if HAVE_FEATURE_OPENCL
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)
{
SvTreeListEntry* pEntry = new SvTreeListEntry;
pEntry->AddItem(new SvLBoxContextBmp(pEntry, 0, Image(), Image(), 0));
pEntry->AddItem(new SvLBoxString(pEntry, 0, it->maVendor));
mpOpenclInfoList->GetModel()->Insert(pEntry);
for(std::vector<sc::OpenclDeviceInfo>::const_iterator
itr = it->maDevices.begin(), itrEnd = it->maDevices.end(); itr != itrEnd; ++itr)
{
SvTreeListEntry* pDeviceEntry = new SvTreeListEntry;
pDeviceEntry->AddItem(new SvLBoxContextBmp(pDeviceEntry, 0, Image(), Image(), 0));
pDeviceEntry->AddItem(new SvLBoxString(pDeviceEntry, 0, itr->maName));
mpOpenclInfoList->GetModel()->Insert(pDeviceEntry, pEntry);
}
}
mpOpenclInfoList->SetUpdateMode(true);
}
#endif
void ScCalcOptionsDialog::FillOptionsList() void ScCalcOptionsDialog::FillOptionsList()
{ {
mpLbSettings->SetUpdateMode(false); mpLbSettings->SetUpdateMode(false);
...@@ -198,6 +238,7 @@ void ScCalcOptionsDialog::FillOptionsList() ...@@ -198,6 +238,7 @@ void ScCalcOptionsDialog::FillOptionsList()
pModel->Insert(createBoolItem(maCaptionEmptyStringAsZero,maConfig.mbEmptyStringAsZero)); pModel->Insert(createBoolItem(maCaptionEmptyStringAsZero,maConfig.mbEmptyStringAsZero));
#if HAVE_FEATURE_OPENCL #if HAVE_FEATURE_OPENCL
pModel->Insert(createBoolItem(maCaptionOpenCLEnabled,maConfig.mbOpenCLEnabled)); pModel->Insert(createBoolItem(maCaptionOpenCLEnabled,maConfig.mbOpenCLEnabled));
fillOpenclList();
#endif #endif
mpLbSettings->SetUpdateMode(true); mpLbSettings->SetUpdateMode(true);
...@@ -214,6 +255,7 @@ void ScCalcOptionsDialog::SelectionChanged() ...@@ -214,6 +255,7 @@ void ScCalcOptionsDialog::SelectionChanged()
mpBtnTrue->Hide(); mpBtnTrue->Hide();
mpBtnFalse->Hide(); mpBtnFalse->Hide();
mpLbOptionEdit->Show(); mpLbOptionEdit->Show();
mpOpenclInfoList->GetParent()->Hide();
mpLbOptionEdit->Clear(); mpLbOptionEdit->Clear();
mpLbOptionEdit->InsertEntry(maUseFormulaSyntax); mpLbOptionEdit->InsertEntry(maUseFormulaSyntax);
...@@ -253,11 +295,17 @@ void ScCalcOptionsDialog::SelectionChanged() ...@@ -253,11 +295,17 @@ void ScCalcOptionsDialog::SelectionChanged()
{ {
bValue = maConfig.mbEmptyStringAsZero; bValue = maConfig.mbEmptyStringAsZero;
mpFtAnnotation->SetText(maDescEmptyStringAsZero); mpFtAnnotation->SetText(maDescEmptyStringAsZero);
mpOpenclInfoList->GetParent()->Hide();
} }
else else
{ {
bValue = maConfig.mbOpenCLEnabled; bValue = maConfig.mbOpenCLEnabled;
mpFtAnnotation->SetText(maDescOpenCLEnabled); mpFtAnnotation->SetText(maDescOpenCLEnabled);
mpOpenclInfoList->GetParent()->Show();
if(bValue)
mpOpenclInfoList->GetParent()->Enable();
else
mpOpenclInfoList->GetParent()->Disable();
} }
if ( bValue ) if ( bValue )
......
...@@ -10,10 +10,13 @@ ...@@ -10,10 +10,13 @@
#ifndef __SC_OPTDLG_CALCOPTIONSDLG_HXX__ #ifndef __SC_OPTDLG_CALCOPTIONSDLG_HXX__
#define __SC_OPTDLG_CALCOPTIONSDLG_HXX__ #define __SC_OPTDLG_CALCOPTIONSDLG_HXX__
#include <config_features.h>
#include "vcl/dialog.hxx" #include "vcl/dialog.hxx"
#include "vcl/button.hxx" #include "vcl/button.hxx"
#include "vcl/fixed.hxx" #include "vcl/fixed.hxx"
#include "svx/checklbx.hxx" #include "svx/checklbx.hxx"
#include "svtools/treelistbox.hxx"
#include "calcconfig.hxx" #include "calcconfig.hxx"
...@@ -33,6 +36,9 @@ private: ...@@ -33,6 +36,9 @@ private:
void SelectionChanged(); void SelectionChanged();
void ListOptionValueChanged(); void ListOptionValueChanged();
void RadioValueChanged(); void RadioValueChanged();
#if HAVE_FEATURE_OPENCL
void fillOpenclList();
#endif
OUString toString(formula::FormulaGrammar::AddressConvention eConv) const; OUString toString(formula::FormulaGrammar::AddressConvention eConv) const;
OUString toString(bool bVal) const; OUString toString(bool bVal) const;
...@@ -48,6 +54,10 @@ private: ...@@ -48,6 +54,10 @@ private:
FixedText* mpFtAnnotation; FixedText* mpFtAnnotation;
SvTreeListBox* mpOpenclInfoList;
RadioButton* mpBtnAutomaticSelectionTrue;
RadioButton* mpBtnAutomaticSelectionFalse;
OUString maTrue; OUString maTrue;
OUString maFalse; OUString maFalse;
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<!-- interface-requires gtk+ 3.6 --> <!-- interface-requires gtk+ 3.6 -->
<!-- interface-requires LibreOffice 1.0 -->
<object class="GtkDialog" id="FormulaCalculationOptions"> <object class="GtkDialog" id="FormulaCalculationOptions">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
...@@ -66,6 +67,9 @@ ...@@ -66,6 +67,9 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="Check List Box-selection1"/>
</child>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -173,6 +177,7 @@ ...@@ -173,6 +177,7 @@
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="yalign">0</property> <property name="yalign">0</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">56</property> <property name="max_width_chars">56</property>
</object> </object>
<packing> <packing>
...@@ -190,7 +195,7 @@ ...@@ -190,7 +195,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">3</property> <property name="top_attach">4</property>
<property name="width">1</property> <property name="width">1</property>
<property name="height">1</property> <property name="height">1</property>
</packing> </packing>
...@@ -205,7 +210,7 @@ ...@@ -205,7 +210,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">4</property> <property name="top_attach">5</property>
<property name="width">1</property> <property name="width">1</property>
<property name="height">1</property> <property name="height">1</property>
</packing> </packing>
...@@ -218,7 +223,7 @@ ...@@ -218,7 +223,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">5</property> <property name="top_attach">6</property>
<property name="width">1</property> <property name="width">1</property>
<property name="height">1</property> <property name="height">1</property>
</packing> </packing>
...@@ -231,7 +236,7 @@ ...@@ -231,7 +236,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">6</property> <property name="top_attach">7</property>
<property name="width">1</property> <property name="width">1</property>
<property name="height">1</property> <property name="height">1</property>
</packing> </packing>
...@@ -246,7 +251,7 @@ ...@@ -246,7 +251,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">7</property> <property name="top_attach">8</property>
<property name="width">1</property> <property name="width">1</property>
<property name="height">1</property> <property name="height">1</property>
</packing> </packing>
...@@ -259,7 +264,7 @@ ...@@ -259,7 +264,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">8</property> <property name="top_attach">9</property>
<property name="width">1</property> <property name="width">1</property>
<property name="height">1</property> <property name="height">1</property>
</packing> </packing>
...@@ -274,7 +279,99 @@ ...@@ -274,7 +279,99 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">9</property> <property name="top_attach">10</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid6">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="row_spacing">2</property>
<child>
<object class="svtlo-SvTreeListBox" id="opencl_list">
<property name="visible">True</property>
<property name="app_paintable">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="Tree List-selection1"/>
</child>
</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="GtkGrid" id="grid3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Automatic Selection of Platform/Device:</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="GtkRadioButton" id="automatic_select_true">
<property name="label" translatable="yes">True</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">automatic_select_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="GtkRadioButton" id="automatic_select_false">
<property name="label" translatable="yes">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">automatic_select_true</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</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">0</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">3</property>
<property name="width">1</property> <property name="width">1</property>
<property name="height">1</property> <property name="height">1</property>
</packing> </packing>
......
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