Skip to content

Commit

Permalink
Merge branch 'holzer-master-patch-90858' into 'master'
Browse files Browse the repository at this point in the history
Use omp_get_max_threads in performance evaluation

See merge request walberla/walberla!640
  • Loading branch information
Philipp Suffa committed Dec 6, 2023
2 parents 33af399 + 5694d43 commit 6a3dd3f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/lbm_generated/evaluation/PerformanceEvaluation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" ) )
Expand Down Expand Up @@ -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_;
Expand Down

0 comments on commit 6a3dd3f

Please sign in to comment.