Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix in packed bool compare & swap #4814

Merged
merged 13 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2024, NVIDIA CORPORATION.
* Copyright (c) 2022-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -138,9 +138,16 @@ class edge_partition_edge_property_device_view_t {
{
if constexpr (has_packed_bool_element) {
static_assert(is_packed_bool, "unimplemented for thrust::tuple types.");
cuda::atomic_ref<uint32_t, cuda::thread_scope_device> word(
*(value_first_ + cugraph::packed_bool_offset(offset)));
auto mask = cugraph::packed_bool_mask(offset);
auto old = val ? atomicOr(value_first_ + cugraph::packed_bool_offset(offset), mask)
: atomicAnd(value_first_ + cugraph::packed_bool_offset(offset), ~mask);
uint32_t old{};
if (compare == val) {
old = word.load(cuda::std::memory_order_relaxed);
} else {
old = val ? word.fetch_or(mask, cuda::std::memory_order_relaxed)
: word.fetch_and(~mask, cuda::std::memory_order_relaxed);
}
return static_cast<bool>(old & mask);
} else {
return cugraph::elementwise_atomic_cas(value_first_ + offset, compare, val);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024, NVIDIA CORPORATION.
* Copyright (c) 2021-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -145,9 +145,16 @@ class edge_partition_endpoint_property_device_view_t {
auto val_offset = value_offset(offset);
if constexpr (has_packed_bool_element) {
static_assert(is_packed_bool, "unimplemented for thrust::tuple types.");
cuda::atomic_ref<uint32_t, cuda::thread_scope_device> word(
*(value_first_ + cugraph::packed_bool_offset(val_offset)));
auto mask = cugraph::packed_bool_mask(val_offset);
auto old = val ? atomicOr(value_first_ + cugraph::packed_bool_offset(val_offset), mask)
: atomicAnd(value_first_ + cugraph::packed_bool_offset(val_offset), ~mask);
uint32_t old{};
if (compare == val) {
old = word.load(cuda::std::memory_order_relaxed);
} else {
old = val ? word.fetch_or(mask, cuda::std::memory_order_relaxed)
: word.fetch_and(~mask, cuda::std::memory_order_relaxed);
}
return static_cast<bool>(old & mask);
} else {
return cugraph::elementwise_atomic_cas(value_first_ + val_offset, compare, val);
Expand Down
Loading