<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 - OpenMP Offload with complex math function on"
   href="https://bugs.llvm.org/show_bug.cgi?id=52068">52068</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>OpenMP Offload with complex math function on
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Runtime Library
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>tapplencourt@anl.gov
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Math function in std::complex.  Maybe related to 45003.

This code doesn't compile:
```
#include <complex>
#include <cmath>
#include <iomanip>
#include <stdlib.h>
#include <limits>
#include <iostream>
#include <cstdlib>
using namespace std;
bool almost_equal(complex<double> x, complex<double> y, int ulp) {
    return std::abs(x-y) <= std::numeric_limits<double>::epsilon() *
std::abs(x+y) * ulp || std::abs(x-y) < std::numeric_limits<double>::min();
}
void test_cos(){
   const char* usr_precision = getenv("OVO_TOL_ULP");
   const int precision = usr_precision ? atoi(usr_precision) : 4;
   complex<double> in0 { 0.42, 0.0 };
    complex<double> out1_host {};
   complex<double> out1_device {};
   {
    out1_host = cos(in0);
   }
   #pragma omp target map(tofrom: out1_device )
   {
    out1_device = cos(in0);
   }
   if ( !almost_equal(out1_host,out1_device, precision) ) {
        std::cerr << std::setprecision
(std::numeric_limits<double>::max_digits10 ) << "Host: " << out1_host << " GPU:
" << out1_device << std::endl;
        std::exit(112);
    }
}
int main()
{
    test_cos();
}
```
Error message:
```
tapplencourt@gpu07:~> clang++ --version
clang version 14.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
63c566b1fde33344688fb0e37dc4223a230ad575)
[...]
tapplencourt@gpu07:~> clang++ -fopenmp -fopenmp-targets=nvptx64 -Xopenmp-target
-march=sm_80 test.cpp
clang-14: warning: unknown CUDA version: version.txt: 11.0.207.; assuming the
latest supported version 10.1 [-Wunknown-cuda-version]
nvlink error   : Undefined reference to 'ccos' in '/tmp/test-e10f6f.cubin'
clang-14: error: nvlink command failed with exit code 255 (use -v to see
invocation)
clang version 14.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
63c566b1fde33344688fb0e37dc4223a230ad575)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /soft/compilers/llvm/master-latest/bin
clang-14: note: diagnostic msg: Error generating preprocessed source(s).
```

More tests here:
<a href="https://github.com/TApplencourt/OvO/tree/master/test_src/cpp/mathematical_function/cpp11-complex">https://github.com/TApplencourt/OvO/tree/master/test_src/cpp/mathematical_function/cpp11-complex</a>

One can do:
```
 ./ovo.sh run ./test_src/cpp/mathematical_function/cpp11-complex/
```</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>