DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
OMP.hpp
Go to the documentation of this file.
1#pragma once
2/// @file OMP.hpp
3/// @brief Helpers for OpenMP thread-count configuration at solver entry points.
4
5#include "Defines.hpp"
6#include "Eigen/src/Core/products/Parallelizer.h"
7
8namespace DNDS::OMP
9{
10 /**
11 * @brief Configure OpenMP and Eigen threading for the "distributed OMP" pattern.
12 *
13 * @details Sets the OpenMP thread count from the @ref DNDS_DIST_OMP_NUM_THREADS
14 * environment variable (falling back to 1) and disables Eigen's internal
15 * parallelism so it does not oversubscribe the MPI+OpenMP layout.
16 *
17 * Intended to be called once near `main()` when @ref DNDS_USE_OMP is on.
18 */
20 {
21#ifdef DNDS_USE_OMP
22 // omp_set_num_threads( // note that the meaning is like "omp_set_max_threads()"
23 // DNDS::MPIWorldSize() == -1
24 // ? std::min(omp_get_num_procs(), omp_get_max_threads())
25 // : (get_env_DNDS_DIST_OMP_NUM_THREADS() == 0 ? 1 : DNDS::get_env_DNDS_DIST_OMP_NUM_THREADS()));
26 omp_set_num_threads(
28#endif
29 Eigen::setNbThreads(1); // ! sets Eigen's multithreading!
30 }
31}
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
void set_full_parallel_OMP()
Configure OpenMP and Eigen threading for the "distributed OMP" pattern.
Definition OMP.hpp:19
int get_env_DNDS_DIST_OMP_NUM_THREADS()
Read the DNDSR-specific DNDS_DIST_OMP_NUM_THREADS override, falling back to get_env_OMP_NUM_THREADS.
Definition Defines.cpp:139