Page MenuHomePhabricator

[libomptarget] Build amdgcn devicertl by default
ClosedPublic

Authored by JonChesterfield on Mar 15 2021, 1:18 PM.

Details

Summary

[libomptarget] Build amdgcn devicertl by default

The cmake for this looks for an llvm install and does the right thing when
building as part of enable_runtimes. It will probably do the right thing
in other settings - at least, it won't try to build this with gcc.

Diff Detail

Event Timeline

JonChesterfield requested review of this revision.Mar 15 2021, 1:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2021, 1:18 PM
openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
157

This matches nvptx and the clang driver from trunk. It marks a divergence from the rocm install tree.

jdoerfert accepted this revision.Mar 15 2021, 3:22 PM
This revision is now accepted and ready to land.Mar 15 2021, 3:22 PM
This revision was automatically updated to reflect the committed changes.

There is a failure mode here. If clang is built with an llvm that has the amdgpu target disabled, it will fail to compile this library. This is because clang sets the flag amdhsa-code-object-version for amdgpu, but that flag is defined in llvm, and is excluded from the build if the amdgpu target is disabled. That can be fixed by either not building openmp, or by enabling the target, but the error message the user gets is poor:

clang (LLVM option parsing): Unknown command line argument '--amdhsa-code-object-version=3'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--pgo-memop-max-version=3'?

cmake has a CHECK_CXX_COMPILER_FLAG control, but that doesn't work as CXX_COMPILER is not set to the compiler that is building the library. There is a CHECK_CXX_SOURCE_COMPILES which has the same problem.

I'm considering embedding llc --version | grep -c amdgcn in cmake, but can't work out how to and it seems excessively ugly.

Any suggestions on how to detect when the clang detected/specified is going to fail to build the library, and thus skip it?

asking llc seems fine and generic

JonChesterfield added a comment.EditedMar 16 2021, 11:45 AM

Do you know how to do so? I'm an hour into cmake documentation, stack overflow and trial and error with zero progress.

edit: looking into whether I can decouple clang from llvm instead of hacking around it here

Reverted, D98746 attracted requests for improvement that I don't have a timeline for. This will unblock people building openmp with a clang that doesn't have amdgpu enabled.

D101095 would suffice to land this again.