This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Parse toolchain-specific offloading arguments directly
ClosedPublic

Authored by jhuber6 on Jul 9 2022, 7:25 PM.

Details

Summary

OpenMP supports multiple offloading toolchains and architectures. In
order to support this we originally used getArgsForToolchain to get
the arguments only intended for each toolchain. This allowed users to
manually specify if an --offload-arch= argument was intended for which
toolchain using -Xopenmp-target= or other methods. For example,

clang input.c -fopenmp -fopenmp-targets=nvptx64,amdgcn -Xopenmp-target=nvptx64 --offload-arch=sm_70 -Xopenmp-target=amdgcn --offload-arch=gfx908

However, this was causing problems with the AMDGPU toolchain. This is
because the AMDGPU toolchain for OpenMP uses an amdgpu arch to determine the
architecture. If this tool is not availible the compiler will exit with an error
even when manually specifying the architecture. This patch pulls out the logic in
getArgsForToolchain and specializes it for extracting --offload-arch
arguments to avoid this.

Diff Detail

Event Timeline

jhuber6 created this revision.Jul 9 2022, 7:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 9 2022, 7:25 PM
jhuber6 requested review of this revision.Jul 9 2022, 7:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 9 2022, 7:25 PM
JonChesterfield accepted this revision.Jul 11 2022, 6:27 AM

LG, thanks!

This revision is now accepted and ready to land.Jul 11 2022, 6:27 AM

need a test

need a test

There's a test clang/test/Driver/openmp-offload-gpu-new.c already making sure that the following works, so this patch should maintain the same functionality we had before.

clang input.c -fopenmp -fopenmp-targets=nvptx64,amdgcn -Xopenmp-target=nvptx64 --offload-arch=sm_70 -Xopenmp-target=amdgcn --offload-arch=gfx908
yaxunl accepted this revision.Jul 11 2022, 10:14 AM

LGTM. Thanks.