<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/150904>150904</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-Cuda]: unused command line argument `-fgpu-default-stream=per-thread`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          maartenarnst
      </td>
    </tr>
</table>

<pre>
    When we use `clang` to compile `cuda` code with `-fgpu-default-stream=per-thread`, we get the warning:

```
warning: argument unused during compilation: '-fgpu-default-stream=per-thread' [-Wunused-command-line-argument]
```

This is a reproducer:

<details>
<summary>
Dockerfile
</summary>

```
FROM nvidia/cuda:12.8.1-devel-ubuntu24.04

# Set up the key ring so that we can use apt update.
ADD https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb cuda-keyring_1.0-1_all.deb

RUN <<EOF
    set -ex

    apt-key del 7fa2af80
    rm -f /etc/apt/sources.list.d/cuda.list
    rm -f /etc/apt/sources.list.d/nvidia-ml.list
    dpkg -i cuda-keyring_1.0-1_all.deb
EOF

# Install requirements.
RUN <<EOF
 set -ex

    apt update

    apt --yes --no-install-recommends install wget software-properties-common
EOF

# Install clang.
RUN <<EOF
    set -ex

    wget https://apt.llvm.org/llvm.sh

    chmod +x llvm.sh

 ./llvm.sh 20
EOF

# This is a source file to compile.
COPY <<EOF test.cpp
#include "cuda_runtime.h"

__device__ int value_d;

int main() {
    const int value_h = 5;

    cudaMemcpyToSymbol(
 value_d,
        &value_h,
        sizeof(int),
        0,
 cudaMemcpyHostToDevice
    );
}
EOF

# Compile the source file.
RUN <<EOF
    set -ex

    clang++-20 -x cuda --cuda-gpu-arch=sm_70 -fgpu-default-stream=per-thread -L/usr/local/cuda/lib64 -lcudart test.cpp
EOF
```
</details>

With this Dockerfile, the issue can be reproduced with:

```
docker buildx build --progress plain --tag reproducer - < Dockerfile
```

I am not sure whether the command line argument is really not taken into account during the compilation, or whether this is a spurious warning. A first step to analyse this issue further may hence be to use Nvidia tooling to see which cuda api calls are made. 

- https://github.com/llvm/llvm-project/blob/d532d58974d5f1ccb5c568b67321cc761742152b/clang/lib/CodeGen/CGCUDANV.cpp#L417

Tagging @boxu-zhang and @Artem-B because they submitted the original work on this command line argument:
- https://github.com/llvm/llvm-project/commit/f05b58a9468cc2990678e06bc51df56b30344807 

Joint work with @romintomasetti.



</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVl1v6zYS_TX0y4ACTX3ZD35w7LrbRXvvor3di30yKHFkcUORWpJK4v76BSnlOg7SbbtBAItfwzNnZs5QeK8uBnFHygdSHldiCr11u0EIF9AIZ3xYNVZed197NPCMMHkEUrFWC3MhFYNgobXDqPQ8PUkRZ1srEZ5V6OMk7S7jRCV2YtKB-uBQDCQ_juho6B0KSSpG-CFav2CA0CM8C2eUuZB8T1j6r9jyz_a3NRDuMg1oAkxm8ihBTk6ZywJIBGVN3EV4_ccQeA2kfKBfZ0u0tcMgjKRaGaSv15Dy-A4LYfsvvfKgPAhwODorpxbdDXd-kBiE0p7k381jPw2DcNd5fLTtI7pOaZwXCT_drb-77vTz55_APCmpBOGnRHa-X_Nsk62pxCfUdGomEyZeZKxYjvMcfsEA05iIfcQrJI68hdCLEElvhUlhFWPcJkXAjLD9_niEPoTRR2f4ifBTusGO6DJpn422QmYzlqy1Q8Rjh3EK-IqMnxyO1hN-WkAxVhB-etlU56pYNtFHvEY453XG6PostM4kNvD7S7NTP__6CSJb-eG7zyfC9gAAHgNQfJk3xAkxhmgDJGqoO8FFt2HLkhuAdkD4CUNL-EmMIRJvJ9eiz7TyIZMLwDT6S6dmSuig3x6V4-MFqPrfjs2-LDH7wfggtAaH_5mUw5h-PvvI9Y_8XsJ4P0fpFT1QaixVs3HqMOY5GulhmYLnWILeduFZOKSji_EOCn2qCGt-D2bSgw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