Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMP][Flang][MLIR] Implement OffloadModuleInterface for OpenMP Dia…
…lect and convert is_device to an Attribute This commit adds the OffloadModuleInterface to the OpenMP dialect, which will implement future module attribute get/set's for offloading. Currently it implements set and get's for the omp.is_device attribute, which is promoted to a real attribute in this commit as well (primarily to allow switch cases to work nicely with it for future work and to keep consistency with future module attributes). This interface is attached to mlir::ModuleOp's on registration of the OpenMPDialect and should be accessible anywhere the OpenMP dialect is registered and initialized. Reviewers: kiranchandramohan, awarzynski Differential Revision: https://reviews.llvm.org/D146850
- Loading branch information
Showing
9 changed files
with
133 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===-- Tools/CrossToolHelpers.h --------------------------------- *-C++-*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// A header file for containing functionallity that is used across Flang tools, | ||
// such as helper functions which apply or generate information needed accross | ||
// tools like bbc and flang-new. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H | ||
#define FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H | ||
|
||
#include "mlir/Dialect/OpenMP/OpenMPDialect.h" | ||
#include "mlir/IR/BuiltinOps.h" | ||
|
||
// Shares assinging of the OpenMP OffloadModuleInterface and its assorted | ||
// attributes accross Flang tools (bbc/flang) | ||
void setOffloadModuleInterfaceAttributes( | ||
mlir::ModuleOp &module, bool isDevice) { | ||
// Should be registered by the OpenMPDialect | ||
if (auto offloadMod = llvm::dyn_cast<mlir::omp::OffloadModuleInterface>( | ||
module.getOperation())) { | ||
offloadMod.setIsDevice(isDevice); | ||
} | ||
} | ||
|
||
#endif // FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//===- OpenMPInterfaces.h - MLIR Interfaces for OpenMP ----------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file declares OpenMP Interface implementations for the OpenMP dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_DIALECT_OPENMP_OPENMPINTERFACES_H_ | ||
#define MLIR_DIALECT_OPENMP_OPENMPINTERFACES_H_ | ||
|
||
#include "mlir/Dialect/LLVMIR/LLVMDialect.h" | ||
#include "mlir/IR/Dialect.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
#include "mlir/IR/PatternMatch.h" | ||
#include "mlir/IR/SymbolTable.h" | ||
#include "mlir/Interfaces/ControlFlowInterfaces.h" | ||
#include "mlir/Interfaces/SideEffectInterfaces.h" | ||
|
||
#include "mlir/Dialect/OpenMP/OpenMPOpsInterfaces.h.inc" | ||
|
||
namespace mlir::omp { | ||
// You can override defaults here or implement more complex implementations of | ||
// functions. Or define a completely seperate external model implementation, | ||
// to override the existing implementation. | ||
struct OffloadModuleDefaultModel | ||
: public OffloadModuleInterface::ExternalModel<OffloadModuleDefaultModel, | ||
mlir::ModuleOp> {}; | ||
} // namespace mlir::omp | ||
|
||
#endif // MLIR_DIALECT_OPENMP_OPENMPINTERFACES_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters