[Mlir-commits] [clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Dec 11 04:31:42 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 8eb12f6775d288eece9a2bf090d2675c025bf457 977c8394f5f838ee360485e0e01de94aae66e23d --extensions cpp,h -- clang/lib/Parse/ParseOpenMP.cpp flang/lib/Lower/OpenMP/ClauseProcessor.cpp flang/lib/Lower/OpenMP/ClauseProcessor.h flang/lib/Lower/OpenMP/OpenMP.cpp flang/lib/Parser/openmp-parsers.cpp flang/lib/Semantics/check-omp-structure.cpp llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index 77454a6f35..37d2257516 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -1714,8 +1714,8 @@ void TargetOp::build(OpBuilder &builder, OperationState &state,
clauses.ifExpr, /*in_reduction_vars=*/{},
/*in_reduction_byref=*/nullptr, /*in_reduction_syms=*/nullptr,
clauses.isDevicePtrVars, clauses.mapVars, clauses.nowait,
- clauses.privateVars,
- makeArrayAttr(ctx, clauses.privateSyms), clauses.threadLimit);
+ clauses.privateVars, makeArrayAttr(ctx, clauses.privateSyms),
+ clauses.threadLimit);
}
LogicalResult TargetOp::verify() {
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 4da659dfe1..3122873f30 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -158,179 +158,185 @@ static LogicalResult checkImplementationStatus(Operation &op) {
if (!op.getAllocateVars().empty() || !op.getAllocatorVars().empty())
result = todo("allocate");
};
- auto checkBare = [&todo](auto op, LogicalResult &result) {
- if (op.getBare()) {
- result = todo("ompx_bare");
- };
- auto checkDepend = [&todo](auto op, LogicalResult &result) {
- if (!op.getDependVars().empty() || op.getDependKinds())
- result = todo("depend");
- };
- auto checkDevice = [&todo](auto op, LogicalResult &result) {
- if (op.getDevice())
- result = todo("device");
- };
- auto checkHasDeviceAddr = [&todo](auto op, LogicalResult &result) {
- if (!op.getHasDeviceAddrVars().empty())
- result = todo("has_device_addr");
- };
- auto checkHint = [](auto op, LogicalResult &) {
- if (op.getHint())
- op.emitWarning("hint clause discarded");
- };
- auto checkIf = [&todo](auto op, LogicalResult &result) {
- if (op.getIfExpr())
- result = todo("if");
- };
- auto checkInReduction = [&todo](auto op, LogicalResult &result) {
- if (!op.getInReductionVars().empty() || op.getInReductionByref() ||
- op.getInReductionSyms())
- result = todo("in_reduction");
- };
- auto checkIsDevicePtr = [&todo](auto op, LogicalResult &result) {
- if (!op.getIsDevicePtrVars().empty())
- result = todo("is_device_ptr");
- };
- auto checkLinear = [&todo](auto op, LogicalResult &result) {
- if (!op.getLinearVars().empty() || !op.getLinearStepVars().empty())
- result = todo("linear");
- };
- auto checkNontemporal = [&todo](auto op, LogicalResult &result) {
- if (!op.getNontemporalVars().empty())
- result = todo("nontemporal");
- };
- auto checkNowait = [&todo](auto op, LogicalResult &result) {
- if (op.getNowait())
- result = todo("nowait");
- };
- auto checkOrder = [&todo](auto op, LogicalResult &result) {
- if (op.getOrder() || op.getOrderMod())
- result = todo("order");
- };
- auto checkParLevelSimd = [&todo](auto op, LogicalResult &result) {
- if (op.getParLevelSimd())
- result = todo("parallelization-level");
- };
- auto checkPriority = [&todo](auto op, LogicalResult &result) {
- if (op.getPriority())
- result = todo("priority");
- };
- auto checkPrivate = [&todo](auto op, LogicalResult &result) {
- if (!op.getPrivateVars().empty() || op.getPrivateSyms())
- result = todo("privatization");
- };
- auto checkReduction = [&todo](auto op, LogicalResult &result) {
- if (!op.getReductionVars().empty() || op.getReductionByref() ||
- op.getReductionSyms())
- result = todo("reduction");
- };
- auto checkThreadLimit = [&todo](auto op, LogicalResult &result) {
- if (op.getThreadLimit())
- result = todo("thread_limit");
- };
- auto checkTaskReduction = [&todo](auto op, LogicalResult &result) {
- if (!op.getTaskReductionVars().empty() || op.getTaskReductionByref() ||
- op.getTaskReductionSyms())
- result = todo("task_reduction");
- };
- auto checkUntied = [&todo](auto op, LogicalResult &result) {
- if (op.getUntied())
- result = todo("untied");
- };
-
- LogicalResult result = success();
- llvm::TypeSwitch<Operation &>(op)
- .Case([&](omp::OrderedRegionOp op) { checkParLevelSimd(op, result); })
- .Case([&](omp::SectionsOp op) {
- checkAllocate(op, result);
- checkPrivate(op, result);
- })
- .Case([&](omp::SingleOp op) {
- checkAllocate(op, result);
- checkPrivate(op, result);
- })
- .Case([&](omp::TeamsOp op) {
- checkAllocate(op, result);
- checkPrivate(op, result);
- checkReduction(op, result);
- })
- .Case([&](omp::TaskOp op) {
- checkAllocate(op, result);
- checkInReduction(op, result);
- checkPriority(op, result);
- checkUntied(op, result);
- })
- .Case([&](omp::TaskgroupOp op) {
- checkAllocate(op, result);
- checkTaskReduction(op, result);
- })
- .Case([&](omp::TaskwaitOp op) {
- checkDepend(op, result);
- checkNowait(op, result);
- })
- .Case([&](omp::WsloopOp op) {
- checkAllocate(op, result);
- checkLinear(op, result);
- checkOrder(op, result);
- })
- .Case([&](omp::ParallelOp op) { checkAllocate(op, result); })
- .Case([&](omp::SimdOp op) {
- checkAligned(op, result);
- checkLinear(op, result);
- checkNontemporal(op, result);
- checkPrivate(op, result);
- checkReduction(op, result);
- })
- .Case<omp::AtomicReadOp, omp::AtomicWriteOp, omp::AtomicUpdateOp,
- omp::AtomicCaptureOp>([&](auto op) { checkHint(op, result); })
- .Case<omp::TargetEnterDataOp, omp::TargetExitDataOp, omp::TargetUpdateOp>(
- [&](auto op) { checkDepend(op, result); })
- .Case([&](omp::TargetOp op) {
- checkAllocate(op, result);
- checkBare(op, result);
- checkDevice(op, result);
- checkHasDeviceAddr(op, result);
- checkIf(op, result);
- checkInReduction(op, result);
- checkIsDevicePtr(op, result);
- // Privatization clauses are supported, except on some situations, so we
- // need to check here whether any of these unsupported cases are being
- // translated.
- if (std::optional<ArrayAttr> privateSyms = op.getPrivateSyms()) {
- for (Attribute privatizerNameAttr : *privateSyms) {
- omp::PrivateClauseOp privatizer = findPrivatizer(
- op.getOperation(), cast<SymbolRefAttr>(privatizerNameAttr));
-
- if (privatizer.getDataSharingType() ==
- omp::DataSharingClauseType::FirstPrivate)
- result = todo("firstprivate");
-
- if (!privatizer.getDeallocRegion().empty())
- result = op.emitError("not yet implemented: privatization of "
- "structures in omp.target operation");
- }
- }
- checkThreadLimit(op, result);
- })
- .Default([](Operation &) {
- // Assume all clauses for an operation can be translated unless they are
- // checked above.
- });
- return result;
-}
+ auto checkBare =
+ [&todo](auto op, LogicalResult &result) {
+ if (op.getBare()) {
+ result = todo("ompx_bare");
+ };
+ auto checkDepend = [&todo](auto op, LogicalResult &result) {
+ if (!op.getDependVars().empty() || op.getDependKinds())
+ result = todo("depend");
+ };
+ auto checkDevice = [&todo](auto op, LogicalResult &result) {
+ if (op.getDevice())
+ result = todo("device");
+ };
+ auto checkHasDeviceAddr = [&todo](auto op, LogicalResult &result) {
+ if (!op.getHasDeviceAddrVars().empty())
+ result = todo("has_device_addr");
+ };
+ auto checkHint = [](auto op, LogicalResult &) {
+ if (op.getHint())
+ op.emitWarning("hint clause discarded");
+ };
+ auto checkIf = [&todo](auto op, LogicalResult &result) {
+ if (op.getIfExpr())
+ result = todo("if");
+ };
+ auto checkInReduction = [&todo](auto op, LogicalResult &result) {
+ if (!op.getInReductionVars().empty() || op.getInReductionByref() ||
+ op.getInReductionSyms())
+ result = todo("in_reduction");
+ };
+ auto checkIsDevicePtr = [&todo](auto op, LogicalResult &result) {
+ if (!op.getIsDevicePtrVars().empty())
+ result = todo("is_device_ptr");
+ };
+ auto checkLinear = [&todo](auto op, LogicalResult &result) {
+ if (!op.getLinearVars().empty() || !op.getLinearStepVars().empty())
+ result = todo("linear");
+ };
+ auto checkNontemporal = [&todo](auto op, LogicalResult &result) {
+ if (!op.getNontemporalVars().empty())
+ result = todo("nontemporal");
+ };
+ auto checkNowait = [&todo](auto op, LogicalResult &result) {
+ if (op.getNowait())
+ result = todo("nowait");
+ };
+ auto checkOrder = [&todo](auto op, LogicalResult &result) {
+ if (op.getOrder() || op.getOrderMod())
+ result = todo("order");
+ };
+ auto checkParLevelSimd = [&todo](auto op, LogicalResult &result) {
+ if (op.getParLevelSimd())
+ result = todo("parallelization-level");
+ };
+ auto checkPriority = [&todo](auto op, LogicalResult &result) {
+ if (op.getPriority())
+ result = todo("priority");
+ };
+ auto checkPrivate = [&todo](auto op, LogicalResult &result) {
+ if (!op.getPrivateVars().empty() || op.getPrivateSyms())
+ result = todo("privatization");
+ };
+ auto checkReduction = [&todo](auto op, LogicalResult &result) {
+ if (!op.getReductionVars().empty() || op.getReductionByref() ||
+ op.getReductionSyms())
+ result = todo("reduction");
+ };
+ auto checkThreadLimit = [&todo](auto op, LogicalResult &result) {
+ if (op.getThreadLimit())
+ result = todo("thread_limit");
+ };
+ auto checkTaskReduction = [&todo](auto op, LogicalResult &result) {
+ if (!op.getTaskReductionVars().empty() ||
+ op.getTaskReductionByref() || op.getTaskReductionSyms())
+ result = todo("task_reduction");
+ };
+ auto checkUntied = [&todo](auto op, LogicalResult &result) {
+ if (op.getUntied())
+ result = todo("untied");
+ };
+
+ LogicalResult result = success();
+ llvm::TypeSwitch<Operation &>(op)
+ .Case(
+ [&](omp::OrderedRegionOp op) { checkParLevelSimd(op, result); })
+ .Case([&](omp::SectionsOp op) {
+ checkAllocate(op, result);
+ checkPrivate(op, result);
+ })
+ .Case([&](omp::SingleOp op) {
+ checkAllocate(op, result);
+ checkPrivate(op, result);
+ })
+ .Case([&](omp::TeamsOp op) {
+ checkAllocate(op, result);
+ checkPrivate(op, result);
+ checkReduction(op, result);
+ })
+ .Case([&](omp::TaskOp op) {
+ checkAllocate(op, result);
+ checkInReduction(op, result);
+ checkPriority(op, result);
+ checkUntied(op, result);
+ })
+ .Case([&](omp::TaskgroupOp op) {
+ checkAllocate(op, result);
+ checkTaskReduction(op, result);
+ })
+ .Case([&](omp::TaskwaitOp op) {
+ checkDepend(op, result);
+ checkNowait(op, result);
+ })
+ .Case([&](omp::WsloopOp op) {
+ checkAllocate(op, result);
+ checkLinear(op, result);
+ checkOrder(op, result);
+ })
+ .Case([&](omp::ParallelOp op) { checkAllocate(op, result); })
+ .Case([&](omp::SimdOp op) {
+ checkAligned(op, result);
+ checkLinear(op, result);
+ checkNontemporal(op, result);
+ checkPrivate(op, result);
+ checkReduction(op, result);
+ })
+ .Case<omp::AtomicReadOp, omp::AtomicWriteOp, omp::AtomicUpdateOp,
+ omp::AtomicCaptureOp>([&](auto op) { checkHint(op, result); })
+ .Case<omp::TargetEnterDataOp, omp::TargetExitDataOp,
+ omp::TargetUpdateOp>(
+ [&](auto op) { checkDepend(op, result); })
+ .Case([&](omp::TargetOp op) {
+ checkAllocate(op, result);
+ checkBare(op, result);
+ checkDevice(op, result);
+ checkHasDeviceAddr(op, result);
+ checkIf(op, result);
+ checkInReduction(op, result);
+ checkIsDevicePtr(op, result);
+ // Privatization clauses are supported, except on some situations,
+ // so we need to check here whether any of these unsupported cases
+ // are being translated.
+ if (std::optional<ArrayAttr> privateSyms = op.getPrivateSyms()) {
+ for (Attribute privatizerNameAttr : *privateSyms) {
+ omp::PrivateClauseOp privatizer =
+ findPrivatizer(op.getOperation(),
+ cast<SymbolRefAttr>(privatizerNameAttr));
+
+ if (privatizer.getDataSharingType() ==
+ omp::DataSharingClauseType::FirstPrivate)
+ result = todo("firstprivate");
+
+ if (!privatizer.getDeallocRegion().empty())
+ result =
+ op.emitError("not yet implemented: privatization of "
+ "structures in omp.target operation");
+ }
+ }
+ checkThreadLimit(op, result);
+ })
+ .Default([](Operation &) {
+ // Assume all clauses for an operation can be translated unless
+ // they are checked above.
+ });
+ return result;
+ }
-static LogicalResult handleError(llvm::Error error, Operation &op) {
- LogicalResult result = success();
- if (error) {
- llvm::handleAllErrors(
- std::move(error),
- [&](const PreviouslyReportedError &) { result = failure(); },
- [&](const llvm::ErrorInfoBase &err) {
- result = op.emitError(err.message());
- });
+ static LogicalResult
+ handleError(llvm::Error error, Operation & op) {
+ LogicalResult result = success();
+ if (error) {
+ llvm::handleAllErrors(
+ std::move(error),
+ [&](const PreviouslyReportedError &) { result = failure(); },
+ [&](const llvm::ErrorInfoBase &err) {
+ result = op.emitError(err.message());
+ });
+ }
+ return result;
}
- return result;
-}
template <typename T>
static LogicalResult handleError(llvm::Expected<T> &result, Operation &op) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/111106
More information about the Mlir-commits
mailing list