Skip to content

Commit

Permalink
Use spin
Browse files Browse the repository at this point in the history
  • Loading branch information
PointKernel committed Nov 9, 2023
1 parent d04d99f commit 9c88b68
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions include/cuco/detail/open_addressing/open_addressing_ref_impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,8 @@ class open_addressing_ref_impl {
{
using mapped_type = decltype(this->empty_slot_sentinel_.second);

auto const expected_key = expected.first;
auto const expected_key = expected.first;
auto const expected_payload = expected.second;

auto old_key = compare_and_swap(
&address->first, expected_key, static_cast<key_type>(thrust::get<0>(desired)));
Expand All @@ -1009,7 +1010,14 @@ class open_addressing_ref_impl {

// if key success
if (cuco::detail::bitwise_compare(*old_key_ptr, expected_key)) {
atomic_store(&address->second, static_cast<mapped_type>(thrust::get<1>(desired)));
auto ref = cuda::atomic<mapped_type, cuda::thread_scope_system>{address->second};
ref.store(static_cast<mapped_type>(thrust::get<1>(desired)), cuda::std::memory_order_relaxed);

mapped_type old;
do {
old = ref.load(cuda::std::memory_order_relaxed);
} while (cuco::detail::bitwise_compare(old, expected_payload));

return insert_result::SUCCESS;
}

Expand Down

0 comments on commit 9c88b68

Please sign in to comment.