<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 - Complex math functions not linking on nvptx"
   href="https://bugs.llvm.org/show_bug.cgi?id=51639">51639</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Complex math functions not linking on nvptx
          </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>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>OpenMP
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>pushpinderdhaliwal00@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>johannes@jdoerfert.de, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I have been trying to use complex math functions in the openmp target
region. I am able to use basic complex arithmetic but math functions
like abs, sin do not work. I get a linker undefined error when I use
these methods. I noticed that these methods are defined in
openmp_wrappers/complex_cmath.h in the variant region in
<a href="https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/openmp_wrappers/complex#L47">https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/openmp_wrappers/complex#L47</a>.
Am I missing something?

More details,
command line: clang++ test.cpp -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda
test.cpp:
#include <iostream>
#include <complex>
#include <cmath>

int main() {
  std::complex<double> x, a, b;
#pragma omp target map(tofrom: x)
  {
    x = std::exp(a * b);
  }

  std::cout << x << std::endl;
  return 0;
}

linker error: nvlink error   : Undefined reference to 'cexp' in
'/tmp/test-a02307.cubin'
CUDA details:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Tue_Sep_15_19:10:02_PDT_2020
Cuda compilation tools, release 11.1, V11.1.74
Build cuda_11.1.TC455_06.29069683_0</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>