|
| 1 | +//===- MPI.td - Message Passing Interface Ops ---------*- tablegen -*-===// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | + |
| 9 | +#ifndef MPI_OPS |
| 10 | +#define MPI_OPS |
| 11 | + |
| 12 | +include "mlir/Dialect/MPI/IR/MPIBase.td" |
| 13 | + |
| 14 | +class MPI_Op<string mnemonic, list<Trait> traits = []> |
| 15 | + : Op<MPI_Dialect, mnemonic, traits>; |
| 16 | + |
| 17 | +//===----------------------------------------------------------------------===// |
| 18 | +// InitOp |
| 19 | +//===----------------------------------------------------------------------===// |
| 20 | + |
| 21 | +def MPI_InitOp : MPI_Op<"init", [ |
| 22 | + |
| 23 | +]> { |
| 24 | + let summary = |
| 25 | + "Initialize the MPI library, equivalent to `MPI_Init(NULL, NULL)`"; |
| 26 | + let description = [{ |
| 27 | + This operation must preceed most MPI calls (except for very few exceptions, |
| 28 | + please consult with the MPI specification on these). |
| 29 | + |
| 30 | + Passing &argc, &argv is not supported currently. |
| 31 | + Inspecting the functions return value (error code) is also not supported. |
| 32 | + }]; |
| 33 | + |
| 34 | + let assemblyFormat = "attr-dict"; |
| 35 | +} |
| 36 | + |
| 37 | +//===----------------------------------------------------------------------===// |
| 38 | +// CommRankOp |
| 39 | +//===----------------------------------------------------------------------===// |
| 40 | + |
| 41 | +def MPI_CommRankOp : MPI_Op<"comm_rank", [ |
| 42 | + |
| 43 | +]> { |
| 44 | + let summary = "Get the current rank, equivalent to " |
| 45 | + "`MPI_Comm_rank(MPI_COMM_WORLD, &rank)`"; |
| 46 | + let description = [{ |
| 47 | + Communicators other than `MPI_COMM_WORLD` are not supprted for now. |
| 48 | + Inspecting the functions return value (error code) is also not supported. |
| 49 | + }]; |
| 50 | + |
| 51 | + let results = (outs I32 : $result); |
| 52 | + |
| 53 | + let assemblyFormat = "attr-dict `:` type($result)"; |
| 54 | +} |
| 55 | + |
| 56 | +//===----------------------------------------------------------------------===// |
| 57 | +// SendOp |
| 58 | +//===----------------------------------------------------------------------===// |
| 59 | + |
| 60 | +def MPI_SendOp : MPI_Op<"send", [ |
| 61 | + |
| 62 | +]> { |
| 63 | + let summary = |
| 64 | + "Equivalent to `MPI_Send(ptr, size, dtype, dest, tag, MPI_COMM_WORLD)`"; |
| 65 | + let description = [{ |
| 66 | + MPI_Send performs a blocking send of `size` elements of type `dtype` to rank `dest`. |
| 67 | + The `tag` value and communicator enables the library to determine the matching of |
| 68 | + multiple sends and receives between the same ranks. |
| 69 | + |
| 70 | + Communicators other than `MPI_COMM_WORLD` are not supprted for now. |
| 71 | + Inspecting the functions return value (error code) is also not supported. |
| 72 | + }]; |
| 73 | + |
| 74 | + let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank); |
| 75 | + |
| 76 | + let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:` " |
| 77 | + "type($ref) `,` type($tag) `,` type($rank)"; |
| 78 | +} |
| 79 | + |
| 80 | +//===----------------------------------------------------------------------===// |
| 81 | +// RecvOp |
| 82 | +//===----------------------------------------------------------------------===// |
| 83 | + |
| 84 | +def MPI_RecvOp : MPI_Op<"recv", [ |
| 85 | + |
| 86 | +]> { |
| 87 | + let summary = "Equivalent to `MPI_Recv(ptr, size, dtype, dest, tag, " |
| 88 | + "MPI_COMM_WORLD, MPI_STATUS_IGNORE)`"; |
| 89 | + let description = [{ |
| 90 | + MPI_Recv performs a blocking receive of `size` elements of type `dtype` from rank `dest`. |
| 91 | + The `tag` value and communicator enables the library to determine the matching of |
| 92 | + multiple sends and receives between the same ranks. |
| 93 | + |
| 94 | + Communicators other than `MPI_COMM_WORLD` are not supprted for now. |
| 95 | + The MPI_Status is set to `MPI_STATUS_IGNORE`, as the status object is not yet ported to MLIR. |
| 96 | + Inspecting the functions return value (error code) is also not supported. |
| 97 | + }]; |
| 98 | + |
| 99 | + let arguments = (ins AnyMemRef : $ref, I32 : $tag, I32 : $rank); |
| 100 | + |
| 101 | + let assemblyFormat = "`(` $ref `,` $tag `,` $rank `)` attr-dict `:` " |
| 102 | + "type($ref) `,` type($tag) `,` type($rank)"; |
| 103 | +} |
| 104 | + |
| 105 | +//===----------------------------------------------------------------------===// |
| 106 | +// FinalizeOp |
| 107 | +//===----------------------------------------------------------------------===// |
| 108 | + |
| 109 | +def MPI_FinalizeOp : MPI_Op<"finalize", [ |
| 110 | + |
| 111 | +]> { |
| 112 | + let summary = "Finalize the MPI library, equivalent to `MPI_Finalize()`"; |
| 113 | + let description = [{ |
| 114 | + This function cleans up the MPI state. Afterwards, no MPI methods may be invoked |
| 115 | + (excpet for MPI_Get_version, MPI_Initialized, and MPI_Finalized). |
| 116 | + Notably, MPI_Init cannot be called again in the same program. |
| 117 | + |
| 118 | + Inspecting the functions return value (error code) is not supported. |
| 119 | + }]; |
| 120 | + |
| 121 | + let assemblyFormat = "attr-dict"; |
| 122 | +} |
| 123 | + |
| 124 | +#endif // MPI_OPS |
0 commit comments