This is an archive of the discontinued LLVM Phabricator instance.

[Libomptarget] Update handling of architectures for DeviceRTL
ClosedPublic

Authored by jhuber6 on Mar 7 2023, 8:37 AM.

Details

Summary

The support for enabling and disabling certain architectures for the
OpenMP device RTL is different between AMD and Nvidia. This patch
updates the logic to make it common. This supports the auto format
more generally via the nvptx-arch and amdgpu-arch options. (These
are not availible at CMake time without a runtimes build, or another
install somewhere. But that only prevents users from using auto).

Diff Detail

Event Timeline

jhuber6 created this revision.Mar 7 2023, 8:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2023, 8:37 AM
Herald added subscribers: kosarev, tpr. · View Herald Transcript
jhuber6 requested review of this revision.Mar 7 2023, 8:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2023, 8:37 AM
jdoerfert added inline comments.Mar 7 2023, 8:39 AM
openmp/libomptarget/DeviceRTL/CMakeLists.txt
64

you are dropping 89 and 90?

jhuber6 added inline comments.Mar 7 2023, 8:39 AM
openmp/libomptarget/DeviceRTL/CMakeLists.txt
64

Didn't notice those were missing, went off an old list.

jhuber6 updated this revision to Diff 503066.Mar 7 2023, 8:40 AM

adding sm_89 and sm_90

jhuber6 edited the summary of this revision. (Show Details)Mar 7 2023, 8:41 AM
jhuber6 updated this revision to Diff 503373.Mar 8 2023, 7:51 AM

GPU -> DEVICE

ye-luo added inline comments.Mar 8 2023, 8:22 AM
openmp/libomptarget/DeviceRTL/CMakeLists.txt
68

Prefer default all instead of the full list.
When doing an incremental build and having new arch being listed. all continue to build everything but cached list doesn't

74

Are both tool always built together?

jhuber6 added inline comments.Mar 8 2023, 8:30 AM
openmp/libomptarget/DeviceRTL/CMakeLists.txt
68

Good point

74

Yes, they are always built by clang.

jhuber6 updated this revision to Diff 503392.Mar 8 2023, 8:31 AM

Default value to all

ye-luo added inline comments.Mar 8 2023, 8:44 AM
openmp/libomptarget/DeviceRTL/CMakeLists.txt
74

Did you mean they are always built by the clang target outside openmp project?
If I don't build NVPTX or AMDGPU backend, are they still being built?
Can it be better if we do this.
if nvptx-arch exists, add its list to the LIBOMPTARGET_DEVICE_ARCHITECTURES.
if it doesn't exists, print a warning but don't error out.
do the same for amdgpu-arch.
if LIBOMPTARGET_DEVICE_ARCHITECTURES is still empty, error out.

openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
121–122

There are a few variables related to ARCH. Could you rename this to LIBOMPTARGET_NVPTX_ARCH_DETECTED_LIST.
Also the AMDGPU one.

jhuber6 added inline comments.Mar 8 2023, 8:47 AM
openmp/libomptarget/DeviceRTL/CMakeLists.txt
74

nvptx-arch and amdgpu-arch are clang tools. They are built unconditionally whenever you build clang, they will be available here during a runtimes build, or if the user has the binary somewhere else. This is only necessary for auto support, which I'm pretty sure already used this transitively after I made a previous change deprecating the use of findCUDA in favor of nvptx-arch.

This logic only runs on auto which I feel is fair to require some additional handling to support. Or are you suggesting we make the default only supporting the user's architecture?

openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
121–122

Sure

jhuber6 updated this revision to Diff 503397.Mar 8 2023, 8:51 AM

Adding detected to variable name

ye-luo added inline comments.Mar 8 2023, 8:53 AM
openmp/libomptarget/DeviceRTL/CMakeLists.txt
74

What I described above is intended for inside the logic block "auto". I don't support having auto as the default.

jhuber6 added inline comments.Mar 8 2023, 8:54 AM
openmp/libomptarget/DeviceRTL/CMakeLists.txt
74

I think this is fine since there's no situation where the user would have one but not the other unless they manually deleted it.

ye-luo accepted this revision.Mar 8 2023, 9:00 AM
ye-luo added inline comments.
openmp/libomptarget/DeviceRTL/CMakeLists.txt
74

Then what we have now is sufficient. Could you extend the error message saying current auto detection only support NV and AMD.

This revision is now accepted and ready to land.Mar 8 2023, 9:00 AM