Skip to content

[libc] Use __builtin_ffsll for RPC lane mask #85000

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

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

petrhosek
Copy link
Member

src/__support/GPU/utils.h doesn't compile on a 32-bit platforms because __builtin_ffsl uses long which is a 32-bit number. Use __builtin_ffsll which uses long long which is guaranteed to be at least 64-bits.

src/__support/GPU/utils.h doesn't compile on a 32-bit platforms because
__builtin_ffsl uses long which is a 32-bit number. Use __builtin_ffsll
which uses long long which is guaranteed to be at least 64-bits.
@petrhosek petrhosek added the libc label Mar 13, 2024
@petrhosek petrhosek requested a review from jhuber6 March 13, 2024 00:16
@llvmbot
Copy link
Member

llvmbot commented Mar 13, 2024

@llvm/pr-subscribers-libc

Author: Petr Hosek (petrhosek)

Changes

src/__support/GPU/utils.h doesn't compile on a 32-bit platforms because __builtin_ffsl uses long which is a 32-bit number. Use __builtin_ffsll which uses long long which is guaranteed to be at least 64-bits.


Full diff: https://github.com/llvm/llvm-project/pull/85000.diff

1 Files Affected:

  • (modified) libc/src/__support/GPU/utils.h (+1-1)
diff --git a/libc/src/__support/GPU/utils.h b/libc/src/__support/GPU/utils.h
index 0f9167cdee0663..45523f88f917f7 100644
--- a/libc/src/__support/GPU/utils.h
+++ b/libc/src/__support/GPU/utils.h
@@ -23,7 +23,7 @@ namespace LIBC_NAMESPACE {
 namespace gpu {
 /// Get the first active thread inside the lane.
 LIBC_INLINE uint64_t get_first_lane_id(uint64_t lane_mask) {
-  return __builtin_ffsl(lane_mask) - 1;
+  return __builtin_ffsll(lane_mask) - 1;
 }
 
 /// Conditional that is only true for a single thread in a lane.

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, maybe some day we'll have a 32-bit process communicating with some embedded magic using this interface. Theoretically the rpc code can be used for communication between anything that atomically shares an address space.

@petrhosek petrhosek merged commit c6a93fe into llvm:main Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants