[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls
Gheorghe-Teodor Bercea via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 8 08:08:00 PDT 2018
gtbercea added a comment.
In https://reviews.llvm.org/D47849#1192368, @Hahnfeld wrote:
> In https://reviews.llvm.org/D47849#1192321, @gtbercea wrote:
>
> > > IIRC you started to work on this to fix the problem with inline assembly (see https://reviews.llvm.org/D47849#1125019). AFAICS this patch fixes declarations of math functions but you still cannot include `math.h` which most "correct" codes do.
> >
> > I'm not sure what you mean by this. This patch enables me to include math.h.
>
>
> `math.c`:
>
> #include <math.h>
>
>
> executed commands:
>
> $ clang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -c math.c -O2
> In file included from math.c:1:
> In file included from /usr/include/math.h:413:
> /usr/include/bits/mathinline.h:131:43: error: invalid input constraint 'x' in asm
> __asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x));
> ^
> /usr/include/bits/mathinline.h:143:43: error: invalid input constraint 'x' in asm
> __asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x));
> ^
> 2 errors generated.
>
We are probably linking against different math.h files. I don't seem to have a mathinline.h with those instructions. Perhaps this is an x86 specific error.
I think I know what's happening. I think the host math.h is still included but not necessarily used. Math functions resolve to math functions in the CUDA header first (that's what this patch does). This patch doesn't prevent math.h from being included.
Repository:
rC Clang
https://reviews.llvm.org/D47849
More information about the cfe-commits
mailing list