Repository navigation
Description
Is this a duplicate?
- I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct
Type of Bug
Compile-time Error
Component
libcu++
Describe the bug
Using cuda::atomic_ref fails to compile when using nvrtc and --device-debug in CUDA 12.6 (also tested latest CCCL). Removing --device-debug works successfully.
Given the following code snippet:
#include <cuda/atomic>
__global__ void add_relaxed_device_non_volatile(int* data, int *out)
{
auto ref = cuda::atomic_ref<int>(*data);
*out = ref.fetch_add(1);
}
Compiling with nvrtc and --device-debug produces the following error that looks like it is from LLVM complaining about missing !dbg locations:
inlinable function call in a function with debug info must have a !dbg location
%21 = call i32 @_ZN4cuda3std3__427__atomic_fetch_add_dispatchIKNS1_20__atomic_ref_storageIiEEiNS1_25__thread_scope_system_tagELi0EEENT_14__underlying_tEPS7_T0_NS1_12memory_orderET1_(%struct._ZN4cuda3std3__420__atomic_ref_storageIiEE* %16, i32 %17, i32 %18, %struct._ZN4cuda3std3__425__thread_scope_system_tagE %20)
inlinable function call in a function with debug info must have a !dbg location
%7 = call i32 @_ZN4cuda3std3__427__atomic_fetch_add_dispatchIKNS1_20__atomic_ref_storageIiEEiNS1_25__thread_scope_system_tagELi0EEENT_14__underlying_tEPS7_T0_NS1_12memory_orderET1_(%struct._ZN4cuda3std3__420__atomic_ref_storageIiEE* %6, i32 %4, i32 %5, %struct._ZN4cuda3std3__425__thread_scope_system_tagE zeroinitializer)
error: Broken module found, compilation aborted!
How to Reproduce
Full reproducer:
#include <nvrtc.h>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
static const char cu_cpp[] = R"(
#include <cuda/atomic>
__global__ void add_relaxed_device_non_volatile(int* data, int *out)
{
auto ref = cuda::atomic_ref<int>(*data);
*out = ref.fetch_add(1);
}
)";
int main(int argc, const char *argv[])
{
if (argc < 2) {
printf("%s PATH_TO_LIBCUDACXX_INCLUDE\n", argv[0]);
exit(1);
}
std::string include_arg = std::string("-I") + argv[1];
{ // Succeeds without --device-debug
nvrtcProgram prog;
nvrtcResult res = nvrtcCreateProgram(
&prog, cu_cpp, "dummy", 0, nullptr, nullptr);
assert(res == NVRTC_SUCCESS);
const char *args[] = {
include_arg.c_str(),
};
res = nvrtcCompileProgram(prog, 1, args);
assert(res == NVRTC_SUCCESS);
nvrtcDestroyProgram(&prog);
}
{ // Fails with --device-debug
nvrtcProgram prog;
nvrtcResult res = nvrtcCreateProgram(
&prog, cu_cpp, "dummy", 0, nullptr, nullptr);
assert(res == NVRTC_SUCCESS);
const char *args[] = {
include_arg.c_str(),
"--device-debug",
};
res = nvrtcCompileProgram(prog, 2, args);
assert(res != NVRTC_SUCCESS);
size_t log_size = 0;
nvrtcGetProgramLogSize(prog, &log_size);
std::vector<char> nvrtc_log(log_size);
nvrtcGetProgramLog(prog, nvrtc_log.data());
printf("%s", nvrtc_log.data());
nvrtcDestroyProgram(&prog);
}
}
Compile with: nvcc -lnvrtc test.cpp
Run with ./a.out PATH_TO_CCCL_INCLUDE_DIR
Expected behavior
Compilation succeeds.
Reproduction link
No response
Operating System
Ubuntu Linux 22.04
nvidia-smi output
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.35.03 Driver Version: 560.35.03 CUDA Version: 12.6 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 4090 Off | 00000000:01:00.0 On | Off |
| 30% 40C P8 12W / 450W | 4334MiB / 24564MiB | 7% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------
------+
NVCC version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Wed_Aug_14_10:10:22_PDT_2024
Cuda compilation tools, release 12.6, V12.6.68
Build cuda_12.6.r12.6/compiler.34714021_0
Activity
yukini2009 commentedon Sep 25, 2024
We logged 4878632 internally to investigate this . We will bring back conclusion here .
jrhemstad commentedon Dec 3, 2024
@shacklettbp thanks for using CCCL and taking the time to file this issue.
To provide an update, we looked into this internally and this is a compiler bug in NVRTC that the NVRTC team is scoping for fixing in an upcoming CUDA Toolkit release.
yukini2009 commentedon Dec 6, 2024
Hi @shacklettbp ticket 4878632 is fixed and verified on your provided case to us . The fix is in NVRTC , it will be part of next CUDA release soon . Thanks again for reporting bugs with explicit reproducer .