diff options
author | Sergio Afonso <safonsof@amd.com> | 2023-06-01 17:38:33 +0100 |
---|---|---|
committer | Sergio Afonso <safonsof@amd.com> | 2023-07-20 15:07:50 +0100 |
commit | 40340cf91ab9c61ec8c77c0a5063d4e5894e9d07 (patch) | |
tree | a1382b8cf47b7d5664f70ae8fe111141bc0a31d1 /flang/tools | |
parent | a1c0e3be6f09be1315c21911b646eb9ddc5048c4 (diff) | |
download | llvm-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/tools')
-rw-r--r-- | flang/tools/bbc/bbc.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp index 4048899..f617743 100644 --- a/flang/tools/bbc/bbc.cpp +++ b/flang/tools/bbc/bbc.cpp @@ -135,6 +135,11 @@ static llvm::cl::opt<bool> llvm::cl::desc("enable openmp device compilation"), llvm::cl::init(false)); +static llvm::cl::opt<bool> + enableOpenMPGPU("fopenmp-is-gpu", + llvm::cl::desc("enable openmp GPU target codegen"), + llvm::cl::init(false)); + // A simplified subset of the OpenMP RTL Flags from Flang, only the primary // positive options are available, no negative options e.g. fopen_assume* vs // fno_open_assume* @@ -288,10 +293,16 @@ static mlir::LogicalResult convertFortranSourceToMLIR( burnside.lower(parseTree, semanticsContext); mlir::ModuleOp mlirModule = burnside.getModule(); if (enableOpenMP) { - auto offloadModuleOpts = OffloadModuleOpts( - setOpenMPTargetDebug, setOpenMPTeamSubscription, - setOpenMPThreadSubscription, setOpenMPNoThreadState, - setOpenMPNoNestedParallelism, enableOpenMPDevice, setOpenMPVersion); + if (enableOpenMPGPU && !enableOpenMPDevice) { + llvm::errs() << "FATAL: -fopenmp-is-gpu can only be set if " + "-fopenmp-is-target-device is also set"; + return mlir::failure(); + } + auto offloadModuleOpts = + OffloadModuleOpts(setOpenMPTargetDebug, setOpenMPTeamSubscription, + setOpenMPThreadSubscription, setOpenMPNoThreadState, + setOpenMPNoNestedParallelism, enableOpenMPDevice, + enableOpenMPGPU, setOpenMPVersion); setOffloadModuleInterfaceAttributes(mlirModule, offloadModuleOpts); setOpenMPVersionAttribute(mlirModule, setOpenMPVersion); } |