From 5694d43eded9f40d2e58ded7cd1fcce19a2fcaca Mon Sep 17 00:00:00 2001 From: Markus Holzer <markus.holzer@fau.de> Date: Wed, 6 Dec 2023 11:37:54 +0100 Subject: [PATCH] Use omp_get_max_threads in performance evaluation --- .../evaluation/PerformanceEvaluation.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/lbm_generated/evaluation/PerformanceEvaluation.h b/src/lbm_generated/evaluation/PerformanceEvaluation.h index 9fb7e934a..36f112ac3 100644 --- a/src/lbm_generated/evaluation/PerformanceEvaluation.h +++ b/src/lbm_generated/evaluation/PerformanceEvaluation.h @@ -24,6 +24,7 @@ #include "core/DataTypes.h" #include "core/Hostname.h" #include "core/Set.h" +#include "core/OpenMP.h" #include "core/waLBerlaBuildInfo.h" #include "core/debug/CheckFunctions.h" #include "core/logging/Logging.h" @@ -223,10 +224,17 @@ PerformanceEvaluationBase< CellCounter_T, FluidCellCounter_T >::PerformanceEvalu fluidCells_( fluidCellCounter ) { #ifdef _OPENMP - if( std::getenv( "OMP_NUM_THREADS" ) == NULL ) - WALBERLA_ABORT( "If you are using a version of the program that was compiled with OpenMP you have to " - "specify the environment variable \'OMP_NUM_THREADS\' accordingly!" ); - threadsPerProcess_ = std::atoi( std::getenv( "OMP_NUM_THREADS" ) ); + if( std::getenv( "OMP_NUM_THREADS" ) ) + { + threadsPerProcess_ = std::atoi( std::getenv( "OMP_NUM_THREADS" ) ); + } + else + { + WALBERLA_LOG_WARNING( "You are using a version of the program that was compiled with OpenMP and the environment " + "variable \'OMP_NUM_THREADS\' was not set!\nThe number of threads will now determined with " + "\'omp_get_max_threads\'.\nIf this not correct in your case please set \'OMP_NUM_THREADS\'" ); + threadsPerProcess_ = omp_get_max_threads(); + } #endif if( std::getenv( "THREADS_PER_CORE" ) ) @@ -256,7 +264,7 @@ std::string PerformanceEvaluationBase< CellCounter_T, FluidCellCounter_T >::logg { std::ostringstream oss; - std::string na( "n/a *)" ); + const std::string na( "n/a *)" ); std::ostringstream threadsPerCoreString; threadsPerCoreString << threadsPerCore_; -- GitLab