use ccQtHelpers::GetMaxThreadCount

This commit is contained in:
Paul Leroy
2024-02-13 09:22:50 +01:00
parent 858c04522a
commit 11ed7bd843
4 changed files with 18 additions and 7 deletions
+4 -1
View File
@@ -23,6 +23,9 @@
//qCC_db
#include <ccScalarField.h>
//CCPluginAPI
#include <ccQtHelpers.h>
//Qt
#include <QMutex>
@@ -194,7 +197,7 @@ bool ContextBasedFeature::prepare( const CorePoints& corePoints,
bool cancelled = false;
#ifndef _DEBUG
#if defined(_OPENMP)
#pragma omp parallel for num_threads(std::max(1, omp_get_max_threads() - 2))
#pragma omp parallel for num_threads(ccQtHelpers::GetMaxThreadCount(omp_get_max_threads()))
#endif
#endif
for (int i = 0; i < static_cast<int>(pointCount); ++i)
+4 -1
View File
@@ -89,6 +89,9 @@ constexpr const char* LAS_FIELD_NAMES[22] = {"X",
//CCLib
#include <WeibullDistribution.h>
//CCPluginAPI
#include <ccQtHelpers.h>
//system
#include <assert.h>
@@ -424,7 +427,7 @@ static bool ComputeMathOpWithNearestNeighbor( const CorePoints& corePoints,
error.clear();
#ifndef _DEBUG
#if defined(_OPENMP)
#pragma omp parallel for num_threads(std::max(1, omp_get_max_threads() - 2))
#pragma omp parallel for num_threads(ccQtHelpers::GetMaxThreadCount(omp_get_max_threads()))
#endif
#endif
for (int i = 0; i < static_cast<int>(pointCount); ++i)
+3 -2
View File
@@ -30,8 +30,9 @@
//qPDALIO
#include "../../../core/IO/qPDALIO/include/LASFields.h"
//qCC_plugins
//CCPluginAPI
#include <ccMainAppInterface.h>
#include <ccQtHelpers.h>
//Qt
#include <QCoreApplication>
@@ -209,7 +210,7 @@ bool Classifier::classify( const Feature::Source::Set& featureSources,
int numberOfTrees = static_cast<int>(m_rtrees->getRoots().size());
#ifndef _DEBUG
#if defined(_OPENMP)
#pragma omp parallel for num_threads(std::max(1, omp_get_max_threads() - 2))
#pragma omp parallel for num_threads(ccQtHelpers::GetMaxThreadCount(omp_get_max_threads()))
#endif
#endif
for (int i = 0; i < static_cast<int>(cloud->size()); ++i)
+7 -3
View File
@@ -30,6 +30,9 @@
#include <ccScalarField.h>
#include <ccPointCloud.h>
//CCPluginAPI
#include <ccQtHelpers.h>
//qPDALIO
#include "../../../core/IO/qPDALIO/include/LASFields.h"
@@ -1229,15 +1232,16 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
progressCb->setMethodTitle("Compute features");
progressCb->setInfo(qPrintable(logMessage));
}
ccLog::Print(logMessage + " , nb threads " + QString::number(omp_get_max_threads() - 2) + ", nb points " + QString::number(pointCount));
ccLog::Print(logMessage + ", nb points " + QString::number(pointCount));
CCCoreLib::NormalizedProgress nProgress(progressCb, pointCount);
nProgress.reset();
QMutex mutex;
#ifndef _DEBUG
#if defined(_OPENMP)
#pragma omp parallel for num_threads(std::max(1, omp_get_max_threads() - 2))
int num_threads = ccQtHelpers::GetMaxThreadCount(omp_get_max_threads());
ccLog::Print("Using OpenMP with " + QString::number(num_threads) + " threads ");
#pragma omp parallel for num_threads(num_threads)
#endif
#endif
for (int i = 0; i < static_cast<int>(pointCount); ++i)