Skip to content

Commit

Permalink
Address DLG comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpowelsnl committed Jan 17, 2024
1 parent 004b5cd commit 1c7131b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 19 deletions.
5 changes: 3 additions & 2 deletions core/src/HPX/Kokkos_HPX.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,13 +1293,14 @@ class ParallelScan<FunctorType, Kokkos::RangePolicy<Traits...>,
execute_chunk(range.begin(), range.end(), update_sum, false);

{
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
// Since arrive_and_wait may yield and resume on another worker thread we
// set in_parallel = false on the current thread before suspending and set
// it again to true when we resume.
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
Kokkos::Experimental::HPX::impl_not_in_parallel_scope p;
#endif
#else
barrier.arrive_and_wait();
#endif
}

if (t == 0) {
Expand Down
7 changes: 4 additions & 3 deletions core/src/OpenMP/Kokkos_OpenMP_Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,12 @@ void OpenMPInternal::initialize(int thread_count) {
Kokkos::abort(
"Calling OpenMP::initialize after OpenMP::finalize is illegal\n");
}

#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
if (omp_in_parallel()) {
std::string msg("Kokkos::OpenMP::initialize ERROR : in parallel");
Kokkos::Impl::throw_runtime_exception(msg);
}
#endif

{
if (Kokkos::show_warnings() && !std::getenv("OMP_PROC_BIND")) {
Expand Down Expand Up @@ -276,15 +277,15 @@ void OpenMPInternal::initialize(int thread_count) {

m_initialized = true;
}

void OpenMPInternal::finalize() {
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
if (omp_in_parallel()) {
std::string msg("Kokkos::OpenMP::finalize ERROR ");
if (this != &singleton()) msg.append(": not initialized");
if (omp_in_parallel()) msg.append(": in parallel");
Kokkos::Impl::throw_runtime_exception(msg);
}

#endif
if (this == &singleton()) {
auto const &instance = singleton();
// Silence Cuda Warning
Expand Down
2 changes: 2 additions & 0 deletions core/src/OpenMP/Kokkos_OpenMP_Instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ inline bool execute_in_serial(OpenMP const& space = OpenMP()) {
#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
Expand Down
2 changes: 2 additions & 0 deletions core/unit_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -709,12 +709,14 @@ if(Kokkos_ENABLE_HPX)
hpx/TestHPX_IndependentInstancesRefCounting.cpp
hpx/TestHPX_IndependentInstancesSynchronization.cpp
)
if(Kokkos_ENABLE_DEPRECATED_CODE_4)
KOKKOS_ADD_EXECUTABLE_AND_TEST(
CoreUnitTest_HPX_InParallel
SOURCES
UnitTestMainInit.cpp
hpx/TestHPX_InParallel.cpp
)
endif()
endif()

if(Kokkos_ENABLE_OPENMPTARGET)
Expand Down
12 changes: 1 addition & 11 deletions core/unit_test/TestExecutionSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,7 @@ struct CheckClassWithExecutionSpaceAsDataMemberIsCopyable {
Kokkos::DefaultExecutionSpace device;
Kokkos::DefaultHostExecutionSpace host;

KOKKOS_FUNCTION void operator()(int, int& e) const {
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
// not actually doing anything useful, mostly checking that
// ExecutionSpace::in_parallel() is callable
if (static_cast<int>(device.in_parallel()) < 0) {
++e;
}
#else
e = 0;
#endif
}
KOKKOS_FUNCTION void operator()(int, int& e) const { e += i; }

CheckClassWithExecutionSpaceAsDataMemberIsCopyable() {
int errors;
Expand Down
3 changes: 0 additions & 3 deletions core/unit_test/hpx/TestHPX_InParallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

namespace {

#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4

inline constexpr int n = 1 << 10;

TEST(hpx, in_parallel_for_range_policy) {
Expand Down Expand Up @@ -183,5 +181,4 @@ TEST(hpx, in_parallel_scan_range_policy) {
ASSERT_EQ(a(i), 0);
}
}
#endif
} // namespace

0 comments on commit 1c7131b

Please sign in to comment.