Skip to content

Commit

Permalink
Merge pull request kokkos#7174 from rgayatri23/ompt_lock_code_delete
Browse files Browse the repository at this point in the history
OpenMPTarget: Delete ununsed code.
  • Loading branch information
dalg24 authored Jul 31, 2024
2 parents e933bfd + c8c6ae9 commit dbb0abb
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 45 deletions.
40 changes: 0 additions & 40 deletions core/src/OpenMPTarget/Kokkos_OpenMPTarget_Exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ void OpenMPTargetExec::verify_initialized(const char* const label) {

void* OpenMPTargetExec::m_scratch_ptr = nullptr;
int64_t OpenMPTargetExec::m_scratch_size = 0;
int* OpenMPTargetExec::m_lock_array = nullptr;
uint64_t OpenMPTargetExec::m_lock_size = 0;
uint32_t* OpenMPTargetExec::m_uniquetoken_ptr = nullptr;
int OpenMPTargetExec::MAX_ACTIVE_THREADS = 0;
std::mutex OpenMPTargetExec::m_mutex_scratch_ptr;
Expand All @@ -84,15 +82,6 @@ void OpenMPTargetExec::clear_scratch() {
m_scratch_size = 0;
}

void OpenMPTargetExec::clear_lock_array() {
if (m_lock_array != nullptr) {
Kokkos::Experimental::OpenMPTargetSpace space;
space.deallocate(m_lock_array, m_lock_size);
m_lock_array = nullptr;
m_lock_size = 0;
}
}

void* OpenMPTargetExec::get_scratch_ptr() { return m_scratch_ptr; }

void OpenMPTargetExec::resize_scratch(int64_t team_size, int64_t shmem_size_L0,
Expand Down Expand Up @@ -135,35 +124,6 @@ void OpenMPTargetExec::resize_scratch(int64_t team_size, int64_t shmem_size_L0,
}
}

int* OpenMPTargetExec::get_lock_array(int num_teams) {
Kokkos::Experimental::OpenMPTargetSpace space;
int max_active_league_size = MAX_ACTIVE_THREADS / 32;
int lock_array_elem =
(num_teams > max_active_league_size) ? num_teams : max_active_league_size;
if (m_lock_size < (lock_array_elem * sizeof(int))) {
space.deallocate(m_lock_array, m_lock_size);
m_lock_size = lock_array_elem * sizeof(int);
m_lock_array = static_cast<int*>(space.allocate(m_lock_size));

// FIXME_OPENMPTARGET - Creating a target region here to initialize the
// lock_array with 0's fails. Hence creating an equivalent host array to
// achieve the same. Value of host array are then copied to the lock_array.
int* h_lock_array = static_cast<int*>(
omp_target_alloc(m_lock_size, omp_get_initial_device()));

for (int i = 0; i < lock_array_elem; ++i) h_lock_array[i] = 0;

if (0 < m_lock_size)
KOKKOS_IMPL_OMPT_SAFE_CALL(omp_target_memcpy(
m_lock_array, h_lock_array, m_lock_size, 0, 0,
omp_get_default_device(), omp_get_initial_device()));

omp_target_free(h_lock_array, omp_get_initial_device());
}

return m_lock_array;
}

} // namespace Impl
} // namespace Kokkos

Expand Down
1 change: 0 additions & 1 deletion core/src/OpenMPTarget/Kokkos_OpenMPTarget_Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ void OpenMPTargetInternal::print_configuration(std::ostream& os,
void OpenMPTargetInternal::impl_finalize() {
m_is_initialized = false;
Kokkos::Impl::OpenMPTargetExec space;
if (space.m_lock_array != nullptr) space.clear_lock_array();

if (space.m_uniquetoken_ptr != nullptr)
Kokkos::kokkos_free<Kokkos::Experimental::OpenMPTargetSpace>(
Expand Down
4 changes: 0 additions & 4 deletions core/src/OpenMPTarget/Kokkos_OpenMPTarget_Parallel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,19 +765,15 @@ class OpenMPTargetExec {
static void verify_is_process(const char* const);
static void verify_initialized(const char* const);

static int* get_lock_array(int num_teams);
static void* get_scratch_ptr();
static void clear_scratch();
static void clear_lock_array();
static void resize_scratch(int64_t team_reduce_bytes,
int64_t team_shared_bytes,
int64_t thread_local_bytes, int64_t league_size);

static void* m_scratch_ptr;
static std::mutex m_mutex_scratch_ptr;
static int64_t m_scratch_size;
static int* m_lock_array;
static uint64_t m_lock_size;
static uint32_t* m_uniquetoken_ptr;
};

Expand Down

0 comments on commit dbb0abb

Please sign in to comment.