[flang-commits] [flang] [flang] Adding lowering of TEAMs features to PRIF in MIF Dialect (PR #165573)
via flang-commits
flang-commits at lists.llvm.org
Fri Oct 31 15:19:02 PDT 2025
================
@@ -265,4 +283,141 @@ def mif_CoSumOp
}];
}
+//===----------------------------------------------------------------------===//
+// Teams
+//===----------------------------------------------------------------------===//
+
+def mif_FormTeamOp : mif_Op<"form_team", [AttrSizedOperandSegments]> {
+ let summary =
+ "Create a set of sibling teams whose parent team is the current team.";
+ let description = [{
+ Create a new team for each unique `team_number` value specified.
+ Each executing image will belong to the team whose `team_number` is equal
+ to the value of team-number on that image, and `team_var` becomes defined
+ with a value that identifies that team.
+
+ If `new_index` is specified, the image index of the executing image will take
+ this index in its new team. Otherwise, the new image index is processor
+ dependent.
+
+ Arguments:
+ - `team_number`: Shall be a positive integer.
+ - `team_var` : Shall be a variable of type TEAM_TYPE from the intrinsic
+ module ISO_FORTRAN_ENV.
+ - `new_index`(optional): Shall be an integer that correspond to the index that
+ the calling image will have in the new team.
+ }];
+
+ let arguments = (ins AnyIntegerType:$team_number,
+ Arg<fir_BoxType, "", [MemWrite]>:$team_var,
+ Optional<AnyIntegerType>:$new_index,
+ Arg<Optional<AnyReferenceLike>, "", [MemWrite]>:$stat,
+ Arg<Optional<AnyRefOrBoxType>, "", [MemWrite]>:$errmsg);
+
+ let assemblyFormat = [{
+ `team_number` $team_number `team_var` $team_var
+ (`new_index` $new_index^ )?
+ (`stat` $stat^ )?
+ (`errmsg` $errmsg^ )?
+ attr-dict `:` functional-type(operands, results)
+ }];
+}
+
+def mif_EndTeamOp : mif_Op<"end_team", [AttrSizedOperandSegments, Terminator,
+ ParentOneOf<["ChangeTeamOp"]>]> {
+ let summary = "Changes the current team to the parent team.";
+ let description = [{
+ The END TEAM operation completes the CHANGE TEAM construct and
+ restores the current team to the team that was current before
+ the CHANGE TEAM construct.
+ }];
+
+ let arguments = (ins Arg<Optional<AnyReferenceLike>, "", [MemWrite]>:$stat,
+ Arg<Optional<AnyRefOrBoxType>, "", [MemWrite]>:$errmsg);
+ let builders = [OpBuilder<(ins), [{ /* do nothing */ }]>];
+
+ let assemblyFormat = [{
+ (`stat` $stat^ )? (`errmsg` $errmsg^ )?
+ attr-dict `:` functional-type(operands, results)
+ }];
+}
+
+//===----------------------------------------------------------------------===//
+// NOTE: The CHANGE TEAM region will take a coarray association list in
+// argument. However, coarray management and coarray alias creation are not
+// yet supported by the dialect. The argument is therefore not yet supported by
+// this operation and will be added later.
+//===----------------------------------------------------------------------===//
+def mif_ChangeTeamOp
+ : region_Op<"change_team", [AttrSizedOperandSegments,
+ SingleBlockImplicitTerminator<"EndTeamOp">]> {
+ let summary = "Changes the current team.";
+ let description = [{
+ The CHANGE TEAM construct changes the current team to the specified new
+ team, which must be a child team of the current team.
+
+ ```
+ mif.change_team %team {
+ %x = fir.convert %i : (index) -> i32
+ ...
+ mif.end_team
+ }
+ }];
+
+ let arguments = (ins AnyRefOrBoxType:$team,
+ Arg<Optional<AnyReferenceLike>, "", [MemWrite]>:$stat,
+ Arg<Optional<AnyRefOrBoxType>, "", [MemWrite]>:$errmsg);
+ let regions = (region SizedRegion<1>:$region);
+
+ let skipDefaultBuilders = 1;
+ let builders =
+ [OpBuilder<(ins "mlir::Value":$team,
+ CArg<"bool", "true">:$ensureTerminaison,
----------------
jeanPerier wrote:
`ensureTermination`?
https://github.com/llvm/llvm-project/pull/165573
More information about the flang-commits
mailing list