@@ -37,26 +37,41 @@ def MPI_InitOp : MPI_Op<"init", []> {
37
37
let assemblyFormat = "attr-dict (`:` type($retval)^)?";
38
38
}
39
39
40
+ //===----------------------------------------------------------------------===//
41
+ // CommWorldOp
42
+ //===----------------------------------------------------------------------===//
43
+
44
+ def MPI_CommWorldOp : MPI_Op<"comm_world", []> {
45
+ let summary = "Get the World communicator, equivalent to `MPI_COMM_WORLD`";
46
+ let description = [{
47
+ This operation returns the predefined MPI_COMM_WORLD communicator.
48
+ }];
49
+
50
+ let results = (outs MPI_Comm : $comm);
51
+
52
+ let assemblyFormat = "attr-dict `:` type(results)";
53
+ }
54
+
40
55
//===----------------------------------------------------------------------===//
41
56
// CommRankOp
42
57
//===----------------------------------------------------------------------===//
43
58
44
59
def MPI_CommRankOp : MPI_Op<"comm_rank", []> {
45
60
let summary = "Get the current rank, equivalent to "
46
- "`MPI_Comm_rank(MPI_COMM_WORLD , &rank)`";
61
+ "`MPI_Comm_rank(comm , &rank)`";
47
62
let description = [{
48
- Communicators other than `MPI_COMM_WORLD` are not supported for now.
49
-
50
63
This operation can optionally return an `!mpi.retval` value that can be used
51
64
to check for errors.
52
65
}];
53
66
67
+ let arguments = (ins MPI_Comm : $comm);
68
+
54
69
let results = (
55
70
outs Optional<MPI_Retval> : $retval,
56
71
I32 : $rank
57
72
);
58
73
59
- let assemblyFormat = "attr-dict `:` type(results)";
74
+ let assemblyFormat = "`(` $comm `)` attr-dict `:` type(results)";
60
75
}
61
76
62
77
//===----------------------------------------------------------------------===//
@@ -65,20 +80,48 @@ def MPI_CommRankOp : MPI_Op<"comm_rank", []> {
65
80
66
81
def MPI_CommSizeOp : MPI_Op<"comm_size", []> {
67
82
let summary = "Get the size of the group associated to the communicator, "
68
- "equivalent to `MPI_Comm_size(MPI_COMM_WORLD , &size)`";
83
+ "equivalent to `MPI_Comm_size(comm , &size)`";
69
84
let description = [{
70
- Communicators other than `MPI_COMM_WORLD` are not supported for now.
71
-
72
85
This operation can optionally return an `!mpi.retval` value that can be used
73
86
to check for errors.
74
87
}];
75
88
89
+ let arguments = (ins MPI_Comm : $comm);
90
+
76
91
let results = (
77
92
outs Optional<MPI_Retval> : $retval,
78
93
I32 : $size
79
94
);
80
95
81
- let assemblyFormat = "attr-dict `:` type(results)";
96
+ let assemblyFormat = "`(` $comm `)` attr-dict `:` type(results)";
97
+ }
98
+
99
+ //===----------------------------------------------------------------------===//
100
+ // CommSplitOp
101
+ //===----------------------------------------------------------------------===//
102
+
103
+ def MPI_CommSplitOp : MPI_Op<"comm_split", []> {
104
+ let summary = "Partition the group associated with the given communicator into "
105
+ "disjoint subgroups";
106
+ let description = [{
107
+ This operation splits the communicator into multiple sub-communicators.
108
+ The color value determines the group of processes that will be part of the
109
+ new communicator. The key value determines the rank of the calling process
110
+ in the new communicator.
111
+
112
+ This operation can optionally return an `!mpi.retval` value that can be used
113
+ to check for errors.
114
+ }];
115
+
116
+ let arguments = (ins MPI_Comm : $comm, I32 : $color, I32 : $key);
117
+
118
+ let results = (
119
+ outs Optional<MPI_Retval> : $retval,
120
+ MPI_Comm : $newcomm
121
+ );
122
+
123
+ let assemblyFormat = "`(` $comm `,` $color `,` $key `)` attr-dict `:` "
124
+ "type(results)";
82
125
}
83
126
84
127
//===----------------------------------------------------------------------===//
@@ -87,27 +130,26 @@ def MPI_CommSizeOp : MPI_Op<"comm_size", []> {
87
130
88
131
def MPI_SendOp : MPI_Op<"send", []> {
89
132
let summary =
90
- "Equivalent to `MPI_Send(ptr, size, dtype, dest, tag, MPI_COMM_WORLD )`";
133
+ "Equivalent to `MPI_Send(ptr, size, dtype, dest, tag, comm )`";
91
134
let description = [{
92
135
MPI_Send performs a blocking send of `size` elements of type `dtype` to rank
93
136
`dest`. The `tag` value and communicator enables the library to determine
94
137
the matching of multiple sends and receives between the same ranks.
95
138
96
- Communicators other than `MPI_COMM_WORLD` are not supported for now.
97
-
98
139
This operation can optionally return an `!mpi.retval` value that can be used
99
140
to check for errors.
100
141
}];
101
142
102
143
let arguments = (
103
144
ins AnyMemRef : $ref,
104
145
I32 : $tag,
105
- I32 : $dest
146
+ I32 : $dest,
147
+ MPI_Comm : $comm
106
148
);
107
149
108
150
let results = (outs Optional<MPI_Retval>:$retval);
109
151
110
- let assemblyFormat = "`(` $ref `,` $tag `,` $dest `)` attr-dict `:` "
152
+ let assemblyFormat = "`(` $ref `,` $tag `,` $dest `,` $comm ` )` attr-dict `:` "
111
153
"type($ref) `,` type($tag) `,` type($dest)"
112
154
"(`->` type($retval)^)?";
113
155
let hasCanonicalizer = 1;
@@ -119,32 +161,31 @@ def MPI_SendOp : MPI_Op<"send", []> {
119
161
120
162
def MPI_ISendOp : MPI_Op<"isend", []> {
121
163
let summary =
122
- "Equivalent to `MPI_Isend(ptr, size, dtype, dest, tag, MPI_COMM_WORLD )`";
164
+ "Equivalent to `MPI_Isend(ptr, size, dtype, dest, tag, comm )`";
123
165
let description = [{
124
166
MPI_Isend begins a non-blocking send of `size` elements of type `dtype` to
125
167
rank `dest`. The `tag` value and communicator enables the library to
126
168
determine the matching of multiple sends and receives between the same
127
169
ranks.
128
170
129
- Communicators other than `MPI_COMM_WORLD` are not supported for now.
130
-
131
171
This operation can optionally return an `!mpi.retval` value that can be used
132
172
to check for errors.
133
173
}];
134
174
135
175
let arguments = (
136
176
ins AnyMemRef : $ref,
137
177
I32 : $tag,
138
- I32 : $rank
178
+ I32 : $dest,
179
+ MPI_Comm : $comm
139
180
);
140
181
141
182
let results = (
142
183
outs Optional<MPI_Retval>:$retval,
143
184
MPI_Request : $req
144
185
);
145
186
146
- let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict "
147
- "`:` type($ref) `,` type($tag) `,` type($rank ) "
187
+ let assemblyFormat = "`(` $ref `,` $tag `,` $dest `,` $comm `)` attr-dict "
188
+ "`:` type($ref) `,` type($tag) `,` type($dest ) "
148
189
"`->` type(results)";
149
190
let hasCanonicalizer = 1;
150
191
}
@@ -155,14 +196,13 @@ def MPI_ISendOp : MPI_Op<"isend", []> {
155
196
156
197
def MPI_RecvOp : MPI_Op<"recv", []> {
157
198
let summary = "Equivalent to `MPI_Recv(ptr, size, dtype, source, tag, "
158
- "MPI_COMM_WORLD , MPI_STATUS_IGNORE)`";
199
+ "comm , MPI_STATUS_IGNORE)`";
159
200
let description = [{
160
201
MPI_Recv performs a blocking receive of `size` elements of type `dtype`
161
202
from rank `source`. The `tag` value and communicator enables the library to
162
203
determine the matching of multiple sends and receives between the same
163
204
ranks.
164
205
165
- Communicators other than `MPI_COMM_WORLD` are not supported for now.
166
206
The MPI_Status is set to `MPI_STATUS_IGNORE`, as the status object
167
207
is not yet ported to MLIR.
168
208
@@ -172,13 +212,14 @@ def MPI_RecvOp : MPI_Op<"recv", []> {
172
212
173
213
let arguments = (
174
214
ins AnyMemRef : $ref,
175
- I32 : $tag, I32 : $source
215
+ I32 : $tag, I32 : $source,
216
+ MPI_Comm : $comm
176
217
);
177
218
178
219
let results = (outs Optional<MPI_Retval>:$retval);
179
220
180
- let assemblyFormat = "`(` $ref `,` $tag `,` $source `)` attr-dict `:` "
181
- "type($ref) `,` type($tag) `,` type($source)"
221
+ let assemblyFormat = "`(` $ref `,` $tag `,` $source `,` $comm `)` attr-dict "
222
+ " `:` type($ref) `,` type($tag) `,` type($source) "
182
223
"(`->` type($retval)^)?";
183
224
let hasCanonicalizer = 1;
184
225
}
@@ -188,34 +229,33 @@ def MPI_RecvOp : MPI_Op<"recv", []> {
188
229
//===----------------------------------------------------------------------===//
189
230
190
231
def MPI_IRecvOp : MPI_Op<"irecv", []> {
191
- let summary = "Equivalent to `MPI_Irecv(ptr, size, dtype, dest , tag, "
192
- "MPI_COMM_WORLD , &req)`";
232
+ let summary = "Equivalent to `MPI_Irecv(ptr, size, dtype, source , tag, "
233
+ "comm , &req)`";
193
234
let description = [{
194
235
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
236
+ from rank `source `. The `tag` value and communicator enables the library to
196
237
determine the matching of multiple sends and receives between the same
197
238
ranks.
198
239
199
- Communicators other than `MPI_COMM_WORLD` are not supported for now.
200
-
201
240
This operation can optionally return an `!mpi.retval` value that can be used
202
241
to check for errors.
203
242
}];
204
243
205
244
let arguments = (
206
245
ins AnyMemRef : $ref,
207
246
I32 : $tag,
208
- I32 : $rank
247
+ I32 : $source,
248
+ MPI_Comm : $comm
209
249
);
210
250
211
251
let results = (
212
252
outs Optional<MPI_Retval>:$retval,
213
253
MPI_Request : $req
214
254
);
215
255
216
- let assemblyFormat = "`(` $ref `,` $tag `,` $rank ` )` attr-dict `:` "
217
- "type($ref) `,` type($tag) `,` type($rank) `->` "
218
- "type(results)";
256
+ let assemblyFormat = "`(` $ref `,` $tag `,` $source `,` $comm` )` attr-dict "
257
+ "`:` type($ref) `,` type($tag) `,` type($source) "
258
+ "`->` type(results)";
219
259
let hasCanonicalizer = 1;
220
260
}
221
261
@@ -224,8 +264,7 @@ def MPI_IRecvOp : MPI_Op<"irecv", []> {
224
264
//===----------------------------------------------------------------------===//
225
265
226
266
def MPI_AllReduceOp : MPI_Op<"allreduce", []> {
227
- let summary = "Equivalent to `MPI_Allreduce(sendbuf, recvbuf, op, "
228
- "MPI_COMM_WORLD)`";
267
+ let summary = "Equivalent to `MPI_Allreduce(sendbuf, recvbuf, op, comm)`";
229
268
let description = [{
230
269
MPI_Allreduce performs a reduction operation on the values in the sendbuf
231
270
array and stores the result in the recvbuf array. The operation is
@@ -235,22 +274,21 @@ def MPI_AllReduceOp : MPI_Op<"allreduce", []> {
235
274
Currently only the `MPI_Op` predefined in the standard (e.g. `MPI_SUM`) are
236
275
supported.
237
276
238
- Communicators other than `MPI_COMM_WORLD` are not supported for now.
239
-
240
277
This operation can optionally return an `!mpi.retval` value that can be used
241
278
to check for errors.
242
279
}];
243
280
244
281
let arguments = (
245
282
ins AnyMemRef : $sendbuf,
246
283
AnyMemRef : $recvbuf,
247
- MPI_OpClassEnum : $op
284
+ MPI_OpClassEnum : $op,
285
+ MPI_Comm : $comm
248
286
);
249
287
250
288
let results = (outs Optional<MPI_Retval>:$retval);
251
289
252
- let assemblyFormat = "`(` $sendbuf `,` $recvbuf `,` $op `)` attr-dict `:` "
253
- "type($sendbuf) `,` type($recvbuf)"
290
+ let assemblyFormat = "`(` $sendbuf `,` $recvbuf `,` $op `,` $comm `)` "
291
+ "attr-dict `:` type($sendbuf) `,` type($recvbuf) "
254
292
"(`->` type($retval)^)?";
255
293
}
256
294
@@ -259,20 +297,23 @@ def MPI_AllReduceOp : MPI_Op<"allreduce", []> {
259
297
//===----------------------------------------------------------------------===//
260
298
261
299
def MPI_Barrier : MPI_Op<"barrier", []> {
262
- let summary = "Equivalent to `MPI_Barrier(MPI_COMM_WORLD )`";
300
+ let summary = "Equivalent to `MPI_Barrier(comm )`";
263
301
let description = [{
264
302
MPI_Barrier blocks execution until all processes in the communicator have
265
303
reached this routine.
266
304
267
- Communicators other than `MPI_COMM_WORLD` are not supported for now.
268
-
269
305
This operation can optionally return an `!mpi.retval` value that can be used
270
306
to check for errors.
271
307
}];
272
308
309
+ let arguments = (ins MPI_Comm : $comm);
310
+
273
311
let results = (outs Optional<MPI_Retval>:$retval);
274
312
275
- let assemblyFormat = "attr-dict (`:` type($retval) ^)?";
313
+ let assemblyFormat = [{
314
+ `(` $comm `)` attr-dict
315
+ (`->` type($retval)^)?
316
+ }];
276
317
}
277
318
278
319
//===----------------------------------------------------------------------===//
@@ -295,8 +336,7 @@ def MPI_Wait : MPI_Op<"wait", []> {
295
336
296
337
let results = (outs Optional<MPI_Retval>:$retval);
297
338
298
- let assemblyFormat = "`(` $req `)` attr-dict `:` type($req) "
299
- "(`->` type($retval) ^)?";
339
+ let assemblyFormat = "`(` $req `)` attr-dict `:` type($req) (`->` type($retval) ^)?";
300
340
}
301
341
302
342
//===----------------------------------------------------------------------===//
0 commit comments