Skip to content
Snippets Groups Projects
Unverified Commit 49e9f148 authored by Yurov, Dmitry's avatar Yurov, Dmitry Committed by GitHub
Browse files

Merge pull request #402 from gpospelov/develop

Fixed multithreading with n_threads>9
parents fd2b38ec 4e8e96a4
No related branches found
No related tags found
No related merge requests found
...@@ -100,10 +100,7 @@ SimulationOptionsItem::SimulationOptionsItem() ...@@ -100,10 +100,7 @@ SimulationOptionsItem::SimulationOptionsItem()
int SimulationOptionsItem::getNumberOfThreads() const int SimulationOptionsItem::getNumberOfThreads() const
{ {
ComboProperty combo = getItemValue(P_NTHREADS).value<ComboProperty>(); ComboProperty combo = getItemValue(P_NTHREADS).value<ComboProperty>();
foreach(QChar ch, combo.getValue()) { return m_text_to_nthreads[combo.getValue()];
if(ch.isDigit()) return ch.digitValue();
}
return 0;
} }
bool SimulationOptionsItem::runImmediately() const bool SimulationOptionsItem::runImmediately() const
...@@ -181,16 +178,20 @@ QString SimulationOptionsItem::runPolicy() const ...@@ -181,16 +178,20 @@ QString SimulationOptionsItem::runPolicy() const
//! returns list with number of threads to select //! returns list with number of threads to select
QStringList SimulationOptionsItem::getCPUUsageOptions() QStringList SimulationOptionsItem::getCPUUsageOptions()
{ {
m_text_to_nthreads.clear();
QStringList result; QStringList result;
int nthreads = std::thread::hardware_concurrency(); int nthreads = std::thread::hardware_concurrency();
for(int i = nthreads; i>0; i--){ for(int i = nthreads; i>0; i--){
QString str;
if(i == nthreads) { if(i == nthreads) {
result.append(QString("Max (%1 threads)").arg(QString::number(i))); str = QString("Max (%1 threads)").arg(QString::number(i));
} else if(i == 1) { } else if(i == 1) {
result.append(QString("%1 thread").arg(QString::number(i))); str = QString("%1 thread").arg(QString::number(i));
} else { } else {
result.append(QString("%1 threads").arg(QString::number(i))); str = QString("%1 threads").arg(QString::number(i));
} }
result.append(str);
m_text_to_nthreads[str] = i;
} }
return result; return result;
} }
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#define SIMULATIONOPTIONSITEM_H #define SIMULATIONOPTIONSITEM_H
#include "SessionItem.h" #include "SessionItem.h"
#include <QMap>
//! The SimulationOptionsItem class holds simulation status (run policy, number of threads, //! The SimulationOptionsItem class holds simulation status (run policy, number of threads,
//! integration flag). Used in SimulationView to define job settings. When job is started, //! integration flag). Used in SimulationView to define job settings. When job is started,
...@@ -54,6 +55,7 @@ public: ...@@ -54,6 +55,7 @@ public:
private: private:
QString runPolicy() const; QString runPolicy() const;
QStringList getCPUUsageOptions(); QStringList getCPUUsageOptions();
QMap<QString, int> m_text_to_nthreads;
}; };
#endif // SIMULATIONOPTIONSITEM_H #endif // SIMULATIONOPTIONSITEM_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment