Skip to content

Fix __nv_atomic_load guard from compiler to target based - #7983

Merged
gonidelis merged 7 commits into
NVIDIA:mainfrom
gonidelis:agent_find_sm_guard
Mar 11, 2026
Merged

gonidelis merged 7 commits into
NVIDIA:mainfrom
gonidelis:agent_find_sm_guard

Conversation

@gonidelis

@gonidelis gonidelis commented Mar 11, 2026 •

Copy link
Copy Markdown
Member

fixes #7982

We used a rather modern atomic for our new cub::FindIf agent but we guarded it with merit to the compiler support. That does not suffice though as one might compile for NVCC 12.9 on sm_50 which will throw as per the tracking issue.

We shift to using __CUDACC_DEVICE_ATOMIC_BUILTINS__ which is a flag dedicated to atomic support instead.

@gonidelis
gonidelis requested a review from a team as a code owner March 11, 2026 04:44
@gonidelis
gonidelis requested a review from pauleonix March 11, 2026 04:44
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Mar 11, 2026
@gonidelis
gonidelis enabled auto-merge (squash) March 11, 2026 04:44
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Mar 11, 2026
Comment thread cub/cub/agent/agent_find.cuh Resolved
Comment thread cub/cub/agent/agent_find.cuh Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't we also need to guard the headers here?

@github-actions

This comment has been minimized.

Comment thread cub/cub/agent/agent_find.cuh Resolved
Comment thread cub/cub/agent/agent_find.cuh Resolved
@miscco
miscco requested a review from a team as a code owner March 11, 2026 08:07
Comment thread cub/cub/agent/agent_find.cuh Resolved
@github-project-automation github-project-automation Bot moved this from In Review to In Progress in CCCL Mar 11, 2026
@gonidelis

gonidelis commented Mar 11, 2026 •

Copy link
Copy Markdown
Member Author

since we got to that end why not just guard with the arch number per atomic? What's the point of __CUDACC_DEVICE_ATOMIC_BUILTINS__ even?

i am confused why was the bug disappearing without the extra arch check before? @davebayer

@davebayer

Copy link
Copy Markdown
Contributor

i am confused why was the bug disappearing without the extra arch check before?

Because you had a typo in your implementation and instead of __CUDACC_DEVICE_ATOMIC_BUILTINS__, you were checking for _CUDACC_DEVICE_ATOMIC_BUILTINS__ which was never defined, thus nv atomic builtins were always disabled

@gonidelis

Copy link
Copy Markdown
Member Author

i am confused why was the bug disappearing without the extra arch check before?

Because you had a typo in your implementation and instead of __CUDACC_DEVICE_ATOMIC_BUILTINS__, you were checking for _CUDACC_DEVICE_ATOMIC_BUILTINS__ which was never defined, thus nv atomic builtins were always disabled

so the bug reappeared after we fixed the double underscore thingy?

#endif

// The new __nv_atomic builtins are available when __CUDACC_DEVICE_ATOMIC_BUILTINS__ is defined
#if defined(__CUDACC_DEVICE_ATOMIC_BUILTINS__) && _CCCL_PTX_ARCH() >= 600 && !_CCCL_COMPILER(MSVC)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Q: Why do we need to exclude MSVC here? I had to exclude it only in warpspeed scan because of compiler bugs. It should not generally be disabled IMO.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe for now the appropriate bugfix is to just fix the condition with the macro and then individually enable it for MSVC in a followup PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fine. But we should not forget to enable the built-in atomics for MSVC where they work.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i definitely copied over because of mighty legacy reasons that I wasn't aware

@davebayer

Copy link
Copy Markdown
Contributor

so the bug reappeared after we fixed the double underscore thingy?

I believe so, but I haven't tested it

@github-project-automation github-project-automation Bot moved this from In Progress to In Review in CCCL Mar 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 3h 16m: Pass: 100%/298 | Total: 9d 00h | Max: 3h 16m | Hits: 84%/371333

See results here.

@gonidelis
gonidelis merged commit 73a3fb5 into NVIDIA:main Mar 11, 2026
321 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Mar 11, 2026
rapids-bot Bot pushed a commit to rapidsai/rapids-cmake that referenced this pull request Mar 25, 2026
robertmaynard pushed a commit to robertmaynard/rapids-cmake that referenced this pull request Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[BUG]: sm_60 support broken for cub::detail::find::agent_t

5 participants