Is cuda::std::bitset designed to be thread-safe?
#4917
-
|
I might have encountered data racing during __global__ void func(
cuda::std::bitset<SOME_SIZE>* bitset_ptr,
size_t pos
) {
...
size_t SOME_POS = 6;
bitset_ptr->set(dst);
if (!bitset_ptr->test(dst)) {
printf("dst did not set\n");
}
if (dst == SOME_POS) {
if (!bitset_ptr->test(SOME_POS)) {
printf("SOME_POS did not set\n");
}
printf("check SOME_POS marked: %s\n",
curr_frontier_bitset_ptr->test(SOME_POS) ? "true" : "false"
);
}
}The output could be (shown in my runs): or Even after checking the source code, I could not see a good lock-free method to avoid the racing condition on user side. Is there any good practice on this? |
Beta Was this translation helpful? Give feedback.
Answered by
miscco
Jun 6, 2025
Replies: 1 comment 3 replies
-
|
Unfortunately, this is not unexpected. We cannot add internal locking that would negatively affect performance for common use cases |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Our data structures especially those in
cuda::std::are meant to provide access to familiar C++ features but are still standard conforming. They are also usable on both host and device and can be copied around.Using them does not prevent any data races that would still happen with
std::data structures or even a plain bool array. That is on the user to ensure that there are no racy operations