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

    <tr>
        <th>Summary</th>
        <td>
            clang 20.0.0 omp device number is 1 despite having 2 devices. This appears to confuse #pragma omp target enter data commands
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    Hi there, i have an nvidia NVIDIA GeForce GTX 1660 SUPER gpu and a ryzen  AMD Ryzen 9 3900X 12-Core Processor. Yet if i compile the attached c++ test program with clang (version clang version 20.0.0git639e1fa2) , the omp device number is always just 1.

This appears to cause problems with target enter data commands.

I can write:
 #pragma omp target map(tofrom:x1data[0:10])device(0)

in the attached c++ file (rename the .txt to .cpp) and the map commands work on the target, despite 0 should be the host.

But if i replace it with, say:

(just uncomment the respective lines in the c++ code)
  #pragma omp target enter data map(alloc: x1data[0:10])device(0)
  #pragma omp target map(to:x1data[0:10])device(0)

  and then
  #pragma omp target exit data map (from:x1data[0:10])device(0)


before the last three printf commands in main will show that this will delete the data on the host before it is copied to the device and given to the called functions.

If i use target enter data and exit data on device(1), it wil, without printing an error, just work on the host device (but the host should be device 0)....

[main.txt](https://github.com/user-attachments/files/18392657/main.txt)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVV2PmzgX_jXOzdEgYwIDF1wknTd952JXVbe76l4acwB3jY1sk8z0168OkKRSZ7tbKRLEmMfn-TgHGYLuLWLN8iPLn3ZyjoPzdRPUMJuvZbprXPta_19DHNAjE-9AwyDPCNKCPetWS_j1j-en5wO8x5PzCuH9p8-QFgWH337_8L-P0E8zSNuCBP_6FS3A4Zcn-LjcVpBVnH-GVDy8cx7hg3cKQ3A-gT8xgu5Ag3LjpA3S8SBjlGrAFhQTRyaOEDFEmLzrvRzhou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