[FEM] Replacement of hardware_concurrency() with idealThreadCount()
I encountered problems with std::thread::hardware_concurrency() with mingw-w64 < v8.1. QThread::idealThreadCount() is a better alternative.
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <thread>
|
||||
# include <QThread>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
@@ -46,10 +46,8 @@ DlgSettingsFemCcxImp::DlgSettingsFemCcxImp(QWidget* parent)
|
||||
ui->dsb_ccx_analysis_time->setMaximum(FLOAT_MAX);
|
||||
ui->dsb_ccx_initial_time_step->setMaximum(FLOAT_MAX);
|
||||
// determine number of CPU cores
|
||||
auto processor_count = std::thread::hardware_concurrency();
|
||||
// hardware check might fail and then returns 0
|
||||
if (processor_count > 0)
|
||||
ui->sb_ccx_numcpu->setMaximum(processor_count);
|
||||
int processor_count = QThread::idealThreadCount();
|
||||
ui->sb_ccx_numcpu->setMaximum(processor_count);
|
||||
|
||||
connect(ui->fc_ccx_binary_path, &Gui::PrefFileChooser::fileNameChanged,
|
||||
this, &DlgSettingsFemCcxImp::onfileNameChanged);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <thread>
|
||||
# include <QThread>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
@@ -41,10 +41,8 @@ DlgSettingsFemElmerImp::DlgSettingsFemElmerImp(QWidget* parent)
|
||||
ui->setupUi(this);
|
||||
|
||||
// determine number of CPU cores
|
||||
processor_count = std::thread::hardware_concurrency();
|
||||
// hardware check might fail and then returns 0
|
||||
if (processor_count > 0)
|
||||
ui->sb_elmer_num_cores->setMaximum(processor_count);
|
||||
processor_count = QThread::idealThreadCount();
|
||||
ui->sb_elmer_num_cores->setMaximum(processor_count);
|
||||
|
||||
connect(ui->fc_grid_binary_path, &Gui::PrefFileChooser::fileNameChanged,
|
||||
this, &DlgSettingsFemElmerImp::onfileNameChanged);
|
||||
@@ -109,10 +107,7 @@ void DlgSettingsFemElmerImp::onfileNameChanged(QString FileName)
|
||||
|
||||
void DlgSettingsFemElmerImp::onfileNameChangedMT(QString FileName)
|
||||
{
|
||||
// reset in case it was previously set to 1
|
||||
// (hardware check might fail and then returns 0)
|
||||
if (processor_count > 0)
|
||||
ui->sb_elmer_num_cores->setMaximum(processor_count);
|
||||
ui->sb_elmer_num_cores->setMaximum(processor_count);
|
||||
|
||||
if (ui->sb_elmer_num_cores->value() == 1)
|
||||
return;
|
||||
|
||||
@@ -51,7 +51,7 @@ protected:
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgSettingsFemElmerImp> ui;
|
||||
unsigned int processor_count;
|
||||
int processor_count;
|
||||
};
|
||||
|
||||
} // namespace FemGui
|
||||
|
||||
Reference in New Issue
Block a user