Skip to content

Fix is_address_from(shared/local) - Bug #11028 - #11052

Merged
fbusato merged 4 commits into
NVIDIA:mainfrom
fbusato:fix-is_address_from-cuda-12.9
Aug 31, 2026
Merged

Fix is_address_from(shared/local) - Bug #11028#11052
fbusato merged 4 commits into
NVIDIA:mainfrom
fbusato:fix-is_address_from-cuda-12.9

Conversation

@fbusato

@fbusato fbusato commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #11028

The PR provides a workaround for NVCC/NVRTC 12.9–13.1 where typed pointers (even with void*) are passed to __isShared and __isLocal. The fix consists of passing the argument to a non-inline function.

@fbusato fbusato self-assigned this Aug 27, 2026
@fbusato
fbusato requested a review from a team as a code owner August 27, 2026 22:54
@fbusato
fbusato requested a review from ericniebler August 27, 2026 22:54
@fbusato fbusato added this to CCCL Aug 27, 2026
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Aug 27, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Aug 27, 2026
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved CUDA address-space detection for affected CUDA 12.9–13.1 compiler versions.
    • Fixed issues that could produce incorrect shared- and local-memory classification during compilation.
    • Preserved native compiler behavior for other supported CUDA versions.
    • Improved compilation reliability for applications using CUDA memory-space checks across supported compiler versions.

Walkthrough

The change adds named CUDA compiler-version conditions and function-template helpers for affected address-space lowerings. Local checks use the workaround on CUDA 13.1. Shared checks use it on CUDA 12.9–13.1. Other supported versions retain native intrinsics.

Changes

Address-space lowering

Layer / File(s) Summary
Compiler workaround helpers
libcudacxx/include/cuda/__memory/address_space.h
Names the affected compiler-version conditions and defines function-template helpers for __isShared and __isLocal.
Address-check routing
libcudacxx/include/cuda/__memory/address_space.h
Routes CUDA 13.1 local checks and CUDA 12.9–13.1 shared checks through the helpers. Other supported versions retain native intrinsics.

Assessment against linked issues

Objective Addressed Explanation
Compile is_address_from(ptr, address_space::shared) on CTK 12.9 for all consumers [#11028]

Suggested reviewers: ericniebler

Merge Risk: ⚪ Minimal · up to d331b

This change provides the CUDA compiler compatibility workaround without introducing an actionable merge-blocking risk; it is merge-ready after normal checks and review.


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
libcudacxx/include/cuda/__memory/address_space.h (1)

69-69: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: Repeat the exact preprocessor condition in each added #else and #endif comment. The current comments use summaries such as NVCC/NVRTC 13.1 and other NVCC/NVRTC versions, which can drift from the actual compiler gates. Based on learnings: every annotated #else or #endif must repeat the exact condition text from its corresponding #if, without inversion or paraphrasing.

Also applies to: 78-78, 147-153, 159-159, 223-229

Source: Learnings


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 05ef8990-8a13-4ca3-b99f-2634db3d9626

📥 Commits

Reviewing files that changed from the base of the PR and between 3a9ae70 and fe2e31a.

📒 Files selected for processing (1)
  • libcudacxx/include/cuda/__memory/address_space.h

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@github-actions

This comment has been minimized.

@miscco miscco left a comment

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 the less invasive approach would be to selectively mark the function as either noinline or forceinline or potentially just drop the inline

That would reduce the impact on the call sites and we should probably check whether its used in other places

Comment thread libcudacxx/include/cuda/__memory/address_space.h Outdated
|| (_CCCL_CUDA_COMPILER(NVRTC, >=, 12, 9) && _CCCL_CUDA_COMPILER(NVRTC, <, 13, 2))
// NVCC/NVRTC 12.9-13.1 pass typed pointers to the i8* __isShared intrinsic after inlining, which breaks the LLVM
// verifier. Preventing inlining preserves the required generic pointer type.
[[nodiscard]] _CCCL_DEVICE_API _CCCL_NOINLINE inline bool __is_shared_cuda_12_9_workaround(const void* __ptr) noexcept

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.

This will not work, because many compiler balk at noinline inline Als here inline is applied multiple times, we should not use _CCCL_DEVICE_API, because that might include inline.

Suggested change
[[nodiscard]] _CCCL_DEVICE_API _CCCL_NOINLINE inline bool __is_shared_cuda_12_9_workaround(const void* __ptr) noexcept
[[nodiscard]] _CCCL_DEVICE _CCCL_NOINLINE bool __is_shared_cuda_12_9_workaround(const void* __ptr) noexcept

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

inline is for ODR, noinline is actually to avoid function inlining from the compiler. _CCCL_DEVICE_API looks safe to me. It cannot include inline

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

an alternative could be using template<typename = void>, but looks that CI is passing with the current code

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.

yeah but I am pretty sure old GCC will then break in the nightlies. Please use the template hack

@griwes griwes Aug 28, 2026

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.

Even GCC 5 is happy with inline noinline: https://godbolt.org/z/PsMsYb9o6. Compilers have had a good understanding that inline is predominantly an ODR control, not an, well, inlining marker for a rather long time.

@griwes griwes left a comment

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.

Reviewed throughout.

Nit: since you are re-spelling the same version checking conditions twice, could we have them drive the definition of a macro which you then check in both places? Would make it easier to visually verify that the conditions do, in fact, match, but I leave this up to you.

@github-actions

This comment has been minimized.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a68cd768-d33c-4614-833e-7ad2a4a308fe

📥 Commits

Reviewing files that changed from the base of the PR and between fe2e31a and d331be4.

📒 Files selected for processing (1)
  • libcudacxx/include/cuda/__memory/address_space.h

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Comment thread libcudacxx/include/cuda/__memory/address_space.h
Comment thread libcudacxx/include/cuda/__memory/address_space.h
@github-actions

This comment has been minimized.

@fbusato
fbusato enabled auto-merge (squash) August 31, 2026 15:38
@fbusato
fbusato disabled auto-merge August 31, 2026 15:41
@fbusato
fbusato enabled auto-merge (squash) August 31, 2026 15:41
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 6h 57m: Pass: 100%/195 | Total: 8d 04h | Max: 4h 32m | Hits: 36%/3295551

See results here.

@fbusato
fbusato merged commit d037a06 into NVIDIA:main Aug 31, 2026
436 of 440 checks passed
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]: is_address_from(shared) is broken on CTK 12.9, neither the intrinsic nor the PTX path works

3 participants