Skip to content

Commit

Permalink
OpenMP backend cleanup following removal of deprecated code 3
Browse files Browse the repository at this point in the history
  • Loading branch information
dalg24 committed Oct 18, 2023
1 parent 0505ce2 commit ca49c65
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 149 deletions.
15 changes: 0 additions & 15 deletions core/src/OpenMP/Kokkos_OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,13 @@ bool OpenMP::impl_is_initialized() noexcept {
}

bool OpenMP::in_parallel(OpenMP const &exec_space) noexcept {
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
return (
(exec_space.impl_internal_space_instance()->m_level < omp_get_level()) &&
(!Impl::t_openmp_instance ||
Impl::t_openmp_instance->m_level < omp_get_level()));
#else
return exec_space.impl_internal_space_instance()->m_level < omp_get_level();
#endif
}

int OpenMP::impl_thread_pool_size() const noexcept {
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
return OpenMP::in_parallel(*this)
? omp_get_num_threads()
: (Impl::t_openmp_instance
? Impl::t_openmp_instance->m_pool_size
: impl_internal_space_instance()->m_pool_size);
#else
return OpenMP::in_parallel(*this)
? omp_get_num_threads()
: impl_internal_space_instance()->m_pool_size;
#endif
}

int OpenMP::impl_max_hardware_threads() noexcept {
Expand Down
10 changes: 0 additions & 10 deletions core/src/OpenMP/Kokkos_OpenMP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ namespace Kokkos {

namespace Impl {
class OpenMPInternal;

#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
// FIXME_OPENMP we can remove this after we remove partition_master
inline thread_local OpenMPInternal* t_openmp_instance = nullptr;
#endif
} // namespace Impl

/// \class OpenMP
Expand Down Expand Up @@ -156,12 +151,7 @@ class OpenMP {
inline int OpenMP::impl_thread_pool_rank() noexcept {
// FIXME_OPENMP Can we remove this when removing partition_master? It's only
// used in one partition_master test
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
KOKKOS_IF_ON_HOST(
(return Impl::t_openmp_instance ? 0 : omp_get_thread_num();))
#else
KOKKOS_IF_ON_HOST((return omp_get_thread_num();))
#endif

KOKKOS_IF_ON_DEVICE((return -1;))
}
Expand Down
55 changes: 0 additions & 55 deletions core/src/OpenMP/Kokkos_OpenMP_Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,61 +47,6 @@ void OpenMPInternal::release_lock() {
desul::MemoryScopeDevice());
}

#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
void OpenMPInternal::validate_partition_impl(const int nthreads,
int &num_partitions,
int &partition_size) {
if (nthreads == 1) {
num_partitions = 1;
partition_size = 1;
} else if (num_partitions < 1 && partition_size < 1) {
int idle = nthreads;
for (int np = 2; np <= nthreads; ++np) {
for (int ps = 1; ps <= nthreads / np; ++ps) {
if (nthreads - np * ps < idle) {
idle = nthreads - np * ps;
num_partitions = np;
partition_size = ps;
}
if (idle == 0) {
break;
}
}
}
} else if (num_partitions < 1 && partition_size > 0) {
if (partition_size <= nthreads) {
num_partitions = nthreads / partition_size;
} else {
num_partitions = 1;
partition_size = nthreads;
}
} else if (num_partitions > 0 && partition_size < 1) {
if (num_partitions <= nthreads) {
partition_size = nthreads / num_partitions;
} else {
num_partitions = nthreads;
partition_size = 1;
}
} else if (num_partitions * partition_size > nthreads) {
int idle = nthreads;
const int NP = num_partitions;
const int PS = partition_size;
for (int np = NP; np > 0; --np) {
for (int ps = PS; ps > 0; --ps) {
if ((np * ps <= nthreads) && (nthreads - np * ps < idle)) {
idle = nthreads - np * ps;
num_partitions = np;
partition_size = ps;
}
if (idle == 0) {
break;
}
}
}
}
}
#endif

void OpenMPInternal::clear_thread_data() {
const size_t member_bytes =
sizeof(int64_t) *
Expand Down
5 changes: 0 additions & 5 deletions core/src/OpenMP/Kokkos_OpenMP_Instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ class OpenMPInternal {
// Release lock used to protect access to m_pool
void release_lock();

#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
static void validate_partition_impl(const int nthreads, int& num_partitions,
int& partition_size);
#endif

void resize_thread_data(size_t pool_reduce_bytes, size_t team_reduce_bytes,
size_t team_shared_bytes, size_t thread_local_bytes);

Expand Down
25 changes: 1 addition & 24 deletions core/src/OpenMP/Kokkos_OpenMP_Parallel_For.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,7 @@ class ParallelFor<FunctorType, Kokkos::RangePolicy<Traits...>, Kokkos::OpenMP> {

inline ParallelFor(const FunctorType& arg_functor, Policy arg_policy)
: m_instance(nullptr), m_functor(arg_functor), m_policy(arg_policy) {
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
if (t_openmp_instance) {
m_instance = t_openmp_instance;
} else {
m_instance = arg_policy.space().impl_internal_space_instance();
}
#else
m_instance = arg_policy.space().impl_internal_space_instance();
#endif
}
};

Expand Down Expand Up @@ -251,16 +243,9 @@ class ParallelFor<FunctorType, Kokkos::MDRangePolicy<Traits...>,

inline ParallelFor(const FunctorType& arg_functor, MDRangePolicy arg_policy)
: m_instance(nullptr), m_iter(arg_policy, arg_functor) {
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
if (t_openmp_instance) {
m_instance = t_openmp_instance;
} else {
m_instance = arg_policy.space().impl_internal_space_instance();
}
#else
m_instance = arg_policy.space().impl_internal_space_instance();
#endif
}

template <typename Policy, typename Functor>
static int max_tile_size_product(const Policy&, const Functor&) {
/**
Expand Down Expand Up @@ -409,15 +394,7 @@ class ParallelFor<FunctorType, Kokkos::TeamPolicy<Properties...>,
m_shmem_size(arg_policy.scratch_size(0) + arg_policy.scratch_size(1) +
FunctorTeamShmemSize<FunctorType>::value(
arg_functor, arg_policy.team_size())) {
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
if (t_openmp_instance) {
m_instance = t_openmp_instance;
} else {
m_instance = arg_policy.space().impl_internal_space_instance();
}
#else
m_instance = arg_policy.space().impl_internal_space_instance();
#endif
}
};

Expand Down
24 changes: 0 additions & 24 deletions core/src/OpenMP/Kokkos_OpenMP_Parallel_Reduce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,7 @@ class ParallelReduce<CombinedFunctorReducerType, Kokkos::RangePolicy<Traits...>,
m_functor_reducer(arg_functor_reducer),
m_policy(arg_policy),
m_result_ptr(arg_view.data()) {
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
if (t_openmp_instance) {
m_instance = t_openmp_instance;
} else {
m_instance = arg_policy.space().impl_internal_space_instance();
}
#else
m_instance = arg_policy.space().impl_internal_space_instance();
#endif
static_assert(
Kokkos::Impl::MemorySpaceAccess<typename ViewType::memory_space,
Kokkos::HostSpace>::accessible,
Expand Down Expand Up @@ -319,15 +311,7 @@ class ParallelReduce<CombinedFunctorReducerType,
: m_instance(nullptr),
m_iter(arg_policy, arg_functor_reducer),
m_result_ptr(arg_view.data()) {
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
if (t_openmp_instance) {
m_instance = t_openmp_instance;
} else {
m_instance = arg_policy.space().impl_internal_space_instance();
}
#else
m_instance = arg_policy.space().impl_internal_space_instance();
#endif
static_assert(
Kokkos::Impl::MemorySpaceAccess<typename ViewType::memory_space,
Kokkos::HostSpace>::accessible,
Expand Down Expand Up @@ -543,15 +527,7 @@ class ParallelReduce<CombinedFunctorReducerType,
arg_policy.scratch_size(0) + arg_policy.scratch_size(1) +
FunctorTeamShmemSize<FunctorType>::value(
arg_functor_reducer.get_functor(), arg_policy.team_size())) {
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
if (t_openmp_instance) {
m_instance = t_openmp_instance;
} else {
m_instance = arg_policy.space().impl_internal_space_instance();
}
#else
m_instance = arg_policy.space().impl_internal_space_instance();
#endif

static_assert(
Kokkos::Impl::MemorySpaceAccess<typename ViewType::memory_space,
Expand Down
16 changes: 0 additions & 16 deletions core/src/OpenMP/Kokkos_OpenMP_Parallel_Scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,7 @@ class ParallelScan<FunctorType, Kokkos::RangePolicy<Traits...>,

inline ParallelScan(const FunctorType& arg_functor, const Policy& arg_policy)
: m_instance(nullptr), m_functor(arg_functor), m_policy(arg_policy) {
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
if (t_openmp_instance) {
m_instance = t_openmp_instance;
} else {
m_instance = arg_policy.space().impl_internal_space_instance();
}
#else
m_instance = arg_policy.space().impl_internal_space_instance();
#endif
}
};

Expand Down Expand Up @@ -292,15 +284,7 @@ class ParallelScanWithTotal<FunctorType, Kokkos::RangePolicy<Traits...>,
Kokkos::Impl::MemorySpaceAccess<typename ViewType::memory_space,
Kokkos::HostSpace>::accessible,
"Kokkos::OpenMP parallel_scan result must be host-accessible!");
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
if (t_openmp_instance) {
m_instance = t_openmp_instance;
} else {
m_instance = arg_policy.space().impl_internal_space_instance();
}
#else
m_instance = arg_policy.space().impl_internal_space_instance();
#endif
}

//----------------------------------------
Expand Down

0 comments on commit ca49c65

Please sign in to comment.