Skip to content

Commit

Permalink
Use omp_get_max_active_levels() when supported
Browse files Browse the repository at this point in the history
  • Loading branch information
masterleinad committed Dec 13, 2023
1 parent 24b6484 commit a996c12
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/src/OpenMP/Kokkos_OpenMP_Instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ namespace Kokkos {
namespace Impl {

inline bool execute_in_serial(OpenMP const& space = OpenMP()) {
return (OpenMP::in_parallel(space) &&
!(omp_get_nested() && (omp_get_level() == 1)));
return (OpenMP::in_parallel(space) && !(
#if _OPENMP >= 201511
(omp_get_max_active_levels() > 1)
#else
omp_get_nested()
#endif
&& (omp_get_level() == 1)));
}

} // namespace Impl
Expand Down

0 comments on commit a996c12

Please sign in to comment.