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

show compute units, frequency and memory for opencl devices

Change-Id: Ib322a429a3d29ed985702dc1b5cb9d1cb0a1ac07
üst 8fa1a8b4
......@@ -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
......
......@@ -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);
}
......
......@@ -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: */
......@@ -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
......
......@@ -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>
......
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