Skip to content

Commit

Permalink
Drop (unused) HBW lock array
Browse files Browse the repository at this point in the history
  • Loading branch information
dalg24 committed Feb 27, 2023
1 parent c5fe10e commit b4655f9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 72 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
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

0 comments on commit b4655f9

Please sign in to comment.