[llvm-bugs] [Bug 45533] New: CUDA and OpenMP math functions conflicts (using both -xcuda and -fopenmp)

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 14 07:25:46 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45533

            Bug ID: 45533
           Summary: CUDA and OpenMP math functions conflicts (using both
                    -xcuda and -fopenmp)
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: OpenMP
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dontbugme at mailinator.com
                CC: llvm-bugs at lists.llvm.org

Compiling with -xcuda and -fopenmp options yields the following errors:

In file included from <built-in>:1:
In file included from
/usr/lib/clang/9.0.1/include/__clang_cuda_runtime_wrapper.h:36:
In file included from
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../include/c++/9.3.0/cmath:45:
In file included from /usr/include/math.h:290:
/usr/include/bits/mathcalls.h:95:17: error: exception specification in
declaration does not match previous declaration
__MATHCALL_VEC (exp,, (_Mdouble_ __x));
                ^
/usr/lib/clang/9.0.1/include/__clang_cuda_math_forward_declares.h:84:19: note:
previous declaration is here
__DEVICE__ double exp(double);

... along with other math functions.
Using CUDA 9.2 and Clang 9.0.1.
Test code:

#include <stdio.h>
#define N 1000

__global__ void add(int *a, int *b) {
    int i = blockIdx.x;
    if (i<N) {
        b[i] = 2*a[i];
    }
}

int main() {

    int ha[N], hb[N];
    int *da, *db;
    cudaMalloc((void **)&da, N*sizeof(int));
    cudaMalloc((void **)&db, N*sizeof(int));

    #pragma omp parallel for
    for (int i = 0; i<N; ++i) {
        ha[i] = i;
    }

    cudaMemcpy(da, ha, N*sizeof(int), cudaMemcpyHostToDevice);
    add<<<N, 1>>>(da, db);
    cudaMemcpy(hb, db, N*sizeof(int), cudaMemcpyDeviceToHost);

    for (int i = 0; i<N; ++i) {
        printf("%d\n", hb[i]);
    }

    cudaFree(da);
    cudaFree(db);
    return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200414/57dea2bc/attachment.html>


More information about the llvm-bugs mailing list