Skip to content

Commit

Permalink
Merge pull request #5915 from dalg24/drop_host_lock_arrays
Browse files Browse the repository at this point in the history
Drop legacy host lock arrays
  • Loading branch information
dalg24 authored Feb 27, 2023
2 parents c5fe10e + cba99e8 commit 1d08f6f
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 211 deletions.
35 changes: 0 additions & 35 deletions core/src/Kokkos_HBWSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,6 @@ namespace Kokkos {

namespace Experimental {

namespace Impl {

/// \brief Initialize lock array for arbitrary size atomics.
///
/// Arbitrary atomics are implemented using a hash table of locks
/// where the hash value is derived from the address of the
/// object for which an atomic operation is performed.
/// This function initializes the locks to zero (unset).
void init_lock_array_hbw_space();

/// \brief Acquire a lock for the address
///
/// This function tries to acquire the lock for the hash value derived
/// from the provided ptr. If the lock is successfully acquired the
/// function returns true. Otherwise it returns false.
bool lock_address_hbw_space(void* ptr);

/// \brief Release lock for the address
///
/// This function releases the lock for the hash value derived
/// from the provided ptr. This function should only be called
/// after previously successfully acquiring a lock with
/// lock_address.
void unlock_address_hbw_space(void* ptr);

} // namespace Impl

} // namespace Experimental

} // namespace Kokkos

namespace Kokkos {

namespace Experimental {

/// \class HBWSpace
/// \brief Memory management for host memory.
///
Expand Down
31 changes: 0 additions & 31 deletions core/src/Kokkos_HostSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,6 @@ static_assert(false,

/*--------------------------------------------------------------------------*/

namespace Kokkos {

namespace Impl {

/// \brief Initialize lock array for arbitrary size atomics.
///
/// Arbitrary atomics are implemented using a hash table of locks
/// where the hash value is derived from the address of the
/// object for which an atomic operation is performed.
/// This function initializes the locks to zero (unset).
void init_lock_array_host_space();

/// \brief Acquire a lock for the address
///
/// This function tries to acquire the lock for the hash value derived
/// from the provided ptr. If the lock is successfully acquired the
/// function returns true. Otherwise it returns false.
bool lock_address_host_space(void* ptr);

/// \brief Release lock for the address
///
/// This function releases the lock for the hash value derived
/// from the provided ptr. This function should only be called
/// after previously successfully acquiring a lock with
/// lock_address.
void unlock_address_host_space(void* ptr);

} // namespace Impl

} // namespace Kokkos

namespace Kokkos {
/// \class HostSpace
/// \brief Memory management for host memory.
Expand Down
2 changes: 0 additions & 2 deletions core/src/OpenMP/Kokkos_OpenMP_Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,6 @@ void OpenMPInternal::initialize(int thread_count) {
std::cerr << " Requested: "
<< thread_count << " threads per process." << std::endl;
}
// Init the array used for arbitrarily sized atomics
init_lock_array_host_space();

m_initialized = true;
}
Expand Down
33 changes: 0 additions & 33 deletions core/src/OpenMPTarget/Kokkos_OpenMPTargetSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,39 +165,6 @@ SharedAllocationRecord<Kokkos::Experimental::OpenMPTargetSpace, void>::
} // namespace Impl
} // namespace Kokkos

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/*
namespace Kokkos {
namespace {
const unsigned HOST_SPACE_ATOMIC_MASK = 0xFFFF;
const unsigned HOST_SPACE_ATOMIC_XOR_MASK = 0x5A39;
static int HOST_SPACE_ATOMIC_LOCKS[HOST_SPACE_ATOMIC_MASK+1];
}
namespace Impl {
void init_lock_array_host_space() {
static int is_initialized = 0;
if(! is_initialized)
for(int i = 0; i < static_cast<int> (HOST_SPACE_ATOMIC_MASK+1); i++)
HOST_SPACE_ATOMIC_LOCKS[i] = 0;
}
bool lock_address_host_space(void* ptr) {
return 0 == atomic_compare_exchange( &HOST_SPACE_ATOMIC_LOCKS[
(( size_t(ptr) >> 2 ) & HOST_SPACE_ATOMIC_MASK) ^
HOST_SPACE_ATOMIC_XOR_MASK] , 0 , 1);
}
void unlock_address_host_space(void* ptr) {
atomic_exchange( &HOST_SPACE_ATOMIC_LOCKS[
(( size_t(ptr) >> 2 ) & HOST_SPACE_ATOMIC_MASK) ^
HOST_SPACE_ATOMIC_XOR_MASK] , 0);
}
}
}*/

//==============================================================================
// <editor-fold desc="Explicit instantiations of CRTP Base classes"> {{{1

Expand Down
31 changes: 0 additions & 31 deletions core/src/OpenMPTarget/Kokkos_OpenMPTargetSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,6 @@ static_assert(false,
#include <Kokkos_HostSpace.hpp>
#include <omp.h>

/*--------------------------------------------------------------------------*/

namespace Kokkos {
namespace Impl {

/// \brief Initialize lock array for arbitrary size atomics.
///
/// Arbitrary atomics are implemented using a hash table of locks
/// where the hash value is derived from the address of the
/// object for which an atomic operation is performed.
/// This function initializes the locks to zero (unset).
// void init_lock_array_host_space();

/// \brief Acquire a lock for the address
///
/// This function tries to acquire the lock for the hash value derived
/// from the provided ptr. If the lock is successfully acquired the
/// function returns true. Otherwise it returns false.
// bool lock_address_host_space(void* ptr);

/// \brief Release lock for the address
///
/// This function releases the lock for the hash value derived
/// from the provided ptr. This function should only be called
/// after previously successfully acquiring a lock with
/// lock_address.
// void unlock_address_host_space(void* ptr);

} // namespace Impl
} // namespace Kokkos

namespace Kokkos {
namespace Impl {

Expand Down
3 changes: 0 additions & 3 deletions core/src/Serial/Kokkos_Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ void SerialInternal::initialize() {

Impl::SharedAllocationRecord<void, void>::tracking_enable();

// Init the array of locks used for arbitrarily sized atomics
Impl::init_lock_array_host_space();

m_is_initialized = true;
}

Expand Down
3 changes: 0 additions & 3 deletions core/src/Threads/Kokkos_ThreadsExec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,9 +768,6 @@ void ThreadsExec::initialize(int thread_count_arg) {
<< thread_count << " threads per process." << std::endl;
}

// Init the array for used for arbitrarily sized atomics
Impl::init_lock_array_host_space();

Impl::SharedAllocationRecord<void, void>::tracking_enable();
}

Expand Down
37 changes: 0 additions & 37 deletions core/src/impl/Kokkos_HBWSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,41 +310,4 @@ void SharedAllocationRecord<Kokkos::Experimental::HBWSpace, void>::
} // namespace Impl
} // namespace Kokkos

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

namespace Kokkos {
namespace Experimental {
namespace {
const unsigned HBW_SPACE_ATOMIC_MASK = 0xFFFF;
const unsigned HBW_SPACE_ATOMIC_XOR_MASK = 0x5A39;
static int HBW_SPACE_ATOMIC_LOCKS[HBW_SPACE_ATOMIC_MASK + 1];
} // namespace

namespace Impl {
void init_lock_array_hbw_space() {
static int is_initialized = 0;
if (!is_initialized)
for (int i = 0; i < static_cast<int>(HBW_SPACE_ATOMIC_MASK + 1); i++)
HBW_SPACE_ATOMIC_LOCKS[i] = 0;
}

bool lock_address_hbw_space(void *ptr) {
return 0 == atomic_compare_exchange(
&HBW_SPACE_ATOMIC_LOCKS[((size_t(ptr) >> 2) &
HBW_SPACE_ATOMIC_MASK) ^
HBW_SPACE_ATOMIC_XOR_MASK],
0, 1);
}

void unlock_address_hbw_space(void *ptr) {
atomic_exchange(
&HBW_SPACE_ATOMIC_LOCKS[((size_t(ptr) >> 2) & HBW_SPACE_ATOMIC_MASK) ^
HBW_SPACE_ATOMIC_XOR_MASK],
0);
}

} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif
36 changes: 0 additions & 36 deletions core/src/impl/Kokkos_HostSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,42 +284,6 @@ SharedAllocationRecord<Kokkos::HostSpace, void>::SharedAllocationRecord(
} // namespace Impl
} // namespace Kokkos

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

namespace Kokkos {
namespace {
const unsigned HOST_SPACE_ATOMIC_MASK = 0xFFFF;
const unsigned HOST_SPACE_ATOMIC_XOR_MASK = 0x5A39;
static int HOST_SPACE_ATOMIC_LOCKS[HOST_SPACE_ATOMIC_MASK + 1];
} // namespace

namespace Impl {
void init_lock_array_host_space() {
static int is_initialized = 0;
if (!is_initialized)
for (int i = 0; i < static_cast<int>(HOST_SPACE_ATOMIC_MASK + 1); i++)
HOST_SPACE_ATOMIC_LOCKS[i] = 0;
}

bool lock_address_host_space(void *ptr) {
return 0 == atomic_compare_exchange(
&HOST_SPACE_ATOMIC_LOCKS[((size_t(ptr) >> 2) &
HOST_SPACE_ATOMIC_MASK) ^
HOST_SPACE_ATOMIC_XOR_MASK],
0, 1);
}

void unlock_address_host_space(void *ptr) {
atomic_exchange(
&HOST_SPACE_ATOMIC_LOCKS[((size_t(ptr) >> 2) & HOST_SPACE_ATOMIC_MASK) ^
HOST_SPACE_ATOMIC_XOR_MASK],
0);
}

} // namespace Impl
} // namespace Kokkos

//==============================================================================
// <editor-fold desc="Explicit instantiations of CRTP Base classes"> {{{1

Expand Down

0 comments on commit 1d08f6f

Please sign in to comment.