[OpenMP] Pass -fopenmp-is-device to preprocessing and machine specific code generation stages

Summary: The preprocessing and code generation and optimization stages of the compiler are also passed the "-fopenmp-is-device" flag. This is used to trigger machine specific preprocessing and code generation when performing device offloading to an NVIDIA GPU via OpenMP directives.

Reviewers: arpith-jacob, caomhin, carlo.bertolli, Hahnfeld, hfinkel, tstellar

Reviewed By: Hahnfeld

Subscribers: Hahnfeld, rengolin

Differential Revision: https://reviews.llvm.org/D29645

llvm-svn: 306691
This commit is contained in:
Gheorghe-Teodor Bercea 2017-06-29 15:59:19 +00:00
parent 0089419417
commit 3addb7d850
2 changed files with 15 additions and 3 deletions

View File

@ -4429,10 +4429,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// device declarations can be identified. Also, -fopenmp-is-device is passed
// along to tell the frontend that it is generating code for a device, so that
// only the relevant declarations are emitted.
if (IsOpenMPDevice && Inputs.size() == 2) {
if (IsOpenMPDevice) {
CmdArgs.push_back("-fopenmp-is-device");
CmdArgs.push_back("-fopenmp-host-ir-file-path");
CmdArgs.push_back(Args.MakeArgString(Inputs.back().getFilename()));
if (Inputs.size() == 2) {
CmdArgs.push_back("-fopenmp-host-ir-file-path");
CmdArgs.push_back(Args.MakeArgString(Inputs.back().getFilename()));
}
}
// For all the host OpenMP offloading compile jobs we need to pass the targets

View File

@ -589,3 +589,13 @@
// CHK-UBUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]"
// CHK-UBUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=
// CHK-UBUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" "-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]"
/// ###########################################################################
/// Check -fopenmp-is-device is also passed when generating the *.i and *.s intermediate files.
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
// CHK-FOPENMP-IS-DEVICE: clang{{.*}}.i" {{.*}}" "-fopenmp-is-device"
// CHK-FOPENMP-IS-DEVICE-NEXT: clang{{.*}}.bc" {{.*}}.i" "-fopenmp-is-device" "-fopenmp-host-ir-file-path"
// CHK-FOPENMP-IS-DEVICE-NEXT: clang{{.*}}.s" {{.*}}.bc" "-fopenmp-is-device"