Skip to content

Commit

Permalink
Addressing final DA comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpowelsnl committed Jan 30, 2024
1 parent 8005783 commit 853313e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
13 changes: 10 additions & 3 deletions core/src/HPX/Kokkos_HPX.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,7 @@ class ParallelScan<FunctorType, Kokkos::RangePolicy<Traits...>,
// set in_parallel = false on the current thread before suspending and set
// it again to true when we resume.
Kokkos::Experimental::HPX::impl_not_in_parallel_scope p;
barrier.arrive_and_wait();
#else
barrier.arrive_and_wait();
#endif
Expand Down Expand Up @@ -1329,8 +1330,10 @@ class ParallelScan<FunctorType, Kokkos::RangePolicy<Traits...>,
// it again to true when we resume.
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
Kokkos::Experimental::HPX::impl_not_in_parallel_scope p;
#endif
barrier.arrive_and_wait();
#else
barrier.arrive_and_wait();
#endif
}

reference_type update_base =
Expand Down Expand Up @@ -1418,8 +1421,10 @@ class ParallelScanWithTotal<FunctorType, Kokkos::RangePolicy<Traits...>,
// it again to true when we resume.
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
Kokkos::Experimental::HPX::impl_not_in_parallel_scope p;
#endif
barrier.arrive_and_wait();
#else
barrier.arrive_and_wait();
#endif
}

if (t == 0) {
Expand Down Expand Up @@ -1448,8 +1453,10 @@ class ParallelScanWithTotal<FunctorType, Kokkos::RangePolicy<Traits...>,
// it again to true when we resume.
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
Kokkos::Experimental::HPX::impl_not_in_parallel_scope p;
#endif
barrier.arrive_and_wait();
#else
barrier.arrive_and_wait();
#endif
}

reference_type update_base =
Expand Down
32 changes: 13 additions & 19 deletions core/src/OpenMP/Kokkos_OpenMP_Instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,6 @@
#include <vector>

/*--------------------------------------------------------------------------*/
namespace Kokkos {
namespace Impl {

inline bool execute_in_serial(OpenMP const& space = OpenMP()) {
// The default value returned by `omp_get_max_active_levels` with gcc version
// lower than 11.1.0 is 2147483647 instead of 1.
#if (!defined(KOKKOS_COMPILER_GNU) || KOKKOS_COMPILER_GNU >= 1110) && \
_OPENMP >= 201511
bool is_nested = omp_get_max_active_levels() > 1;
#else
bool is_nested = static_cast<bool>(omp_get_nested());
#endif
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
return (OpenMP::in_parallel(space) && !(is_nested && (omp_get_level() == 1)));
#endif
}

} // namespace Impl
} // namespace Kokkos

namespace Kokkos {
namespace Impl {
Expand Down Expand Up @@ -128,6 +109,19 @@ class OpenMPInternal {
void print_configuration(std::ostream& s) const;
};

inline bool execute_in_serial(OpenMP const& space = OpenMP()) {
// The default value returned by `omp_get_max_active_levels` with gcc version
// lower than 11.1.0 is 2147483647 instead of 1.
#if (!defined(KOKKOS_COMPILER_GNU) || KOKKOS_COMPILER_GNU >= 1110) && \
_OPENMP >= 201511
bool is_nested = omp_get_max_active_levels() > 1;
#else
bool is_nested = static_cast<bool>(omp_get_nested());
#endif
return (space.impl_internal_space_instance()->get_level() < omp_get_level() &&
!(is_nested && (omp_get_level() == 1)));
}

} // namespace Impl

namespace Experimental {
Expand Down
1 change: 0 additions & 1 deletion core/unit_test/hpx/TestHPX_InParallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
// fence fencing the independent instance. In that case these tests will fail.

namespace {

inline constexpr int n = 1 << 10;

TEST(hpx, in_parallel_for_range_policy) {
Expand Down

0 comments on commit 853313e

Please sign in to comment.