diff --git a/core/src/HPX/Kokkos_HPX.hpp b/core/src/HPX/Kokkos_HPX.hpp index 81ad696bdcf..c163e89e886 100644 --- a/core/src/HPX/Kokkos_HPX.hpp +++ b/core/src/HPX/Kokkos_HPX.hpp @@ -1293,13 +1293,14 @@ class ParallelScan, 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) { diff --git a/core/src/OpenMP/Kokkos_OpenMP_Instance.cpp b/core/src/OpenMP/Kokkos_OpenMP_Instance.cpp index 32172fbc6c7..a7e672cb0f1 100644 --- a/core/src/OpenMP/Kokkos_OpenMP_Instance.cpp +++ b/core/src/OpenMP/Kokkos_OpenMP_Instance.cpp @@ -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")) { @@ -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 diff --git a/core/src/OpenMP/Kokkos_OpenMP_Instance.hpp b/core/src/OpenMP/Kokkos_OpenMP_Instance.hpp index dc7e7339633..2ccd065edf1 100644 --- a/core/src/OpenMP/Kokkos_OpenMP_Instance.hpp +++ b/core/src/OpenMP/Kokkos_OpenMP_Instance.hpp @@ -53,7 +53,9 @@ inline bool execute_in_serial(OpenMP const& space = OpenMP()) { #else bool is_nested = static_cast(omp_get_nested()); #endif +#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4 return (OpenMP::in_parallel(space) && !(is_nested && (omp_get_level() == 1))); +#endif } } // namespace Impl diff --git a/core/unit_test/CMakeLists.txt b/core/unit_test/CMakeLists.txt index 7bbf72c2533..6c44d0e5621 100644 --- a/core/unit_test/CMakeLists.txt +++ b/core/unit_test/CMakeLists.txt @@ -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) diff --git a/core/unit_test/TestExecutionSpace.hpp b/core/unit_test/TestExecutionSpace.hpp index 95fe6e59c22..4b3377a39d4 100644 --- a/core/unit_test/TestExecutionSpace.hpp +++ b/core/unit_test/TestExecutionSpace.hpp @@ -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(device.in_parallel()) < 0) { - ++e; - } -#else - e = 0; -#endif - } + KOKKOS_FUNCTION void operator()(int, int& e) const { e += i; } CheckClassWithExecutionSpaceAsDataMemberIsCopyable() { int errors; diff --git a/core/unit_test/hpx/TestHPX_InParallel.cpp b/core/unit_test/hpx/TestHPX_InParallel.cpp index 6d12cf69912..ed3308e54b7 100644 --- a/core/unit_test/hpx/TestHPX_InParallel.cpp +++ b/core/unit_test/hpx/TestHPX_InParallel.cpp @@ -24,8 +24,6 @@ namespace { -#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4 - inline constexpr int n = 1 << 10; TEST(hpx, in_parallel_for_range_policy) { @@ -183,5 +181,4 @@ TEST(hpx, in_parallel_scan_range_policy) { ASSERT_EQ(a(i), 0); } } -#endif } // namespace