Compare commits

...

2 Commits

Author SHA1 Message Date
suter_a 6ed33d6500 PPrefsDialog.ui adopted for Qt5.
Build and Deploy Documentation / build-and-deploy (push) Successful in 23s
2026-06-07 11:30:41 +02:00
suter_a e90590b908 allow to set the number of threads for fitting directly via the preferences of musredit. Qt5 ui not yet adopted.
Build and Deploy Documentation / build-and-deploy (push) Successful in 31s
2026-06-07 11:03:02 +02:00
16 changed files with 153 additions and 15 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ if (CMAKE_VERSION GREATER_EQUAL "3.3")
cmake_policy(SET CMP0167 NEW)
endif ()
project(musrfit VERSION 1.11.0 LANGUAGES C CXX)
project(musrfit VERSION 1.11.1 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+6
View File
@@ -12,6 +12,12 @@ or
https://bitbucket.org/muonspin/musrfit
Release of V1.11.1, 2026/06/07
==============================
allow from musredit (via preferences) to select the number of threads to be used
for fitting.
Release of V1.11.0, 2026/05/28
==============================
+10
View File
@@ -168,6 +168,8 @@ bool PAdminXMLParser::startElement()
fKeyWord = eEstimateN0;
} else if (qName == "yaml_out") {
fKeyWord = eYamlOut;
} else if (qName == "use_no_of_threads") {
fKeyWord = eNoOfTreadsToBeUsed;
} else if (qName == "chisq_per_run_block") {
fKeyWord = eChisqPreRunBlock;
} else if (qName == "path_file_name") {
@@ -420,6 +422,11 @@ bool PAdminXMLParser::characters()
fAdmin->fMsr2DataParam.perRunBlockChisq = flag;
fAdmin->setChisqPerRunBlockFlag(flag);
break;
case eNoOfTreadsToBeUsed:
ival = QString(str.toLatin1()).trimmed().toInt(&ok);
if (ok)
fAdmin->setNoOfThreadsToBeUsed(ival);
break;
case eRecentFile:
fAdmin->addRecentFile(QString(str.toLatin1()).trimmed());
break;
@@ -988,6 +995,9 @@ int PAdmin::savePrefs(QString pref_fln)
else
data[i] = " <yaml_out>n</yaml_out>";
}
if (data[i].contains("<use_no_of_threads>") && data[i].contains("</use_no_of_threads>")) {
data[i] = " <use_no_of_threads>" + QString("%1").arg(fNoOfThreadsToBeUsed) + "</use_no_of_threads>";
}
if (data[i].contains("<musrview_show_fourier>") && data[i].contains("</musrview_show_fourier>")) {
if (fMusrviewShowFourier)
data[i] = " <musrview_show_fourier>y</musrview_show_fourier>";
+4 -1
View File
@@ -70,7 +70,7 @@ class PAdminXMLParser
private:
enum EAdminKeyWords {eEmpty, eTimeout, eKeepMinuit2Output, eDumpAscii, eDumpRoot,
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eYamlOut,
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eYamlOut, eNoOfTreadsToBeUsed,
eMusrviewShowFourier, eMusrviewShowAvg, eMusrviewShowOneToOne, eEnableMusrT0,
eDarkThemeIconsMenu, eDarkThemeIconsToolbar, eIgnoreThemeAutoDetection, eEditW, eEditH,
eFontName, eFontSize, eExecPath, eDefaultSavePath,
@@ -128,6 +128,7 @@ class PAdmin : public QObject
bool getDumpRootFlag() { return fDumpRoot; }
bool getEstimateN0Flag() { return fEstimateN0; }
bool getYamlOutFlag() { return fYamlOut; }
int getNoOfThreadsToBeUsed() { return fNoOfThreadsToBeUsed; }
bool getChisqPerRunBlockFlag() { return fChisqPreRunBlock; }
bool getIgnoreThemeAutoDetection() { return fIgnoreThemeAutoDetection; }
bool getDarkThemeIconsMenuFlag() { return fDarkThemeIconsMenu; }
@@ -158,6 +159,7 @@ class PAdmin : public QObject
void setDumpRootFlag(const bool flag) { fDumpRoot = flag; }
void setEstimateN0Flag(const bool flag) { fEstimateN0 = flag; }
void setYamlOutFlag(const bool flag) { fYamlOut = flag; }
void setNoOfThreadsToBeUsed(const int num) { fNoOfThreadsToBeUsed = num; }
void setChisqPerRunBlockFlag(const bool flag) { fChisqPreRunBlock = flag; }
void setIgnoreThemeAutoDetection(const bool flag) { fIgnoreThemeAutoDetection = flag; }
void setDarkThemeIconsMenuFlag(const bool flag) { fDarkThemeIconsMenu = flag; }
@@ -209,6 +211,7 @@ class PAdmin : public QObject
bool fChisqPreRunBlock{false}; ///< flag indicating if musrfit shall write 'per run block' chisq to the msr-file (default: no).
bool fEstimateN0{true}; ///< flag indicating if musrfit shall estimate N0 for single histogram fits (default: yes).
bool fYamlOut{false}; ///< flag indicating if the MINUIT2.OUTPUT file should also be written as <msr-file>.yaml output. (default: no).
int fNoOfThreadsToBeUsed{1}; ///< number of threads to be used
bool fEnableMusrT0{true}; ///< flag indicating if musrT0 shall be enabled at startup from within musredit (default: yes).
bool fIgnoreThemeAutoDetection{false}; ///< flag indicating that the theme autodetection shall be ignored. (default: no)
bool fDarkThemeIconsMenu{false}; ///< flag indicating if dark theme icons shall be used in the menu (default: no)
@@ -28,6 +28,7 @@
***************************************************************************/
#include <memory>
#include <unistd.h> // for # of threads
#include "PChangeDefaultPathsDialog.h"
#include "PPrefsDialog.h"
@@ -90,6 +91,15 @@ PPrefsDialog::PPrefsDialog(PAdmin *admin) : fAdmin(admin)
fTimeout_lineEdit->setText(QString("%1").arg(fAdmin->getTimeout()));
fTimeout_lineEdit->setValidator(new QIntValidator(fTimeout_lineEdit));
// get number of threads info from the systems
long nprocs = sysconf(_SC_NPROCESSORS_ONLN);
if (fAdmin->getNoOfThreadsToBeUsed() > nprocs)
fAdmin->setNoOfThreadsToBeUsed(nprocs);
for (auto i=0; i<nprocs; i++)
fNumberOfThreads_comboBox->addItem(QString("%1").arg(i+1));
fNumberOfThreads_comboBox->setCurrentIndex(fAdmin->getNoOfThreadsToBeUsed()-1);
QObject::connect(fNumberOfThreads_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(numberOfThreadsChanged(int)));
QObject::connect(fDefaultPath_pushButton, SIGNAL(clicked()), this, SLOT(handleDefaultPaths()));
}
@@ -145,6 +155,17 @@ void PPrefsDialog::handleDefaultPaths()
}
}
//----------------------------------------------------------------------------------------------------
/**
* @brief Slot: keeps the number of threads to be used for fitting.
*
* @param idx index of the comboBox
*/
void PPrefsDialog::numberOfThreadsChanged(int idx)
{
fAdmin->setNoOfThreadsToBeUsed(idx+1);
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------
+1
View File
@@ -66,6 +66,7 @@ class PPrefsDialog : public QDialog, private Ui::PPrefsDialog
void dumpAscii();
void dumpRoot();
void handleDefaultPaths();
void numberOfThreadsChanged(int idx);
private:
PAdmin *fAdmin;
+5
View File
@@ -2162,6 +2162,11 @@ void PTextEdit::musrFit()
cmd.append("--yaml");
}
// check how many threads to be used
cmd.append("--use-no-of-threads");
QString noThreads = QString("%1").arg(fAdmin->getNoOfThreadsToBeUsed());
cmd.append(noThreads);
// check per-run-block-chisq flag
if (fAdmin->getChisqPerRunBlockFlag()) {
cmd.append("--per-run-block-chisq");
@@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>460</width>
<height>200</height>
<height>241</height>
</rect>
</property>
<property name="windowTitle">
@@ -26,7 +26,7 @@
<item>
<widget class="QTabWidget" name="fTabWidget">
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="fGeneral_tab">
<attribute name="title">
@@ -36,7 +36,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<y>110</y>
<width>421</width>
<height>31</height>
</rect>
@@ -45,13 +45,13 @@
<string>Change Default Search Paths</string>
</property>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>416</width>
<height>61</height>
<height>79</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
@@ -201,6 +201,28 @@
<string>yaml out</string>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>100</y>
<width>251</width>
<height>25</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QComboBox" name="fNumberOfThreads_comboBox"/>
</item>
<item>
<widget class="QLabel" name="fNumberOfThreads_label">
<property name="text">
<string># threads to be used</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="fMusrview_tab">
<attribute name="title">
@@ -15,6 +15,7 @@
<chisq_per_run_block>n</chisq_per_run_block>
<estimate_n0>y</estimate_n0>
<yaml_out>n</yaml_out>
<use_no_of_threads>1024</use_no_of_threads>
<musrview_show_fourier>n</musrview_show_fourier>
<musrview_show_avg>n</musrview_show_avg>
<musrview_show_one_to_one>n</musrview_show_one_to_one>
+10
View File
@@ -212,6 +212,8 @@ bool PAdminXMLParser::startElement()
fKeyWord = eEstimateN0;
} else if (qName == "yaml_out") {
fKeyWord = eYamlOut;
} else if (qName == "use_no_of_threads") {
fKeyWord = eNoOfTreadsToBeUsed;
} else if (qName == "chisq_per_run_block") {
fKeyWord = eChisqPreRunBlock;
} else if (qName == "path_file_name") {
@@ -469,6 +471,11 @@ bool PAdminXMLParser::characters()
fAdmin->fMsr2DataParam.yamlOut = flag;
fAdmin->setYamlOutFlag(flag);
break;
case eNoOfTreadsToBeUsed:
ival = QString(str.toLatin1()).trimmed().toInt(&ok);
if (ok)
fAdmin->setNoOfThreadsToBeUsed(ival);
break;
case eChisqPreRunBlock:
if (str == "y")
flag = true;
@@ -1134,6 +1141,9 @@ int PAdmin::savePrefs(QString pref_fln)
else
data[i] = " <yaml_out>n</yaml_out>";
}
if (data[i].contains("<use_no_of_threads>") && data[i].contains("</use_no_of_threads>")) {
data[i] = " <use_no_of_threads>" + QString("%1").arg(fNoOfThreadsToBeUsed) + "</use_no_of_threads>";
}
if (data[i].contains("<musrview_show_fourier>") && data[i].contains("</musrview_show_fourier>")) {
if (fMusrviewShowFourier)
data[i] = " <musrview_show_fourier>y</musrview_show_fourier>";
+4 -1
View File
@@ -143,7 +143,7 @@ class PAdminXMLParser
* The parser uses these to determine how to process element content.
*/
enum EAdminKeyWords {eEmpty, eTimeout, eKeepMinuit2Output, eDumpAscii, eDumpRoot,
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eYamlOut,
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eYamlOut, eNoOfTreadsToBeUsed,
eMusrviewShowFourier, eMusrviewShowAvg, eMusrviewShowOneToOne, eEnableMusrT0,
eIgnoreThemeAutoDetection, eDarkThemeIconsMenu, eDarkThemeIconsToolbar, eEditW, eEditH,
eFontName, eFontSize, eExecPath, eDefaultSavePath,
@@ -225,6 +225,7 @@ class PAdmin : public QObject
bool getMusrviewShowOneToOneFlag() { return fMusrviewShowOneToOne; } ///< Check if one-to-one theory display is enabled.
bool getEnableMusrT0Flag() { return fEnableMusrT0; } ///< Check if musrT0 is enabled.
bool getYamlOutFlag() { return fYamlOut; } ///< Check if YAML output is enabled.
int getNoOfThreadsToBeUsed() { return fNoOfThreadsToBeUsed; } ///< Get number of threads to be used
bool getKeepMinuit2OutputFlag() { return fKeepMinuit2Output; } ///< Check if MINUIT2 output files are preserved.
bool getDumpAsciiFlag() { return fDumpAscii; } ///< Check if ASCII dump is enabled.
bool getDumpRootFlag() { return fDumpRoot; } ///< Check if ROOT dump is enabled.
@@ -264,6 +265,7 @@ class PAdmin : public QObject
void setDumpRootFlag(const bool flag) { fDumpRoot = flag; } ///< Enable/disable ROOT dump.
void setEstimateN0Flag(const bool flag) { fEstimateN0 = flag; } ///< Enable/disable N0 estimation.
void setYamlOutFlag(const bool flag) { fYamlOut = flag; } ///< Enable/disable YAML output.
void setNoOfThreadsToBeUsed(const int num) { fNoOfThreadsToBeUsed = num; } ///< set number of threads to be used
void setChisqPerRunBlockFlag(const bool flag) { fChisqPreRunBlock = flag; } ///< Enable/disable per-run-block chi-square.
void setIgnoreThemeAutoDetection(const bool flag) { fIgnoreThemeAutoDetection = flag; } ///< Enable/disable theme auto-detection.
void setDarkThemeIconsMenuFlag(const bool flag) { fDarkThemeIconsMenu = flag; } ///< Enable/disable dark theme menu icons.
@@ -356,6 +358,7 @@ class PAdmin : public QObject
bool fChisqPreRunBlock{false}; ///< If true, write per-run-block chi-square values to msr-file.
bool fEstimateN0{true}; ///< If true, estimate N0 parameter for single histogram fits.
bool fYamlOut{false}; ///< If true, write MINUIT2 output additionally as \<msr-file\>.yaml.
int fNoOfThreadsToBeUsed{1}; ///< number of threads to be used
/** @} */
/** @name MSR File Defaults
@@ -45,6 +45,7 @@
*/
#include <memory>
#include <unistd.h> // for # of threads
#include "PChangeDefaultPathsDialog.h"
#include "PPrefsDialog.h"
@@ -164,6 +165,15 @@ PPrefsDialog::PPrefsDialog(PAdmin *admin) : fAdmin(admin)
fTimeout_lineEdit->setText(QString("%1").arg(fAdmin->getTimeout()));
fTimeout_lineEdit->setValidator(new QIntValidator(fTimeout_lineEdit));
// get number of threads info from the systems
long nprocs = sysconf(_SC_NPROCESSORS_ONLN);
if (fAdmin->getNoOfThreadsToBeUsed() > nprocs)
fAdmin->setNoOfThreadsToBeUsed(nprocs);
for (auto i=0; i<nprocs; i++)
fNumberOfThreads_comboBox->addItem(QString("%1").arg(i+1));
fNumberOfThreads_comboBox->setCurrentIndex(fAdmin->getNoOfThreadsToBeUsed()-1);
QObject::connect(fNumberOfThreads_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(numberOfThreadsChanged(int)));
QObject::connect(fDefaultPath_pushButton, SIGNAL(clicked()), this, SLOT(handleDefaultPaths()));
}
@@ -340,6 +350,17 @@ void PPrefsDialog::handleDefaultPaths()
}
}
//----------------------------------------------------------------------------------------------------
/**
* @brief Slot: keeps the number of threads to be used for fitting.
*
* @param idx index of the comboBox
*/
void PPrefsDialog::numberOfThreadsChanged(int idx)
{
fAdmin->setNoOfThreadsToBeUsed(idx+1);
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------
+7
View File
@@ -318,6 +318,13 @@ class PPrefsDialog : public QDialog, private Ui::PPrefsDialog
*/
void handleDefaultPaths();
/**
* @brief Slot: called when the current index of the number of threads to be used has changed
*
* @param idx index of the comboBox
*/
void numberOfThreadsChanged(int idx);
private:
PAdmin *fAdmin; ///< Pointer to global administration object storing all preferences.
};
+5
View File
@@ -2273,6 +2273,11 @@ void PTextEdit::musrFit()
cmd.append("--yaml");
}
// check how many threads to be used
cmd.append("--use-no-of-threads");
QString noThreads = QString("%1").arg(fAdmin->getNoOfThreadsToBeUsed());
cmd.append(noThreads);
// check per-run-block-chisq flag
if (fAdmin->getChisqPerRunBlockFlag()) {
cmd.append("--per-run-block-chisq");
@@ -3,7 +3,7 @@
<class>PPrefsDialog</class>
<widget class="QDialog" name="PPrefsDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
<enum>Qt::WindowModality::WindowModal</enum>
</property>
<property name="geometry">
<rect>
@@ -26,13 +26,13 @@
<item>
<widget class="QTabWidget" name="fTabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="fGeneral_tab">
<attribute name="title">
<string>general</string>
</attribute>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>11</x>
@@ -57,7 +57,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -97,7 +97,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -117,7 +117,7 @@
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -225,6 +225,28 @@
<string>yaml out</string>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>291</width>
<height>34</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QComboBox" name="fNumberOfThreads_comboBox"/>
</item>
<item>
<widget class="QLabel" name="fNumberOfThreads_label">
<property name="text">
<string># threads to be used</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="fMusrview_tab">
<attribute name="title">
@@ -302,7 +324,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -15,6 +15,7 @@
<chisq_per_run_block>n</chisq_per_run_block>
<estimate_n0>y</estimate_n0>
<yaml_out>n</yaml_out>
<use_no_of_threads>1024</use_no_of_threads>
<musrview_show_fourier>n</musrview_show_fourier>
<musrview_show_avg>n</musrview_show_avg>
<musrview_show_one_to_one>n</musrview_show_one_to_one>