<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Problem calling atomics with pointers to the generic address space"
   href="https://bugs.llvm.org/show_bug.cgi?id=50041">50041</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Problem calling atomics with pointers to the generic address space
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>OpenCL
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>drohr@jwdt.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>anastasia.stulova@arm.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24773" name="attach_24773" title="Testcase">attachment 24773</a> <a href="attachment.cgi?id=24773&action=edit" title="Testcase">[details]</a></span>
Testcase

The attached testcase compiles with clang 11 / clang 12 / clang 13 trunk until
at least 23.2., but it fails with the current trunk (I was using clang version
13.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
6d0fef48609cbec9579716b77998059501969352)).

compile command:
clang++ -O0 -cl-std=clc++ -x cl -emit-llvm --target=spir64-unknown-unknown
-Xclang -fdenormal-fp-math-f32=ieee -cl-mad-enable -cl-no-signed-zeros
-ferror-limit=1000 -Xclang -finclude-default-header
-Dcl_clang_storage_class_specifiers -I../. -I../DataTypes -I../Definitions
-I../Base -I../SliceTracker -I../Common -I../Merger -I../Refit -I../TRDTracking
-I../ITS -I../dEdx -I../TPCConvert -I../TPCFastTransformation
-I../DataCompression -I../TPCClusterFinder -I../Global -I ../GPUUtils
-I/home/qon/alice/O2/DataFormats/Detectors/TPC/include
-I/home/qon/alice/O2/Detectors/Base/include
-I/home/qon/alice/O2/Detectors/Base/src
-I/home/qon/alice/O2/Common/MathUtils/include
-I/home/qon/alice/O2/DataFormats/Headers/include
-I/home/qon/alice/O2/Detectors/TRD/base/include
-I/home/qon/alice/O2/Detectors/TRD/base/src
-I/home/qon/alice/O2/Detectors/ITSMFT/ITS/tracking/include
-I/home/qon/alice/O2/Detectors/ITSMFT/ITS/tracking/cuda/include
-I/home/qon/alice/O2/Common/Constants/include
-I/home/qon/alice/O2/DataFormats/common/include
-I/home/qon/alice/O2/DataFormats/Detectors/TRD/include
-I/home/qon/alice/O2/DataFormats/Reconstruction/include
-I/home/qon/alice/O2/DataFormats/Reconstruction/src -DGPUCA_STANDALONE
-DGPUCA_GPULIBRARY=OCL -DNDEBUG -D__OPENCLCPP__ -DHAVE_O2HEADERS
-DGPUCA_TPC_GEOMETRY_O2 -c

With the current clang trunk, I am getting errors like:
../Common/GPUCommonMath.h:471:3: error: no matching function for call to
'atomic_max'
  ::atomic_max(addr, val);
  ^~~~~~~~~~~~
../Common/GPUCommonMath.h:97:20: note: in instantiation of function template
specialization 'o2::gpu::GPUCommonMath::AtomicMaxInt<volatile __generic
unsigned int, unsigned int>' requested here
    GPUCommonMath::AtomicMaxInt(addr, val);
                   ^
../SliceTracker/GPUTPCSliceData.h:217:11: note: in instantiation of function
template specialization 'o2::gpu::GPUCommonMath::AtomicMax<unsigned int>'
requested here
  CAMath::AtomicMax(&mHitWeights[row.mHitNumberOffset + hitIndex], weight);
          ^
../Common/GPUCommonMath.h:471:5: note: candidate function not viable: cannot
pass pointer to address space '__generic' as a pointer to address space
'__global' in 1st argument
  ::atomic_max(addr, val);
    ^          ~~~~
../Common/GPUCommonMath.h:471:5: note: candidate function not viable: cannot
pass pointer to address space '__generic' as a pointer to address space
'__local' in 1st argument
  ::atomic_max(addr, val);
    ^          ~~~~
../Common/GPUCommonMath.h:471:5: note: candidate function not viable: no known
conversion from 'volatile __generic unsigned int *__private' to 'volatile
__global int *' for 1st argument
  ::atomic_max(addr, val);
    ^          ~~~~
../Common/GPUCommonMath.h:471:5: note: candidate function not viable: no known
conversion from 'volatile __generic unsigned int *__private' to 'volatile
__local int *' for 1st argument
  ::atomic_max(addr, val);
    ^          ~~~~
../Common/GPUCommonMath.h:453:10: error: no matching function for call to
'atomic_add'
  return ::atomic_add(addr, val);
         ^~~~~~~~~~~~</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>