Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1fbae54
Add `MPI_Comm`, `MPI_Request`, `MPI_Status`, `MPI_Op` type definitions
mofeing Jan 16, 2025
dc84ca4
Add `MPI_CommSize`, `MPI_ISend`, `MPI_IRecv` ops
mofeing Jan 16, 2025
2ee10ab
Fix typo
mofeing Jan 16, 2025
539bf43
Finish types
mofeing Jan 25, 2025
662998d
Define `MPI_Op` enum & attr
mofeing Jan 26, 2025
c1ec63c
Add communicator argument to mpi ops as optional input argument
mofeing Jan 26, 2025
7eda791
Add summary of new mpi types
mofeing Jan 26, 2025
b97a541
format code
mofeing Jan 26, 2025
d5725a8
Add `mpi.comm_split` op
mofeing Jan 26, 2025
1a68b34
Add `mpi.barrier` op
mofeing Jan 26, 2025
80a4259
Format code
mofeing Jan 26, 2025
cfb81af
Fix ops returning `MPI_Request`
mofeing Jan 26, 2025
740cf0b
Add `mpi.wait` op
mofeing Jan 26, 2025
1af1425
Add `mpi.allreduce` op
mofeing Jan 26, 2025
c11a60f
Fix assembly formats
mofeing Jan 27, 2025
d971d83
add some tests
mofeing Jan 27, 2025
beb5764
Fix input specifier
mofeing Jan 27, 2025
2317994
Comment predefined constant MPI_Ops
mofeing Jan 27, 2025
63ccc33
Replace `MPI_Op` new type for region
mofeing Jan 27, 2025
d318c60
Go back to only use predefined MPI_Ops
mofeing Jan 28, 2025
8e3aa18
Remove `MPI_Operation` type
mofeing Jan 29, 2025
9c708d4
Add `mpi.comm_world` op to return `MPI_COMM_WORLD`
mofeing Jan 29, 2025
326b13f
Add tests
mofeing Jan 29, 2025
2baf33f
Merge branch 'main' into mlir-mpi
mofeing Jan 29, 2025
1fd5578
Fix anchor of assembly format
mofeing Jan 29, 2025
016b856
Fix more anchors
mofeing Jan 29, 2025
1931b8e
Fix anchors again
mofeing Jan 29, 2025
aec9fbd
fix another anchor
mofeing Jan 29, 2025
d4684fb
fix optional format of `MPI_BarrierOp`
mofeing Jan 29, 2025
794fa25
fix more anchors
mofeing Jan 29, 2025
f0d0f44
fix anchors in `MPI_ISendOp` and `MPI_IRecvOp`
mofeing Jan 29, 2025
92f2cca
fix format
mofeing Jan 29, 2025
3688915
Define `getCanonicalizationPatterns` for `ISendOp`, `IRecvOp`, `AllRe…
mofeing Jan 29, 2025
3abe925
remove duplicated `getCanonicalizationPatterns`
mofeing Jan 29, 2025
7a9fa9c
Remove canonicalization for `AllReduceOp`
mofeing Jan 29, 2025
1926bda
fix test
mofeing Jan 29, 2025
89ec111
fix some assembly formats
mofeing Jan 29, 2025
30fb673
fix syntax
mofeing Jan 29, 2025
6abba5a
Remove MPI_Comm type
mofeing Jan 29, 2025
452f760
fix tests
mofeing Jan 29, 2025
56868e8
change order of results of `MPI_CommRankOp`
mofeing Jan 29, 2025
b9988b3
format code
mofeing Jan 29, 2025
2075c02
format code
mofeing Jan 29, 2025
8477428
refactor assembly format of `isend`, `irecv` and fix tests
mofeing Jan 30, 2025
1259cbc
last fixes
mofeing Jan 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 86 additions & 1 deletion mlir/include/mlir/Dialect/MPI/IR/MPIOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -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
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -87,6 +109,37 @@ def MPI_SendOp : MPI_Op<"send", []> {
let hasCanonicalizer = 1;
}

//===----------------------------------------------------------------------===//
// ISendOp
//===----------------------------------------------------------------------===//

// TODO what about request handler?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conceptually, it should be a result of this op.

There are also some quirks of the design that this inherits from existing op that I'd model differently, but that's alright for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added it as result. The question is whether we should add MPI_Request_free as an op.

// 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
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -166,7 +251,7 @@ def MPI_RetvalCheckOp : MPI_Op<"retval_check", []> {


//===----------------------------------------------------------------------===//
// RetvalCheckOp
// ErrorClassOp
//===----------------------------------------------------------------------===//

def MPI_ErrorClassOp : MPI_Op<"error_class", []> {
Expand Down
30 changes: 30 additions & 0 deletions mlir/include/mlir/Dialect/MPI/IR/MPITypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading