[Openmp-dev] Problem with complex math functions

Pushpinder Singh via Openmp-dev openmp-dev at lists.llvm.org
Wed Aug 25 03:49:45 PDT 2021

Hi all,

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
Am I missing something?

More details,
command line: clang++ test.cpp -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda
#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
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

Please let me know if more details are needed.

Thanks & Regards,
Pushpinder Singh

More information about the Openmp-dev mailing list