|
| 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 | +include "mlir/Interfaces/CallInterfaces.td" |
| 14 | +include "mlir/Interfaces/ControlFlowInterfaces.td" |
| 15 | +include "mlir/Interfaces/SideEffectInterfaces.td" |
| 16 | +include "mlir/IR/FunctionInterfaces.td" |
| 17 | +include "mlir/IR/RegionKindInterface.td" |
| 18 | +include "mlir/IR/SymbolInterfaces.td" |
| 19 | + |
| 20 | +class MPI_Op<string mnemonic, list<Trait> traits = []> : |
| 21 | + Op<MPI_Dialect, mnemonic, traits>; |
| 22 | + |
| 23 | +//===----------------------------------------------------------------------===// |
| 24 | +// InitOp |
| 25 | +//===----------------------------------------------------------------------===// |
| 26 | + |
| 27 | +def MPI_InitOp : MPI_Op<"init", [ |
| 28 | + |
| 29 | + ]> { |
| 30 | + let summary = "Initialize the MPI library, equivalent to `MPI_Init(NULL, NULL)`"; |
| 31 | + let description = [{ |
| 32 | + Passing &argc, &argv is not supported currently, also inspecting the return value is not supported. |
| 33 | + }]; |
| 34 | + |
| 35 | + let assemblyFormat = "attr-dict"; |
| 36 | +} |
| 37 | + |
| 38 | +//===----------------------------------------------------------------------===// |
| 39 | +// CommRankOp |
| 40 | +//===----------------------------------------------------------------------===// |
| 41 | + |
| 42 | +def MPI_CommRankOp : MPI_Op<"comm_rank", [ |
| 43 | + |
| 44 | + ]> { |
| 45 | + let summary = "Get the current rank, equivalent to `MPI_Comm_rank(MPI_COMM_WORLD, &rank)`"; |
| 46 | + let description = [{ |
| 47 | + Communicators other than `MPI_COMM_WORLD` are not supprted for now. |
| 48 | + }]; |
| 49 | + |
| 50 | + let results = (outs |
| 51 | + I32:$result |
| 52 | + ); |
| 53 | + |
| 54 | + let assemblyFormat = "attr-dict `:` type($result)"; |
| 55 | +} |
| 56 | + |
| 57 | + |
| 58 | +//===----------------------------------------------------------------------===// |
| 59 | +// SendOp |
| 60 | +//===----------------------------------------------------------------------===// |
| 61 | + |
| 62 | +def MPI_SendOp : MPI_Op<"send", [ |
| 63 | + |
| 64 | + ]> { |
| 65 | + let summary = "Equivalent to `MPI_Send(ptr, size, dtype, dest, tag, MPI_COMM_WORLD)`"; |
| 66 | + let description = [{ |
| 67 | + Communicators other than `MPI_COMM_WORLD` are not supprted for now. |
| 68 | + }]; |
| 69 | + |
| 70 | + let arguments = (ins |
| 71 | + AnyMemRef:$ref, |
| 72 | + I32:$tag, |
| 73 | + I32:$rank |
| 74 | + ); |
| 75 | + |
| 76 | + let assemblyFormat = "attr-dict $ref `:` type($ref) `,` $tag `:` type($tag) `,` $rank `:` type($rank)"; |
| 77 | +} |
| 78 | + |
| 79 | +//===----------------------------------------------------------------------===// |
| 80 | +// RecvOp |
| 81 | +//===----------------------------------------------------------------------===// |
| 82 | + |
| 83 | +def MPI_RecvOp : MPI_Op<"recv", [ |
| 84 | + |
| 85 | + ]> { |
| 86 | + let summary = "Equivalent to `MPI_Recv(ptr, size, dtype, dest, tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE)`"; |
| 87 | + let description = [{ |
| 88 | + Communicators other than `MPI_COMM_WORLD` are not supprted for now. |
| 89 | + }]; |
| 90 | + |
| 91 | + let arguments = (ins |
| 92 | + AnyMemRef:$ref, |
| 93 | + I32:$tag, |
| 94 | + I32:$rank |
| 95 | + ); |
| 96 | + |
| 97 | + let assemblyFormat = "attr-dict $ref `:` type($ref) `,` $tag `:` type($tag) `,` $rank `:` type($rank)"; |
| 98 | +} |
| 99 | + |
| 100 | +//===----------------------------------------------------------------------===// |
| 101 | +// FinalizeOp |
| 102 | +//===----------------------------------------------------------------------===// |
| 103 | + |
| 104 | +def MPI_FinalizeOp : MPI_Op<"finalize", [ |
| 105 | + |
| 106 | + ]> { |
| 107 | + let summary = "Finalize the MPI library, equivalent to `MPI_Finalize()`"; |
| 108 | + let description = [{ |
| 109 | + |
| 110 | + }]; |
| 111 | + |
| 112 | + let assemblyFormat = "attr-dict"; |
| 113 | +} |
| 114 | + |
| 115 | +#endif // MPI_OPS |
0 commit comments