Skip to content

Conversation

@davebayer
Copy link
Contributor

@davebayer davebayer commented Dec 4, 2025

I found a way to force nvrtc to include the version of <nv/target> that comes with our CCCL.

The idea is that we pass the -D__NV_TARGET_H option to nvrtc through commandline which eliminates makes the builtin <nv/target> header to not be included. Then I #undef __NV_TARGET_H which allows our version of <nv/target> to be included.~~

I'd like to know your opinion on this. We could handle everything inside nvrtcc - both the define and undefine.

Alternatively, we could change the implementation of <nv/target> to not be included if there is a CCCL available in the include path and the version is newer than what nvrtc has. But that would require much larger changes.

It would look something like:

// <nv/target>

// If compiling with nvrtc and there is another <nv/target> in the include path, we skip the builtin header and use the
// other <nv/target> instead.
#if !defined(__NV_TARGET_H) && !defined(_NV_TARGET_SKIPPING_NVRTC_BUILTIN_HEADER)
#  if defined(__CUDACC_RTC__) && __has_include(<cuda/__cccl_config>) && __has_include(<nv/target>)
#    include <cuda/__cccl_config>
#    if (CCCL_MAJOR_VERSION > (__CUDACC_VER_MAJOR__  - 10)) || (CCCL_MAJOR_VERSION == (__CUDACC_VER_MAJOR__  - 10) && CCCL_MINOR_VERSION > __CUDACC_VER_MINOR__)
#      define _NV_TARGET_SKIPPING_NVRTC_BUILTIN_HEADER
#      include <nv/target>
#      undef _NV_TARGET_SKIPPING_NVRTC_BUILTIN_HEADER
#    endif // ^^^ use <nv/target> include ^^^
#  endif // 
#endif // !__NV_TARGET_H && !_NV_TARGET_SKIPPING_NVRTC_BUILTIN_HEADER

#ifndef __NV_TARGET_H
#define __NV_TARGET_H

// ...

#endif // __NV_TARGET_H

Edit: implemented this in #6881

Edit 2: Just adding missing nv target macros for archs 103, 110 and 120.

@davebayer davebayer requested a review from a team as a code owner December 4, 2025 14:01
@davebayer davebayer requested a review from griwes December 4, 2025 14:01
@github-project-automation github-project-automation bot moved this to Todo in CCCL Dec 4, 2025
@davebayer davebayer requested a review from wmaxey December 4, 2025 14:01
@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Review in CCCL Dec 4, 2025
@davebayer davebayer requested review from alliepiper and miscco and removed request for griwes December 4, 2025 14:01
@davebayer
Copy link
Contributor Author

Hm, this is probably not safe, because if nvrtc expects the nv target macros in another builtin headers, the compilation will fail

@github-actions

This comment has been minimized.

@bernhardmgruber
Copy link
Contributor

I guess for tests, this is fine. Please also add a comment to each

// ADDITIONAL_COMPILE_DEFINITIONS: __NV_TARGET_H

explaining how this disables nvrtc's builtin header.

@davebayer davebayer force-pushed the fix_nv_if_target_macros branch from 7c0cbde to 80a9139 Compare December 5, 2025 20:33
@davebayer davebayer changed the title Force nvrtc to use our <nv/target> Add missing nvrtc nv target archs Dec 5, 2025
@davebayer
Copy link
Contributor Author

With @wmaxey we are working on #6881, so we needn't to deal with this problem ever again. I changed this PR to just add the missing architectures. Hopefully we do this for the very last time.

@alliepiper this should fix our libcu++ nightlies.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@davebayer davebayer enabled auto-merge (squash) December 10, 2025 11:12
Copy link
Contributor

@bernhardmgruber bernhardmgruber left a comment

Choose a reason for hiding this comment

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

I hate that we have to do this. LGTM.

@davebayer
Copy link
Contributor Author

I hate that we have to do this. LGTM.

This fix is on the way, but I believe we will have to keep doing this till CUDA 15 :D

@github-actions
Copy link
Contributor

🥳 CI Workflow Results

🟩 Finished in 4h 01m: Pass: 100%/91 | Total: 2d 12h | Max: 3h 00m | Hits: 80%/198656

See results here.

@davebayer davebayer merged commit fb9b3e5 into NVIDIA:main Dec 10, 2025
104 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in CCCL Dec 10, 2025
github-actions bot pushed a commit that referenced this pull request Dec 10, 2025
@github-actions
Copy link
Contributor

Successfully created backport PR for branch/3.2.x:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants