aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorSergio Afonso <safonsof@amd.com>2023-06-01 17:38:33 +0100
committerSergio Afonso <safonsof@amd.com>2023-07-20 15:07:50 +0100
commit40340cf91ab9c61ec8c77c0a5063d4e5894e9d07 (patch)
treea1382b8cf47b7d5664f70ae8fe111141bc0a31d1 /flang/lib/Frontend/CompilerInvocation.cpp
parenta1c0e3be6f09be1315c21911b646eb9ddc5048c4 (diff)
downloadllvm-40340cf91ab9c61ec8c77c0a5063d4e5894e9d07.zip
llvm-40340cf91ab9c61ec8c77c0a5063d4e5894e9d07.tar.gz
llvm-40340cf91ab9c61ec8c77c0a5063d4e5894e9d07.tar.bz2
[MLIR][OpenMP][OMPIRBuilder] Use target triple to initialize `IsGPU` flag
This patch modifies the construction of the `OpenMPIRBuilder` in MLIR to initialize the `IsGPU` flag using target triple information passed down from the Flang frontend. If not present, it will default to `false`. This replicates the behavior currently implemented in Clang, where the `CodeGenModule::createOpenMPRuntime()` method creates a different `CGOpenMPRuntime` instance depending on the target triple, which in turn has an effect on the `IsGPU` flag of the `OpenMPIRBuilderConfig` object. Differential Revision: https://reviews.llvm.org/D151903
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index e76b67a..43fecca 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,23 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
res.getLangOpts().OpenMPTargetDebug = 1;
}
}
+
+ switch (llvm::Triple(res.getTargetOpts().triple).getArch()) {
+ case llvm::Triple::nvptx:
+ case llvm::Triple::nvptx64:
+ case llvm::Triple::amdgcn:
+ if (!res.getLangOpts().OpenMPIsTargetDevice) {
+ const unsigned diagID = diags.getCustomDiagID(
+ clang::DiagnosticsEngine::Error,
+ "OpenMP AMDGPU/NVPTX is only prepared to deal with device code.");
+ diags.Report(diagID);
+ }
+ res.getLangOpts().OpenMPIsGPU = 1;
+ break;
+ default:
+ res.getLangOpts().OpenMPIsGPU = 0;
+ break;
+ }
}
// -pedantic