-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][OpenMP] Add omp.target_triples attribute to the OffloadModuleInterface #100154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-mlir-openmp @llvm/pr-subscribers-mlir Author: Sergio Afonso (skatrak) ChangesThe This patch adds the Full diff: https://github.com/llvm/llvm-project/pull/100154.diff 1 Files Affected:
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
index 385aa8b1b016a..9e62dcd9253d6 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
@@ -351,6 +351,34 @@ def OffloadModuleInterface : OpInterface<"OffloadModuleInterface"> {
(ins "::mlir::omp::ClauseRequires":$clauses), [{}], [{
$_op->setAttr(mlir::StringAttr::get($_op->getContext(), "omp.requires"),
mlir::omp::ClauseRequiresAttr::get($_op->getContext(), clauses));
+ }]>,
+ InterfaceMethod<
+ /*description=*/[{
+ Get the omp.target_triples attribute on the operator if it's present and
+ return its value. If it doesn't exist, return an empty array by default.
+ }],
+ /*retTy=*/"::llvm::ArrayRef<::mlir::Attribute>",
+ /*methodName=*/"getTargetTriples",
+ (ins), [{}], [{
+ if (Attribute triplesAttr = $_op->getAttr("omp.target_triples"))
+ if (auto triples = ::llvm::dyn_cast<::mlir::ArrayAttr>(triplesAttr))
+ return triples.getValue();
+ return {};
+ }]>,
+ InterfaceMethod<
+ /*description=*/[{
+ Set the omp.target_triples attribute on the operation.
+ }],
+ /*retTy=*/"void",
+ /*methodName=*/"setTargetTriples",
+ (ins "::llvm::ArrayRef<::std::string>":$targetTriples), [{}], [{
+ auto names = ::llvm::to_vector(::llvm::map_range(
+ targetTriples, [&](::std::string str) -> ::mlir::Attribute {
+ return mlir::StringAttr::get($_op->getContext(), str);
+ }));
+ $_op->setAttr(
+ ::mlir::StringAttr::get($_op->getContext(), "omp.target_triples"),
+ ::mlir::ArrayAttr::get($_op->getContext(), names));
}]>
];
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
3dbb225
to
81fddab
Compare
3861b28
to
e59c38d
Compare
…nterface The `OffloadModuleInterface` holds getter/setter methods to access OpenMP dialect module-level discardable attributes used to hold general OpenMP compilation information. This patch adds the `omp.target_triples` attribute, which is intended to hold the list of offloading target triples linked to the host module in which it appears. This attribute should be empty when `omp.is_target_device=true`.
81fddab
to
2fd8456
Compare
The
OffloadModuleInterface
holds getter/setter methods to access OpenMP dialect module-level discardable attributes used to hold general OpenMP compilation information.This patch adds the
omp.target_triples
attribute, which is intended to hold the list of offloading target triples linked to the host module in which it appears. This attribute should be empty whenomp.is_target_device=true
.