[Mlir-commits] [mlir] [MLIR] Extend MPI dialect (PR #123255)
Sergio Sánchez Ramírez
llvmlistbot at llvm.org
Mon Jan 27 02:13:30 PST 2025
https://github.com/mofeing updated https://github.com/llvm/llvm-project/pull/123255
>From 1fbae54306aff0c55ec544675bedb961574c2837 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez+git at bsc.es>
Date: Thu, 16 Jan 2025 22:31:59 +0100
Subject: [PATCH 01/17] Add `MPI_Comm`, `MPI_Request`, `MPI_Status`, `MPI_Op`
type definitions
---
mlir/include/mlir/Dialect/MPI/IR/MPITypes.td | 30 ++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPITypes.td b/mlir/include/mlir/Dialect/MPI/IR/MPITypes.td
index 87eefa719d45c0..1d96b49d16585b 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPITypes.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPITypes.td
@@ -40,4 +40,34 @@ def MPI_Retval : MPI_Type<"Retval", "retval"> {
}];
}
+// TODO
+def MPI_Comm : MPI_Type<"Comm", "comm"> {
+ let summary = "..."
+ let description = [{
+ This type represents a handler to the MPI communicator.
+ }]
+}
+
+// TODO
+def MPI_Request : MPI_Type<"Request", "request"> {
+ let summary = "..."
+ let description = [{
+ This type represents a handler to an asynchronous requests.
+ }]
+}
+
+// TODO
+def MPI_Status : MPI_Type<"Status", "status"> {
+ let summary = "";
+ let description = [{
+ }];
+}
+
+// TODO
+def MPI_Op : MPI_Type<"Op", "op"> {
+ let summary = "";
+ let description = [{
+ }];
+}
+
#endif // MLIR_DIALECT_MPI_IR_MPITYPES_TD
>From dc84ca4b87412dcfa9c83c48ae9916663c7ca38e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez+git at bsc.es>
Date: Thu, 16 Jan 2025 23:02:23 +0100
Subject: [PATCH 02/17] Add `MPI_CommSize`, `MPI_ISend`, `MPI_IRecv` ops
---
mlir/include/mlir/Dialect/MPI/IR/MPIOps.td | 85 ++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
index 240fac5104c34f..8719b67cd7f5f0 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
@@ -59,6 +59,28 @@ def MPI_CommRankOp : MPI_Op<"comm_rank", []> {
let assemblyFormat = "attr-dict `:` type(results)";
}
+//===----------------------------------------------------------------------===//
+// CommSizeOp
+//===----------------------------------------------------------------------===//
+
+def MPI_CommSizeOp : MPI_Op<"comm_size", []> {
+ let summary = "Get the size of the group associated to the communicator, equivalent to "
+ "`MPI_Comm_size(MPI_COMM_WORLD, &size)`";
+ let description = [{
+ Communicators other than `MPI_COMM_WORLD` are not supported for now.
+
+ This operation can optionally return an `!mpi.retval` value that can be used
+ to check for errors.
+ }];
+
+ let results = (
+ outs Optional<MPI_Retval> : $retval,
+ I32 : $size
+ );
+
+ let assemblyFormat = "attr-dict `:` type(results)";
+}
+
//===----------------------------------------------------------------------===//
// SendOp
//===----------------------------------------------------------------------===//
@@ -87,6 +109,37 @@ def MPI_SendOp : MPI_Op<"send", []> {
let hasCanonicalizer = 1;
}
+//===----------------------------------------------------------------------===//
+// ISendOp
+//===----------------------------------------------------------------------===//
+
+// TODO what about request handler?
+// NOTE datatype & count args are implicit by the type of the first argument (i.e. memref of eltype)
+// NOTE other communicators not yet supported by the `mpi` dialect
+def MPI_ISendOp : MPI_Op<"isend", []> {
+ let summary =
+ "Equivalent to `MPI_Isend(ptr, size, dtype, dest, tag, MPI_COMM_WORLD)`";
+ let description = [{
+ MPI_Isend begins a non-blocking send of `size` elements of type `dtype` to rank
+ `dest`. The `tag` value and communicator enables the library to determine
+ the matching of multiple sends and receives between the same ranks.
+
+ Communicators other than `MPI_COMM_WORLD` are not supprted for now.
+
+ This operation can optionally return an `!mpi.retval` value that can be used
+ to check for errors.
+ }];
+
+ let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank);
+
+ let results = (outs Optional<MPI_Retval>:$retval);
+
+ let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:` "
+ "type($ref) `,` type($tag) `,` type($rank)"
+ "(`->` type($retval)^)?";
+ let hasCanonicalizer = 1;
+}
+
//===----------------------------------------------------------------------===//
// RecvOp
//===----------------------------------------------------------------------===//
@@ -118,6 +171,38 @@ def MPI_RecvOp : MPI_Op<"recv", []> {
let hasCanonicalizer = 1;
}
+//===----------------------------------------------------------------------===//
+// IRecvOp
+//===----------------------------------------------------------------------===//
+
+// TODO same as MPI_ISendOp
+def MPI_IRecvOp : MPI_Op<"irecv", []> {
+ let summary = "Equivalent to `MPI_Irecv(ptr, size, dtype, dest, tag, "
+ "MPI_COMM_WORLD, MPI_STATUS_IGNORE)`";
+ let description = [{
+ MPI_Irecv begins a non-blocking receive of `size` elements of type `dtype`
+ from rank `dest`. The `tag` value and communicator enables the library to
+ determine the matching of multiple sends and receives between the same
+ ranks.
+
+ Communicators other than `MPI_COMM_WORLD` are not supprted for now.
+ The MPI_Status is set to `MPI_STATUS_IGNORE`, as the status object
+ is not yet ported to MLIR.
+
+ This operation can optionally return an `!mpi.retval` value that can be used
+ to check for errors.
+ }];
+
+ let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank);
+
+ let results = (outs Optional<MPI_Retval>:$retval);
+
+ let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:` "
+ "type($ref) `,` type($tag) `,` type($rank)"
+ "(`->` type($retval)^)?";
+ let hasCanonicalizer = 1;
+}
+
//===----------------------------------------------------------------------===//
// FinalizeOp
>From 2ee10ab60bb793b9164b0795e6657ceccc4704ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez+git at bsc.es>
Date: Thu, 16 Jan 2025 23:02:34 +0100
Subject: [PATCH 03/17] Fix typo
---
mlir/include/mlir/Dialect/MPI/IR/MPIOps.td | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
index 8719b67cd7f5f0..4be5a6dfea7777 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
@@ -251,7 +251,7 @@ def MPI_RetvalCheckOp : MPI_Op<"retval_check", []> {
//===----------------------------------------------------------------------===//
-// RetvalCheckOp
+// ErrorClassOp
//===----------------------------------------------------------------------===//
def MPI_ErrorClassOp : MPI_Op<"error_class", []> {
>From 539bf43b5cf705e64183d7d84f08e7132dac3872 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Sat, 25 Jan 2025 20:59:08 +0100
Subject: [PATCH 04/17] Finish types
---
mlir/include/mlir/Dialect/MPI/IR/MPITypes.td | 24 ++++++++++++++++----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPITypes.td b/mlir/include/mlir/Dialect/MPI/IR/MPITypes.td
index 1d96b49d16585b..20cde07d9a4b98 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPITypes.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPITypes.td
@@ -40,7 +40,10 @@ def MPI_Retval : MPI_Type<"Retval", "retval"> {
}];
}
-// TODO
+//===----------------------------------------------------------------------===//
+// mpi::CommType
+//===----------------------------------------------------------------------===//
+
def MPI_Comm : MPI_Type<"Comm", "comm"> {
let summary = "..."
let description = [{
@@ -48,25 +51,36 @@ def MPI_Comm : MPI_Type<"Comm", "comm"> {
}]
}
-// TODO
+//===----------------------------------------------------------------------===//
+// mpi::RequestType
+//===----------------------------------------------------------------------===//
+
def MPI_Request : MPI_Type<"Request", "request"> {
let summary = "..."
let description = [{
- This type represents a handler to an asynchronous requests.
+ This type represents a handler to an asynchronous request.
}]
}
-// TODO
+//===----------------------------------------------------------------------===//
+// mpi::StatusType
+//===----------------------------------------------------------------------===//
+
def MPI_Status : MPI_Type<"Status", "status"> {
let summary = "";
let description = [{
+ This type represents the status of a reception operation.
}];
}
-// TODO
+//===----------------------------------------------------------------------===//
+// mpi::OpType
+//===----------------------------------------------------------------------===//
+
def MPI_Op : MPI_Type<"Op", "op"> {
let summary = "";
let description = [{
+ This type represents a handle to a operation that can be used in MPI reduce and scan routines.
}];
}
>From 662998d610c56eb83dd9897a94b8bd4131e95191 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Sun, 26 Jan 2025 11:35:36 +0100
Subject: [PATCH 05/17] Define `MPI_Op` enum & attr
---
mlir/include/mlir/Dialect/MPI/IR/MPI.td | 40 +++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPI.td b/mlir/include/mlir/Dialect/MPI/IR/MPI.td
index 643612e1e2ee89..182de03a5a8057 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPI.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPI.td
@@ -215,4 +215,44 @@ def MPI_ErrorClassAttr : EnumAttr<MPI_Dialect, MPI_ErrorClassEnum, "errclass"> {
let assemblyFormat = "`<` $value `>`";
}
+// TODO is it ok to have them as I32?
+def MPI_OpNull : I32EnumAttrCase<"MPI_OP_NULL", 0, "MPI_OP_NULL">;
+def MPI_OpMax : I32EnumAttrCase<"MPI_MAX", 1, "MPI_MAX">;
+def MPI_OpMin : I32EnumAttrCase<"MPI_MIN", 2, "MPI_MIN">;
+def MPI_OpSum : I32EnumAttrCase<"MPI_SUM", 3, "MPI_SUM">;
+def MPI_OpProd : I32EnumAttrCase<"MPI_PROD", 4, "MPI_PROD">;
+def MPI_OpLand : I32EnumAttrCase<"MPI_LAND", 5, "MPI_LAND">;
+def MPI_OpBand : I32EnumAttrCase<"MPI_BAND", 6, "MPI_BAND">;
+def MPI_OpLor : I32EnumAttrCase<"MPI_LOR", 7, "MPI_LOR">;
+def MPI_OpBor : I32EnumAttrCase<"MPI_BOR", 8, "MPI_BOR">;
+def MPI_OpLxor : I32EnumAttrCase<"MPI_LXOR", 9, "MPI_LXOR">;
+def MPI_OpBxor : I32EnumAttrCase<"MPI_BXOR", 10, "MPI_BXOR">;
+def MPI_OpMinloc : I32EnumAttrCase<"MPI_MINLOC", 11, "MPI_MINLOC">;
+def MPI_OpMaxloc : I32EnumAttrCase<"MPI_MAXLOC", 12, "MPI_MAXLOC">;
+def MPI_OpReplace : I32EnumAttrCase<"MPI_REPLACE", 13, "MPI_REPLACE">;
+
+def MPI_OpClassEnum : I32EnumAttr<"MPI_OpClassEnum", "MPI operation class", [
+ MPI_OpNull,
+ MPI_OpMax,
+ MPI_OpMin,
+ MPI_OpSum,
+ MPI_OpProd,
+ MPI_OpLand,
+ MPI_OpBand,
+ MPI_OpLor,
+ MPI_OpBor,
+ MPI_OpLxor,
+ MPI_OpBxor,
+ MPI_OpMinloc,
+ MPI_OpMaxloc,
+ MPI_OpReplace
+ ]> {
+ let genSpecializedAttr = 0;
+ let cppNamespace = "::mlir::mpi";
+}
+
+def MPI_OpClassAttr : EnumAttr<MPI_Dialect, MPI_OpClassEnum, "opclass"> {
+ let assemblyFormat = "`<` $value `>`";
+}
+
#endif // MLIR_DIALECT_MPI_IR_MPI_TD
>From c1ec63c24ff9b1af1a4dde393b1e90767605044b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Sun, 26 Jan 2025 20:18:36 +0100
Subject: [PATCH 06/17] Add communicator argument to mpi ops as optional input
argument
---
mlir/include/mlir/Dialect/MPI/IR/MPIOps.td | 38 ++++++++++++----------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
index 4be5a6dfea7777..1330313c41a8c3 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
@@ -43,14 +43,16 @@ def MPI_InitOp : MPI_Op<"init", []> {
def MPI_CommRankOp : MPI_Op<"comm_rank", []> {
let summary = "Get the current rank, equivalent to "
- "`MPI_Comm_rank(MPI_COMM_WORLD, &rank)`";
+ "`MPI_Comm_rank(comm, &rank)`";
let description = [{
- Communicators other than `MPI_COMM_WORLD` are not supported for now.
+ If communicator is not specified, `MPI_COMM_WORLD` is used by default.
This operation can optionally return an `!mpi.retval` value that can be used
to check for errors.
}];
+ let arguments = (ins Optional<MPI_Comm> : $comm);
+
let results = (
outs Optional<MPI_Retval> : $retval,
I32 : $rank
@@ -65,14 +67,16 @@ def MPI_CommRankOp : MPI_Op<"comm_rank", []> {
def MPI_CommSizeOp : MPI_Op<"comm_size", []> {
let summary = "Get the size of the group associated to the communicator, equivalent to "
- "`MPI_Comm_size(MPI_COMM_WORLD, &size)`";
+ "`MPI_Comm_size(comm, &size)`";
let description = [{
- Communicators other than `MPI_COMM_WORLD` are not supported for now.
+ If communicator is not specified, `MPI_COMM_WORLD` is used by default.
This operation can optionally return an `!mpi.retval` value that can be used
to check for errors.
}];
+ let arguments = (ins Optional<MPI_Comm> : $comm);
+
let results = (
outs Optional<MPI_Retval> : $retval,
I32 : $size
@@ -87,19 +91,19 @@ def MPI_CommSizeOp : MPI_Op<"comm_size", []> {
def MPI_SendOp : MPI_Op<"send", []> {
let summary =
- "Equivalent to `MPI_Send(ptr, size, dtype, dest, tag, MPI_COMM_WORLD)`";
+ "Equivalent to `MPI_Send(ptr, size, dtype, dest, tag, comm)`";
let description = [{
MPI_Send performs a blocking send of `size` elements of type `dtype` to rank
`dest`. The `tag` value and communicator enables the library to determine
the matching of multiple sends and receives between the same ranks.
- Communicators other than `MPI_COMM_WORLD` are not supprted for now.
+ If communicator is not specified, `MPI_COMM_WORLD` is used by default.
This operation can optionally return an `!mpi.retval` value that can be used
to check for errors.
}];
- let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank);
+ let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank, Optional<MPI_Comm> : $comm);
let results = (outs Optional<MPI_Retval>:$retval);
@@ -115,22 +119,21 @@ def MPI_SendOp : MPI_Op<"send", []> {
// TODO what about request handler?
// NOTE datatype & count args are implicit by the type of the first argument (i.e. memref of eltype)
-// NOTE other communicators not yet supported by the `mpi` dialect
def MPI_ISendOp : MPI_Op<"isend", []> {
let summary =
- "Equivalent to `MPI_Isend(ptr, size, dtype, dest, tag, MPI_COMM_WORLD)`";
+ "Equivalent to `MPI_Isend(ptr, size, dtype, dest, tag, comm)`";
let description = [{
MPI_Isend begins a non-blocking send of `size` elements of type `dtype` to rank
`dest`. The `tag` value and communicator enables the library to determine
the matching of multiple sends and receives between the same ranks.
- Communicators other than `MPI_COMM_WORLD` are not supprted for now.
+ If communicator is not specified, `MPI_COMM_WORLD` is used by default.
This operation can optionally return an `!mpi.retval` value that can be used
to check for errors.
}];
- let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank);
+ let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank, Optional<MPI_Comm> : $comm);
let results = (outs Optional<MPI_Retval>:$retval);
@@ -146,14 +149,14 @@ def MPI_ISendOp : MPI_Op<"isend", []> {
def MPI_RecvOp : MPI_Op<"recv", []> {
let summary = "Equivalent to `MPI_Recv(ptr, size, dtype, dest, tag, "
- "MPI_COMM_WORLD, MPI_STATUS_IGNORE)`";
+ "comm, MPI_STATUS_IGNORE)`";
let description = [{
MPI_Recv performs a blocking receive of `size` elements of type `dtype`
from rank `dest`. The `tag` value and communicator enables the library to
determine the matching of multiple sends and receives between the same
ranks.
- Communicators other than `MPI_COMM_WORLD` are not supprted for now.
+ If communicator is not specified, `MPI_COMM_WORLD` is used by default.
The MPI_Status is set to `MPI_STATUS_IGNORE`, as the status object
is not yet ported to MLIR.
@@ -161,7 +164,7 @@ def MPI_RecvOp : MPI_Op<"recv", []> {
to check for errors.
}];
- let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank);
+ let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank, Optional<MPI_Comm> : $comm);
let results = (outs Optional<MPI_Retval>:$retval);
@@ -175,17 +178,16 @@ def MPI_RecvOp : MPI_Op<"recv", []> {
// IRecvOp
//===----------------------------------------------------------------------===//
-// TODO same as MPI_ISendOp
def MPI_IRecvOp : MPI_Op<"irecv", []> {
let summary = "Equivalent to `MPI_Irecv(ptr, size, dtype, dest, tag, "
- "MPI_COMM_WORLD, MPI_STATUS_IGNORE)`";
+ "comm, MPI_STATUS_IGNORE)`";
let description = [{
MPI_Irecv begins a non-blocking receive of `size` elements of type `dtype`
from rank `dest`. The `tag` value and communicator enables the library to
determine the matching of multiple sends and receives between the same
ranks.
- Communicators other than `MPI_COMM_WORLD` are not supprted for now.
+ If communicator is not specified, `MPI_COMM_WORLD` is used by default.
The MPI_Status is set to `MPI_STATUS_IGNORE`, as the status object
is not yet ported to MLIR.
@@ -193,7 +195,7 @@ def MPI_IRecvOp : MPI_Op<"irecv", []> {
to check for errors.
}];
- let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank);
+ let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank, Optional<MPI_Comm> : $comm);
let results = (outs Optional<MPI_Retval>:$retval);
>From 7eda7915fd48b8b52117a2a8075cfc466b25c905 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Sun, 26 Jan 2025 20:21:40 +0100
Subject: [PATCH 07/17] Add summary of new mpi types
---
mlir/include/mlir/Dialect/MPI/IR/MPITypes.td | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPITypes.td b/mlir/include/mlir/Dialect/MPI/IR/MPITypes.td
index 20cde07d9a4b98..a7f96c0530883b 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPITypes.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPITypes.td
@@ -45,10 +45,10 @@ def MPI_Retval : MPI_Type<"Retval", "retval"> {
//===----------------------------------------------------------------------===//
def MPI_Comm : MPI_Type<"Comm", "comm"> {
- let summary = "..."
+ let summary = "MPI communicator handler";
let description = [{
This type represents a handler to the MPI communicator.
- }]
+ }];
}
//===----------------------------------------------------------------------===//
@@ -56,10 +56,10 @@ def MPI_Comm : MPI_Type<"Comm", "comm"> {
//===----------------------------------------------------------------------===//
def MPI_Request : MPI_Type<"Request", "request"> {
- let summary = "..."
+ let summary = "MPI asynchronous request handler";
let description = [{
This type represents a handler to an asynchronous request.
- }]
+ }];
}
//===----------------------------------------------------------------------===//
@@ -67,7 +67,7 @@ def MPI_Request : MPI_Type<"Request", "request"> {
//===----------------------------------------------------------------------===//
def MPI_Status : MPI_Type<"Status", "status"> {
- let summary = "";
+ let summary = "MPI reception operation status type";
let description = [{
This type represents the status of a reception operation.
}];
@@ -78,7 +78,7 @@ def MPI_Status : MPI_Type<"Status", "status"> {
//===----------------------------------------------------------------------===//
def MPI_Op : MPI_Type<"Op", "op"> {
- let summary = "";
+ let summary = "MPI operation handler";
let description = [{
This type represents a handle to a operation that can be used in MPI reduce and scan routines.
}];
>From b97a541bb700df7eaea365f4221d351433bfc3bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Sun, 26 Jan 2025 20:26:37 +0100
Subject: [PATCH 08/17] format code
---
mlir/include/mlir/Dialect/MPI/IR/MPIOps.td | 4 ----
1 file changed, 4 deletions(-)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
index 1330313c41a8c3..de62536bf80d5f 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
@@ -205,7 +205,6 @@ def MPI_IRecvOp : MPI_Op<"irecv", []> {
let hasCanonicalizer = 1;
}
-
//===----------------------------------------------------------------------===//
// FinalizeOp
//===----------------------------------------------------------------------===//
@@ -226,7 +225,6 @@ def MPI_FinalizeOp : MPI_Op<"finalize", []> {
let assemblyFormat = "attr-dict (`:` type($retval)^)?";
}
-
//===----------------------------------------------------------------------===//
// RetvalCheckOp
//===----------------------------------------------------------------------===//
@@ -250,8 +248,6 @@ def MPI_RetvalCheckOp : MPI_Op<"retval_check", []> {
let assemblyFormat = "$val `=` $errclass attr-dict `:` type($res)";
}
-
-
//===----------------------------------------------------------------------===//
// ErrorClassOp
//===----------------------------------------------------------------------===//
>From d5725a8994ab1f913377abcbe56cbab9e52f0cd2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Sun, 26 Jan 2025 20:50:49 +0100
Subject: [PATCH 09/17] Add `mpi.comm_split` op
---
mlir/include/mlir/Dialect/MPI/IR/MPIOps.td | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
index de62536bf80d5f..913e7ab9986eff 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
@@ -85,6 +85,33 @@ def MPI_CommSizeOp : MPI_Op<"comm_size", []> {
let assemblyFormat = "attr-dict `:` type(results)";
}
+//===----------------------------------------------------------------------===//
+// CommSplitOp
+//===----------------------------------------------------------------------===//
+
+def MPI_CommSplit : MPI_Op<"comm_split", []> {
+ let summary = "Partition the group associated to the given communicator into "
+ "disjoint subgroups";
+ let description = [{
+ This operation splits the communicator into multiple sub-communicators.
+ The color value determines the group of processes that will be part of the
+ new communicator. The key value determines the rank of the calling process
+ in the new communicator.
+
+ This operation can optionally return an `!mpi.retval` value that can be used
+ to check for errors.
+ }];
+
+ let arguments = (MPI_Comm : $comm, I32 : $color, I32 : $key);
+
+ let results = (
+ outs Optional<MPI_Retval> : $retval,
+ MPI_Comm : $newcomm
+ );
+
+ let assemblyFormat = "`(` $color `,` $key `)` attr-dict `:` type(results)";
+}
+
//===----------------------------------------------------------------------===//
// SendOp
//===----------------------------------------------------------------------===//
>From 1a68b34dc147adabb04507d3ad80628424ea01bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Sun, 26 Jan 2025 20:52:10 +0100
Subject: [PATCH 10/17] Add `mpi.barrier` op
---
mlir/include/mlir/Dialect/MPI/IR/MPIOps.td | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
index 913e7ab9986eff..78d624bc19f783 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
@@ -232,6 +232,25 @@ def MPI_IRecvOp : MPI_Op<"irecv", []> {
let hasCanonicalizer = 1;
}
+def MPI_Barrier : MPI_Op<"barrier", []> {
+ let summary = "Equivalent to `MPI_Barrier(comm)`";
+ let description = [{
+ MPI_Barrier blocks execution until all processes in the communicator have
+ reached this routine.
+
+ If communicator is not specified, `MPI_COMM_WORLD` is used by default.
+
+ This operation can optionally return an `!mpi.retval` value that can be used
+ to check for errors.
+ }];
+
+ let arguments = (ins Optional<MPI_Comm> : $comm);
+
+ let results = (outs Optional<MPI_Retval>:$retval);
+
+ let assemblyFormat = "attr-dict `:` type($retval)^";
+}
+
//===----------------------------------------------------------------------===//
// FinalizeOp
//===----------------------------------------------------------------------===//
>From 80a42592bb2dfff31915a33d8b4ec8d7d01527ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Mon, 27 Jan 2025 00:05:02 +0100
Subject: [PATCH 11/17] Format code
---
mlir/include/mlir/Dialect/MPI/IR/MPIOps.td | 45 +++++++++++++++-------
1 file changed, 31 insertions(+), 14 deletions(-)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
index 78d624bc19f783..43128fc1c552c6 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
@@ -66,8 +66,8 @@ def MPI_CommRankOp : MPI_Op<"comm_rank", []> {
//===----------------------------------------------------------------------===//
def MPI_CommSizeOp : MPI_Op<"comm_size", []> {
- let summary = "Get the size of the group associated to the communicator, equivalent to "
- "`MPI_Comm_size(comm, &size)`";
+ let summary = "Get the size of the group associated to the communicator, "
+ "equivalent to `MPI_Comm_size(comm, &size)`";
let description = [{
If communicator is not specified, `MPI_COMM_WORLD` is used by default.
@@ -130,7 +130,12 @@ def MPI_SendOp : MPI_Op<"send", []> {
to check for errors.
}];
- let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank, Optional<MPI_Comm> : $comm);
+ let arguments = (
+ ins AnyMemRef : $ref,
+ I32 : $tag,
+ I32 : $rank,
+ Optional<MPI_Comm> : $comm
+ );
let results = (outs Optional<MPI_Retval>:$retval);
@@ -145,14 +150,14 @@ def MPI_SendOp : MPI_Op<"send", []> {
//===----------------------------------------------------------------------===//
// TODO what about request handler?
-// NOTE datatype & count args are implicit by the type of the first argument (i.e. memref of eltype)
def MPI_ISendOp : MPI_Op<"isend", []> {
let summary =
"Equivalent to `MPI_Isend(ptr, size, dtype, dest, tag, comm)`";
let description = [{
- MPI_Isend begins a non-blocking send of `size` elements of type `dtype` to rank
- `dest`. The `tag` value and communicator enables the library to determine
- the matching of multiple sends and receives between the same ranks.
+ MPI_Isend begins a non-blocking send of `size` elements of type `dtype` to
+ rank `dest`. The `tag` value and communicator enables the library to
+ determine the matching of multiple sends and receives between the same
+ ranks.
If communicator is not specified, `MPI_COMM_WORLD` is used by default.
@@ -160,7 +165,12 @@ def MPI_ISendOp : MPI_Op<"isend", []> {
to check for errors.
}];
- let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank, Optional<MPI_Comm> : $comm);
+ let arguments = (
+ ins AnyMemRef : $ref,
+ I32 : $tag,
+ I32 : $rank,
+ Optional<MPI_Comm> : $comm
+ );
let results = (outs Optional<MPI_Retval>:$retval);
@@ -191,7 +201,11 @@ def MPI_RecvOp : MPI_Op<"recv", []> {
to check for errors.
}];
- let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank, Optional<MPI_Comm> : $comm);
+ let arguments = (
+ ins AnyMemRef : $ref,
+ I32 : $tag, I32 : $rank,
+ Optional<MPI_Comm> : $comm
+ );
let results = (outs Optional<MPI_Retval>:$retval);
@@ -207,7 +221,7 @@ def MPI_RecvOp : MPI_Op<"recv", []> {
def MPI_IRecvOp : MPI_Op<"irecv", []> {
let summary = "Equivalent to `MPI_Irecv(ptr, size, dtype, dest, tag, "
- "comm, MPI_STATUS_IGNORE)`";
+ "comm, &req)`";
let description = [{
MPI_Irecv begins a non-blocking receive of `size` elements of type `dtype`
from rank `dest`. The `tag` value and communicator enables the library to
@@ -215,16 +229,19 @@ def MPI_IRecvOp : MPI_Op<"irecv", []> {
ranks.
If communicator is not specified, `MPI_COMM_WORLD` is used by default.
- The MPI_Status is set to `MPI_STATUS_IGNORE`, as the status object
- is not yet ported to MLIR.
This operation can optionally return an `!mpi.retval` value that can be used
to check for errors.
}];
- let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank, Optional<MPI_Comm> : $comm);
+ let arguments = (
+ ins AnyMemRef : $ref,
+ I32 : $tag,
+ I32 : $rank,
+ Optional<MPI_Comm> : $comm
+ );
- let results = (outs Optional<MPI_Retval>:$retval);
+ let results = (outs Optional<MPI_Retval>:$retval, MPI_Request : $req);
let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:` "
"type($ref) `,` type($tag) `,` type($rank)"
>From cfb81af015f25f99542885c9eb024040edc37cb4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Mon, 27 Jan 2025 00:31:26 +0100
Subject: [PATCH 12/17] Fix ops returning `MPI_Request`
---
mlir/include/mlir/Dialect/MPI/IR/MPIOps.td | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
index 43128fc1c552c6..f1e7f94dcbb5d1 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
@@ -149,7 +149,6 @@ def MPI_SendOp : MPI_Op<"send", []> {
// ISendOp
//===----------------------------------------------------------------------===//
-// TODO what about request handler?
def MPI_ISendOp : MPI_Op<"isend", []> {
let summary =
"Equivalent to `MPI_Isend(ptr, size, dtype, dest, tag, comm)`";
@@ -172,11 +171,11 @@ def MPI_ISendOp : MPI_Op<"isend", []> {
Optional<MPI_Comm> : $comm
);
- let results = (outs Optional<MPI_Retval>:$retval);
+ let results = (outs Optional<MPI_Retval>:$retval, MPI_Request : $req);
let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:` "
"type($ref) `,` type($tag) `,` type($rank)"
- "(`->` type($retval)^)?";
+ "`->` (type($retval) `,` ^)? type($req)";
let hasCanonicalizer = 1;
}
@@ -245,7 +244,7 @@ def MPI_IRecvOp : MPI_Op<"irecv", []> {
let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:` "
"type($ref) `,` type($tag) `,` type($rank)"
- "(`->` type($retval)^)?";
+ "`->` (type($retval) `,` ^)? type($req)";
let hasCanonicalizer = 1;
}
>From 740cf0b6dcaedc8da0f77cc029502ec7302edc2e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Mon, 27 Jan 2025 00:44:14 +0100
Subject: [PATCH 13/17] Add `mpi.wait` op
---
mlir/include/mlir/Dialect/MPI/IR/MPIOps.td | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
index f1e7f94dcbb5d1..9c5954aff2879d 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
@@ -248,6 +248,10 @@ def MPI_IRecvOp : MPI_Op<"irecv", []> {
let hasCanonicalizer = 1;
}
+//===----------------------------------------------------------------------===//
+// BarrierOp
+//===----------------------------------------------------------------------===//
+
def MPI_Barrier : MPI_Op<"barrier", []> {
let summary = "Equivalent to `MPI_Barrier(comm)`";
let description = [{
@@ -267,6 +271,29 @@ def MPI_Barrier : MPI_Op<"barrier", []> {
let assemblyFormat = "attr-dict `:` type($retval)^";
}
+//===----------------------------------------------------------------------===//
+// WaitOp
+//===----------------------------------------------------------------------===//
+
+def MPI_Wait : MPI_Op<"wait", []> {
+ let summary = "Equivalent to `MPI_Wait(req, MPI_STATUS_IGNORE)`";
+ let description = [{
+ MPI_Wait blocks execution until the request has completed.
+
+ The MPI_Status is set to `MPI_STATUS_IGNORE`, as the status object
+ is not yet ported to MLIR.
+
+ This operation can optionally return an `!mpi.retval` value that can be used
+ to check for errors.
+ }];
+
+ let arguments = (MPI_Request : $req);
+
+ let results = (outs Optional<MPI_Retval>:$retval);
+
+ let assemblyFormat = "attr-dict `:` type($retval)^";
+}
+
//===----------------------------------------------------------------------===//
// FinalizeOp
//===----------------------------------------------------------------------===//
>From 1af142547f6ee19bc22207f8891c590c1aa78bd5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Mon, 27 Jan 2025 00:55:10 +0100
Subject: [PATCH 14/17] Add `mpi.allreduce` op
---
mlir/include/mlir/Dialect/MPI/IR/MPIOps.td | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
index 9c5954aff2879d..ff48f323fe8c16 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
@@ -248,6 +248,38 @@ def MPI_IRecvOp : MPI_Op<"irecv", []> {
let hasCanonicalizer = 1;
}
+//===----------------------------------------------------------------------===//
+// AllReduceOp
+//===----------------------------------------------------------------------===//
+
+def MPI_AllReduceOp : MPI_Op<"allreduce", []> {
+ let summary = "Equivalent to `MPI_Allreduce(sendbuf, recvbuf, op, comm)`";
+ let description = [{
+ MPI_Allreduce performs a reduction operation on the values in the sendbuf
+ array and stores the result in the recvbuf array. The operation is
+ performed across all processes in the communicator.
+
+ If communicator is not specified, `MPI_COMM_WORLD` is used by default.
+
+ This operation can optionally return an `!mpi.retval` value that can be used
+ to check for errors.
+ }];
+
+ let arguments = (
+ ins AnyMemRef : $sendbuf,
+ AnyMemRef : $recvbuf,
+ MPI_Op : $op,
+ Optional<MPI_Comm> : $comm
+ );
+
+ let results = (outs Optional<MPI_Retval>:$retval);
+
+ let assemblyFormat = "`(` $sendbuf `,` $recvbuf `,` $op (`,` $comm)?`)` "
+ "attr-dict `:` type($sendbuf) `,` type($recvbuf) `,` "
+ "type($op) (`->` type($retval)^)?";
+ let hasCanonicalizer = 1;
+}
+
//===----------------------------------------------------------------------===//
// BarrierOp
//===----------------------------------------------------------------------===//
>From c11a60f8419e446f127adafc282eccfe378553dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Mon, 27 Jan 2025 01:08:34 +0100
Subject: [PATCH 15/17] Fix assembly formats
---
mlir/include/mlir/Dialect/MPI/IR/MPIOps.td | 32 +++++++++++-----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
index ff48f323fe8c16..5f4a39966350ea 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
@@ -58,7 +58,7 @@ def MPI_CommRankOp : MPI_Op<"comm_rank", []> {
I32 : $rank
);
- let assemblyFormat = "attr-dict `:` type(results)";
+ let assemblyFormat = "(`(` $comm `)`)? attr-dict `:` type(results)";
}
//===----------------------------------------------------------------------===//
@@ -82,7 +82,7 @@ def MPI_CommSizeOp : MPI_Op<"comm_size", []> {
I32 : $size
);
- let assemblyFormat = "attr-dict `:` type(results)";
+ let assemblyFormat = "(`(` $comm `)`)? attr-dict `:` type(results)";
}
//===----------------------------------------------------------------------===//
@@ -109,7 +109,7 @@ def MPI_CommSplit : MPI_Op<"comm_split", []> {
MPI_Comm : $newcomm
);
- let assemblyFormat = "`(` $color `,` $key `)` attr-dict `:` type(results)";
+ let assemblyFormat = "`(` $comm `,` $color `,` $key `)` attr-dict `:` type(results)";
}
//===----------------------------------------------------------------------===//
@@ -139,7 +139,7 @@ def MPI_SendOp : MPI_Op<"send", []> {
let results = (outs Optional<MPI_Retval>:$retval);
- let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:` "
+ let assemblyFormat = "`(` $ref `,` $tag `,` $rank (`,` $comm)? `)` attr-dict `:` "
"type($ref) `,` type($tag) `,` type($rank)"
"(`->` type($retval)^)?";
let hasCanonicalizer = 1;
@@ -173,9 +173,9 @@ def MPI_ISendOp : MPI_Op<"isend", []> {
let results = (outs Optional<MPI_Retval>:$retval, MPI_Request : $req);
- let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:` "
- "type($ref) `,` type($tag) `,` type($rank)"
- "`->` (type($retval) `,` ^)? type($req)";
+ let assemblyFormat = "`(` $ref `,` $tag `,` $rank (`,` $comm)?`)` attr-dict "
+ "`:` type($ref) `,` type($tag) `,` type($rank) "
+ "(`,` type($comm))? `->` (type($retval) `,` ^)? type($req)";
let hasCanonicalizer = 1;
}
@@ -208,9 +208,9 @@ def MPI_RecvOp : MPI_Op<"recv", []> {
let results = (outs Optional<MPI_Retval>:$retval);
- let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:` "
- "type($ref) `,` type($tag) `,` type($rank)"
- "(`->` type($retval)^)?";
+ let assemblyFormat = "`(` $ref `,` $tag `,` $rank (`,` $comm)?`)` attr-dict "
+ "`:` type($ref) `,` type($tag) `,` type($rank) "
+ "(`,` type($comm))? (`->` type($retval)^)?";
let hasCanonicalizer = 1;
}
@@ -242,9 +242,9 @@ def MPI_IRecvOp : MPI_Op<"irecv", []> {
let results = (outs Optional<MPI_Retval>:$retval, MPI_Request : $req);
- let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:` "
- "type($ref) `,` type($tag) `,` type($rank)"
- "`->` (type($retval) `,` ^)? type($req)";
+ let assemblyFormat = "`(` $ref `,` $tag `,` $rank (`,` $comm)?`)` attr-dict "
+ "`:` type($ref) `,` type($tag) `,` type($rank)"
+ "(`,` type($comm))? `->` (type($retval) `,` ^)? type($req)";
let hasCanonicalizer = 1;
}
@@ -276,7 +276,7 @@ def MPI_AllReduceOp : MPI_Op<"allreduce", []> {
let assemblyFormat = "`(` $sendbuf `,` $recvbuf `,` $op (`,` $comm)?`)` "
"attr-dict `:` type($sendbuf) `,` type($recvbuf) `,` "
- "type($op) (`->` type($retval)^)?";
+ "type($op) (`,` type($comm))? (`->` type($retval)^)?";
let hasCanonicalizer = 1;
}
@@ -300,7 +300,7 @@ def MPI_Barrier : MPI_Op<"barrier", []> {
let results = (outs Optional<MPI_Retval>:$retval);
- let assemblyFormat = "attr-dict `:` type($retval)^";
+ let assemblyFormat = "(`(` $comm `)`)? attr-dict `:` type($retval)^";
}
//===----------------------------------------------------------------------===//
@@ -323,7 +323,7 @@ def MPI_Wait : MPI_Op<"wait", []> {
let results = (outs Optional<MPI_Retval>:$retval);
- let assemblyFormat = "attr-dict `:` type($retval)^";
+ let assemblyFormat = "`(` $req `)` attr-dict `:` type($req) `->` type($retval)^";
}
//===----------------------------------------------------------------------===//
>From d971d8335a7bd43e7652fd5876489a392e9fd6cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Mon, 27 Jan 2025 01:13:57 +0100
Subject: [PATCH 16/17] add some tests
---
mlir/test/Dialect/MPI/ops.mlir | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/mlir/test/Dialect/MPI/ops.mlir b/mlir/test/Dialect/MPI/ops.mlir
index 8f2421a73396c2..17f2fc9453e464 100644
--- a/mlir/test/Dialect/MPI/ops.mlir
+++ b/mlir/test/Dialect/MPI/ops.mlir
@@ -9,6 +9,9 @@ func.func @mpi_test(%ref : memref<100xf32>) -> () {
// CHECK-NEXT: %retval, %rank = mpi.comm_rank : !mpi.retval, i32
%retval, %rank = mpi.comm_rank : !mpi.retval, i32
+ // CHECK-NEXT: %retval2, %size = mpi.comm_size : !mpi.retval, i32
+ %retval2, %size = mpi.comm_size : !mpi.retval, i32
+
// CHECK-NEXT: mpi.send(%arg0, %rank, %rank) : memref<100xf32>, i32, i32
mpi.send(%ref, %rank, %rank) : memref<100xf32>, i32, i32
@@ -21,6 +24,27 @@ func.func @mpi_test(%ref : memref<100xf32>) -> () {
// CHECK-NEXT: %2 = mpi.recv(%arg0, %rank, %rank) : memref<100xf32>, i32, i32 -> !mpi.retval
%err3 = mpi.recv(%ref, %rank, %rank) : memref<100xf32>, i32, i32 -> !mpi.retval
+ // CHECK-NEXT: mpi.isend(%arg0, %rank, %rank) : memref<100xf32>, i32, i32 -> mpi.request
+ %req1 = mpi.isend(%ref, %rank, %rank) : memref<100xf32>, i32, i32 -> mpi.request
+
+ // CHECK-NEXT: %1 = mpi.isend(%arg0, %rank, %rank) : memref<100xf32>, i32, i32 -> !mpi.retval, mpi.request
+ %err2, %req2 = mpi.isend(%ref, %rank, %rank) : memref<100xf32>, i32, i32 -> !mpi.retval, mpi.request
+
+ // CHECK-NEXT: mpi.irecv(%arg0, %rank, %rank) : memref<100xf32>, i32, i32 -> mpi.request
+ %req3 = mpi.irecv(%ref, %rank, %rank) : memref<100xf32>, i32, i32
+
+ // CHECK-NEXT: %2 = mpi.irecv(%arg0, %rank, %rank) : memref<100xf32>, i32, i32 -> !mpi.retval, mpi.request
+ %err3, %req4 = mpi.irecv(%ref, %rank, %rank) : memref<100xf32>, i32, i32 -> !mpi.retval
+
+ // CHECK-NEXT: mpi.wait(%req1) : mpi.request
+ mpi.wait(%req1) : mpi.request
+
+ // CHECK-NEXT: %3 = mpi.wait(%req1) : mpi.request -> !mpi.retval
+ %err4 = mpi.wait(%req1) : mpi.request -> !mpi.retval
+
+ // CHECK-NEXT: mpi.barrier : !mpi.retval
+ mpi.barrier : !mpi.retval
+
// CHECK-NEXT: %3 = mpi.finalize : !mpi.retval
%rval = mpi.finalize : !mpi.retval
>From beb57646d002e049d12c870ee75d50361177d032 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?=
<sergio.sanchez.ramirez at bsc.es>
Date: Mon, 27 Jan 2025 11:13:09 +0100
Subject: [PATCH 17/17] Fix input specifier
---
mlir/include/mlir/Dialect/MPI/IR/MPIOps.td | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
index 5f4a39966350ea..534849f960ca54 100644
--- a/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
+++ b/mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
@@ -102,7 +102,7 @@ def MPI_CommSplit : MPI_Op<"comm_split", []> {
to check for errors.
}];
- let arguments = (MPI_Comm : $comm, I32 : $color, I32 : $key);
+ let arguments = (ins MPI_Comm : $comm, I32 : $color, I32 : $key);
let results = (
outs Optional<MPI_Retval> : $retval,
@@ -319,7 +319,7 @@ def MPI_Wait : MPI_Op<"wait", []> {
to check for errors.
}];
- let arguments = (MPI_Request : $req);
+ let arguments = (ins MPI_Request : $req);
let results = (outs Optional<MPI_Retval>:$retval);
More information about the Mlir-commits
mailing list