@@ -59,6 +59,28 @@ def MPI_CommRankOp : MPI_Op<"comm_rank", []> {
5959 let assemblyFormat = "attr-dict `:` type(results)";
6060}
6161
62+ //===----------------------------------------------------------------------===//
63+ // CommSizeOp
64+ //===----------------------------------------------------------------------===//
65+
66+ def MPI_CommSizeOp : MPI_Op<"comm_size", []> {
67+ let summary = "Get the size of the group associated to the communicator, "
68+ "equivalent to `MPI_Comm_size(MPI_COMM_WORLD, &size)`";
69+ let description = [{
70+ Communicators other than `MPI_COMM_WORLD` are not supported for now.
71+
72+ This operation can optionally return an `!mpi.retval` value that can be used
73+ to check for errors.
74+ }];
75+
76+ let results = (
77+ outs Optional<MPI_Retval> : $retval,
78+ I32 : $size
79+ );
80+
81+ let assemblyFormat = "attr-dict `:` type(results)";
82+ }
83+
6284//===----------------------------------------------------------------------===//
6385// SendOp
6486//===----------------------------------------------------------------------===//
@@ -71,13 +93,17 @@ def MPI_SendOp : MPI_Op<"send", []> {
7193 `dest`. The `tag` value and communicator enables the library to determine
7294 the matching of multiple sends and receives between the same ranks.
7395
74- Communicators other than `MPI_COMM_WORLD` are not supprted for now.
96+ Communicators other than `MPI_COMM_WORLD` are not supported for now.
7597
7698 This operation can optionally return an `!mpi.retval` value that can be used
7799 to check for errors.
78100 }];
79101
80- let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank);
102+ let arguments = (
103+ ins AnyMemRef : $ref,
104+ I32 : $tag,
105+ I32 : $rank
106+ );
81107
82108 let results = (outs Optional<MPI_Retval>:$retval);
83109
@@ -87,6 +113,42 @@ def MPI_SendOp : MPI_Op<"send", []> {
87113 let hasCanonicalizer = 1;
88114}
89115
116+ //===----------------------------------------------------------------------===//
117+ // ISendOp
118+ //===----------------------------------------------------------------------===//
119+
120+ def MPI_ISendOp : MPI_Op<"isend", []> {
121+ let summary =
122+ "Equivalent to `MPI_Isend(ptr, size, dtype, dest, tag, MPI_COMM_WORLD)`";
123+ let description = [{
124+ MPI_Isend begins a non-blocking send of `size` elements of type `dtype` to
125+ rank `dest`. The `tag` value and communicator enables the library to
126+ determine the matching of multiple sends and receives between the same
127+ ranks.
128+
129+ Communicators other than `MPI_COMM_WORLD` are not supported for now.
130+
131+ This operation can optionally return an `!mpi.retval` value that can be used
132+ to check for errors.
133+ }];
134+
135+ let arguments = (
136+ ins AnyMemRef : $ref,
137+ I32 : $tag,
138+ I32 : $rank
139+ );
140+
141+ let results = (
142+ outs Optional<MPI_Retval>:$retval,
143+ MPI_Request : $req
144+ );
145+
146+ let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict "
147+ "`:` type($ref) `,` type($tag) `,` type($rank) "
148+ "`->` type(results)";
149+ let hasCanonicalizer = 1;
150+ }
151+
90152//===----------------------------------------------------------------------===//
91153// RecvOp
92154//===----------------------------------------------------------------------===//
@@ -100,24 +162,142 @@ def MPI_RecvOp : MPI_Op<"recv", []> {
100162 determine the matching of multiple sends and receives between the same
101163 ranks.
102164
103- Communicators other than `MPI_COMM_WORLD` are not supprted for now.
165+ Communicators other than `MPI_COMM_WORLD` are not supported for now.
104166 The MPI_Status is set to `MPI_STATUS_IGNORE`, as the status object
105167 is not yet ported to MLIR.
106168
107169 This operation can optionally return an `!mpi.retval` value that can be used
108170 to check for errors.
109171 }];
110172
111- let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank);
173+ let arguments = (
174+ ins AnyMemRef : $ref,
175+ I32 : $tag, I32 : $rank
176+ );
112177
113178 let results = (outs Optional<MPI_Retval>:$retval);
114179
115- let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:` "
180+ let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:`"
116181 "type($ref) `,` type($tag) `,` type($rank)"
117182 "(`->` type($retval)^)?";
118183 let hasCanonicalizer = 1;
119184}
120185
186+ //===----------------------------------------------------------------------===//
187+ // IRecvOp
188+ //===----------------------------------------------------------------------===//
189+
190+ def MPI_IRecvOp : MPI_Op<"irecv", []> {
191+ let summary = "Equivalent to `MPI_Irecv(ptr, size, dtype, dest, tag, "
192+ "MPI_COMM_WORLD, &req)`";
193+ let description = [{
194+ MPI_Irecv begins a non-blocking receive of `size` elements of type `dtype`
195+ from rank `dest`. The `tag` value and communicator enables the library to
196+ determine the matching of multiple sends and receives between the same
197+ ranks.
198+
199+ Communicators other than `MPI_COMM_WORLD` are not supported for now.
200+
201+ This operation can optionally return an `!mpi.retval` value that can be used
202+ to check for errors.
203+ }];
204+
205+ let arguments = (
206+ ins AnyMemRef : $ref,
207+ I32 : $tag,
208+ I32 : $rank
209+ );
210+
211+ let results = (
212+ outs Optional<MPI_Retval>:$retval,
213+ MPI_Request : $req
214+ );
215+
216+ let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:`"
217+ "type($ref) `,` type($tag) `,` type($rank) `->`"
218+ "type(results)";
219+ let hasCanonicalizer = 1;
220+ }
221+
222+ //===----------------------------------------------------------------------===//
223+ // AllReduceOp
224+ //===----------------------------------------------------------------------===//
225+
226+ def MPI_AllReduceOp : MPI_Op<"allreduce", []> {
227+ let summary = "Equivalent to `MPI_Allreduce(sendbuf, recvbuf, op, "
228+ "MPI_COMM_WORLD)`";
229+ let description = [{
230+ MPI_Allreduce performs a reduction operation on the values in the sendbuf
231+ array and stores the result in the recvbuf array. The operation is
232+ performed across all processes in the communicator.
233+
234+ The `op` attribute specifies the reduction operation to be performed.
235+ Currently only the `MPI_Op` predefined in the standard (e.g. `MPI_SUM`) are
236+ supported.
237+
238+ Communicators other than `MPI_COMM_WORLD` are not supported for now.
239+
240+ This operation can optionally return an `!mpi.retval` value that can be used
241+ to check for errors.
242+ }];
243+
244+ let arguments = (
245+ ins AnyMemRef : $sendbuf,
246+ AnyMemRef : $recvbuf,
247+ MPI_OpClassAttr : $op
248+ );
249+
250+ let results = (outs Optional<MPI_Retval>:$retval);
251+
252+ let assemblyFormat = "`(` $sendbuf `,` $recvbuf `,` $op `)` attr-dict `:`"
253+ "type($sendbuf) `,` type($recvbuf)"
254+ "(`->` type($retval)^)?";
255+ }
256+
257+ //===----------------------------------------------------------------------===//
258+ // BarrierOp
259+ //===----------------------------------------------------------------------===//
260+
261+ def MPI_Barrier : MPI_Op<"barrier", []> {
262+ let summary = "Equivalent to `MPI_Barrier(MPI_COMM_WORLD)`";
263+ let description = [{
264+ MPI_Barrier blocks execution until all processes in the communicator have
265+ reached this routine.
266+
267+ Communicators other than `MPI_COMM_WORLD` are not supported for now.
268+
269+ This operation can optionally return an `!mpi.retval` value that can be used
270+ to check for errors.
271+ }];
272+
273+ let results = (outs Optional<MPI_Retval>:$retval);
274+
275+ let assemblyFormat = "attr-dict (`:` type($retval) ^)?";
276+ }
277+
278+ //===----------------------------------------------------------------------===//
279+ // WaitOp
280+ //===----------------------------------------------------------------------===//
281+
282+ def MPI_Wait : MPI_Op<"wait", []> {
283+ let summary = "Equivalent to `MPI_Wait(req, MPI_STATUS_IGNORE)`";
284+ let description = [{
285+ MPI_Wait blocks execution until the request has completed.
286+
287+ The MPI_Status is set to `MPI_STATUS_IGNORE`, as the status object
288+ is not yet ported to MLIR.
289+
290+ This operation can optionally return an `!mpi.retval` value that can be used
291+ to check for errors.
292+ }];
293+
294+ let arguments = (ins MPI_Request : $req);
295+
296+ let results = (outs Optional<MPI_Retval>:$retval);
297+
298+ let assemblyFormat = "`(` $req `)` attr-dict `:` type($req) "
299+ "(`->` type($retval) ^)?";
300+ }
121301
122302//===----------------------------------------------------------------------===//
123303// FinalizeOp
@@ -139,7 +319,6 @@ def MPI_FinalizeOp : MPI_Op<"finalize", []> {
139319 let assemblyFormat = "attr-dict (`:` type($retval)^)?";
140320}
141321
142-
143322//===----------------------------------------------------------------------===//
144323// RetvalCheckOp
145324//===----------------------------------------------------------------------===//
@@ -163,10 +342,8 @@ def MPI_RetvalCheckOp : MPI_Op<"retval_check", []> {
163342 let assemblyFormat = "$val `=` $errclass attr-dict `:` type($res)";
164343}
165344
166-
167-
168345//===----------------------------------------------------------------------===//
169- // RetvalCheckOp
346+ // ErrorClassOp
170347//===----------------------------------------------------------------------===//
171348
172349def MPI_ErrorClassOp : MPI_Op<"error_class", []> {
0 commit comments