Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12.0.0-rc1 build error for device runtime #48502

Closed
jprotze opened this issue Feb 12, 2021 · 11 comments
Closed

12.0.0-rc1 build error for device runtime #48502

jprotze opened this issue Feb 12, 2021 · 11 comments
Labels
bugzilla Issues migrated from bugzilla openmp

Comments

@jprotze
Copy link
Collaborator

jprotze commented Feb 12, 2021

Bugzilla Link 49158
Resolution FIXED
Resolved on Feb 15, 2021 14:01
Version unspecified
OS Linux
Blocks #48246
CC @alexey-bataev,@grokos,@jdoerfert,@JonChesterfield,@Fznamznon,@Artem-B,@tstellar,@yxsamliu
Fixed by commit(s) 3b2f19d f9286b4 1dd66e6 343ba97 3b9ea2d 0d14528

Extended Description

Building the just tagged 12.0.0-rc1, I still cannot compile LLVM including libomptarget. The build aborts with the following error, I build OpenMP as runtime, therefore the newly built clang is used:

FAILED: projects/openmp/libomptarget/deviceRTLs/nvptx/loop.cu-cuda_80-sm_70.bc
cd ${BUILD_DIR}/projects/openmp/libomptarget/deviceRTLs/nvptx && clang -S -x c++ -target nvptx64 -Xclang -emit-llvm-bc -Xclang -aux-triple -Xclang x86_64-unknown-linux-gnu -fopenmp -fopenmp-cuda-mode -Xclang -fopenmp-is-device -D__CUDACC__ -I${SOURCE_DIR}/openmp/libomptarget/deviceRTLs -I${SOURCE_DIR}/openmp/libomptarget/deviceRTLs/nvptx/src -DOMPTARGET_NVPTX_DEBUG=0 -Xclang -target-cpu -Xclang sm_70 -D__CUDA_ARCH__=700 -Xclang -target-feature -Xclang +ptx42 -DCUDA_VERSION=8000 ${SOURCE_DIR}/openmp/libomptarget/deviceRTLs/common/src/loop.cu -o loop.cu-cuda_80-sm_70.bc
In file included from ${SOURCE_DIR}/openmp/libomptarget/deviceRTLs/common/src/loop.cu:16:
In file included from ${SOURCE_DIR}/openmp/libomptarget/deviceRTLs/common/omptarget.h:18:
In file included from ${SOURCE_DIR}/openmp/libomptarget/deviceRTLs/common/debug.h:31:
In file included from ${SOURCE_DIR}/openmp/libomptarget/deviceRTLs/common/device_environment.h:16:
In file included from ${SOURCE_DIR}/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h:18:
${SYSTEM}/clang/11.0.0/bin/../include/c++/v1/stdlib.h:128:10: error: '__builtin_fabsl' requires 128 bit size 'long double' type support, but device 'nvptx64' does not support it
return __builtin_fabsl(__lcpp_x);
^
${SYSTEM}/clang/11.0.0/bin/../include/c++/v1/stdlib.h:128:10: note: '__builtin_fabsl' defined here
${SYSTEM}/clang/11.0.0/bin/../include/c++/v1/stdlib.h:128:10: error: '__builtin_fabsl' requires 128 bit size 'long double' type support, but device 'nvptx64' does not support it
return __builtin_fabsl(__lcpp_x);
^
${SYSTEM}/clang/11.0.0/bin/../include/c++/v1/stdlib.h:128:10: note: '__builtin_fabsl' defined here
${SYSTEM}/clang/11.0.0/bin/../include/c++/v1/stdlib.h:128:26: error: '__lcpp_x' requires 128 bit size 'long double' type support, but device 'nvptx64' does not support it
return __builtin_fabsl(__lcpp_x);
^
${SYSTEM}/clang/11.0.0/bin/../include/c++/v1/stdlib.h:127:17: note: '__lcpp_x' defined here
abs(long double __lcpp_x) _NOEXCEPT {
^
3 errors generated.

@jprotze
Copy link
Collaborator Author

jprotze commented Feb 12, 2021

Even, when I manually add -I${BUILD_DIR}/include/c++/v1/ to make sure, that clang uses the just configured stdlib.h, I get the same compiler errors.
The error messages then read:

....
In file included from ${SOURCE_DIR}/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h:18:
${BUILD_DIR}/include/c++/v1/stdlib.h:128:10: error: '__builtin_fabsl' requires 128 bit size 'long double' type support, but device 'nvptx64' does not support it
return __builtin_fabsl(__lcpp_x);

@jprotze
Copy link
Collaborator Author

jprotze commented Feb 12, 2021

Hiding the lines for NVPTX helps to avoid the error:

--- a/libcxx/include/stdlib.h
+++ b/libcxx/include/stdlib.h
@@ -114,7 +114,7

-#if !(defined(_AIX) || defined(sun))
+#if !(defined(_AIX) || defined(sun) || defined(NVPTX))
inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
}

With this patch and manually specifying the include directory, the compile error is gone.

I just don't know to which libomptarget cmake file I would need to add the include_directories command, which makes sure that the compiler uses the new stdlib.h

@jdoerfert
Copy link
Member

Can you check if https://reviews.llvm.org/D95928 fixes this?

@jprotze
Copy link
Collaborator Author

jprotze commented Feb 12, 2021

Will that patch be backported to release-12?
Otherwise I'll create a patch to disable the problematic function in stdlib.h for nvptx.

@jprotze
Copy link
Collaborator Author

jprotze commented Feb 12, 2021

And yes, your patch resolves this issue.

@JonChesterfield
Copy link
Collaborator

It's not obvious to me that including stdlib.h in a target region is well defined. In particular, it contains things that don't work on the target (like this bug report), and glibc doesn't seem to have feature macros for nvptx.

Alternatives to patching clang, to fix this bug, seem to be:

  • don't include glibc headers in the device runtime
  • include stdlib outside of target region
  • possibly use ifdef/variant in combination with the above

Application code might still want to include stdlib in a target region and have it work, but perhaps that could be postponed for now?

@tstellar
Copy link
Collaborator

Is backporting https://reviews.llvm.org/D95928 still OK?

@jdoerfert
Copy link
Member

Is backporting https://reviews.llvm.org/D95928 still OK?

I think so. Though, I'm waiting for review on that one and the one before.

@jdoerfert
Copy link
Member

*** Bug llvm/llvm-bugzilla-archive#48933 has been marked as a duplicate of this bug. ***

@jdoerfert
Copy link
Member

Fixed by
3b2f19d
f9286b4
1dd66e6
which apply cleanly to release 12 when I tried it now.

@tstellar
Copy link
Collaborator

Merged: 0d14528

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla openmp
Projects
None yet
Development

No branches or pull requests

4 participants