[clang] [OpenACC][CIR] Implement 'num_gangs' lowering (PR #137216)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 24 11:11:58 PDT 2025
================
@@ -95,19 +95,41 @@ class OpenACCClauseCIREmitter final
.CaseLower("radeon", mlir::acc::DeviceType::Radeon);
}
- // Handle a clause affected by the 'device-type' to the point that they need
- // to have the attributes added in the correct/corresponding order, such as
- // 'num_workers' or 'vector_length' on a compute construct. For cases where we
- // don't have an expression 'argument' that needs to be added to an operand
- // and only care about the 'device-type' list, we can use this with 'argument'
- // as 'std::nullopt'. If 'argument' is NOT 'std::nullopt' (that is, has a
- // value), argCollection must also be non-null. For cases where we don't have
- // an argument that needs to be added to an additional one (such as asyncOnly)
- // we can use this with 'argument' as std::nullopt.
- mlir::ArrayAttr handleDeviceTypeAffectedClause(
- mlir::ArrayAttr existingDeviceTypes,
- std::optional<mlir::Value> argument = std::nullopt,
- mlir::MutableOperandRange *argCollection = nullptr) {
+ // Overload of this function that only returns the device-types list.
+ mlir::ArrayAttr
+ handleDeviceTypeAffectedClause(mlir::ArrayAttr existingDeviceTypes) {
+ mlir::ValueRange argument;
+ mlir::MutableOperandRange range{operation};
+
+ return handleDeviceTypeAffectedClause(existingDeviceTypes, argument, range);
+ }
+ // Overload of this function for when 'segments' aren't necessary.
+ mlir::ArrayAttr
+ handleDeviceTypeAffectedClause(mlir::ArrayAttr existingDeviceTypes,
+ mlir::ValueRange argument,
+ mlir::MutableOperandRange argCollection) {
+ llvm::SmallVector<int32_t> segments;
+ assert(argument.size() <= 1 &&
+ "Overload only for cases where segments don't need to be added");
+ return handleDeviceTypeAffectedClause(existingDeviceTypes, argument,
+ argCollection, segments);
+ }
+
+ // Handle a clause affected by the 'device_type' to the point that they need
+ // to have attributes added in the correct/corresponding order, such as
+ // 'num_workers' or 'vector_length' on a compute construct. The 'argument' is
+ // a collection of operands that need to be appended to the `argCollection` as
+ // we're adding a 'device_type' entry. If there is more than 0 elements in
+ // the 'argument', the collection must be non-null, as it is needed to add to
+ // it.
+ // As some clauses, such as 'num_gangs' or 'wait' require a 'segments' list to
----------------
erichkeane wrote:
Hmm.. 'segments' are a little weird, they are a little bit MLIR/OpenACC-Dialect specific perhaps. I'll try to improve the comment.
As far as zero-arguments between non-zero segments, my understanding is no.
https://github.com/llvm/llvm-project/pull/137216
More information about the cfe-commits
mailing list