11// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
22//
3- // ModuloPipeline IR — abstract representation of a modulo-scheduled
3+ // ModuloScheduleGraph — abstract representation of a modulo-scheduled
44// loop nest with multi-buffered memory, pipeline stages, and optional
55// warp specialization.
66//
7- // The IR is a side data structure (not MLIR ops). It references MLIR
7+ // The graph is a side data structure (not MLIR ops). It references MLIR
88// Operations but adds scheduling metadata (cycles, stages, buffers,
99// edges) that drive the lowering passes.
1010//
1111// Transformation phases:
12- // Phase 0: SCHEDULE — DDG + Rau's → populate PipelineNode cycle/stage
13- // Phase 1: BUFFERS — stage diffs → populate PipelineBuffer count
12+ // Phase 0: SCHEDULE — DDG + Rau's → populate ScheduleNode cycle/stage
13+ // Phase 1: BUFFERS — stage diffs → populate ScheduleBuffer count
1414// Phase 1.5: WS — utilization → assign warp_group per stage
1515// Phase 2: EXPAND — bottom-up prologue/kernel/epilogue per loop
1616// Phase 3: LOWER — replace MLIR ops with async copies + barriers
1717
18- #ifndef TRITON_NVIDIA_HOPPER_MODULO_PIPELINE_IR_H
19- #define TRITON_NVIDIA_HOPPER_MODULO_PIPELINE_IR_H
18+ #ifndef TRITON_NVIDIA_HOPPER_MODULO_SCHEDULE_GRAPH_H
19+ #define TRITON_NVIDIA_HOPPER_MODULO_SCHEDULE_GRAPH_H
2020
2121#include " LatencyModel.h"
2222
@@ -37,7 +37,7 @@ enum class MemoryKind { SMEM, TMEM, Register, BARRIER };
3737
3838// / A multi-buffered memory allocation.
3939// / Represents SMEM or TMEM that needs multiple copies for pipelining.
40- struct PipelineBuffer {
40+ struct ScheduleBuffer {
4141 unsigned id{};
4242 MemoryKind kind{MemoryKind::SMEM};
4343 llvm::SmallVector<int64_t , 4 > shape; // e.g., {128, 64}
@@ -66,7 +66,7 @@ struct PipelineBuffer {
6666// ============================================================================
6767
6868// / A node in the pipeline graph. Wraps an MLIR Operation with scheduling info.
69- struct PipelineNode {
69+ struct ScheduleNode {
7070 unsigned id{};
7171 Operation *op{nullptr };
7272
@@ -78,11 +78,11 @@ struct PipelineNode {
7878 int selfLatency{0 }; // cycles this op occupies its pipeline
7979
8080 // Super-node: if this node represents a child pipeline (inner loop)
81- unsigned childPipelineId{UINT_MAX}; // index into PipelineGraph ::pipelines
81+ unsigned childPipelineId{UINT_MAX}; // index into ScheduleGraph ::pipelines
8282 int prologueLatency{0 }; // cycles before TC starts in child
8383
8484 // Buffer references
85- unsigned producesBuffer{UINT_MAX}; // index into PipelineLoop ::buffers
85+ unsigned producesBuffer{UINT_MAX}; // index into ScheduleLoop ::buffers
8686 llvm::SmallVector<unsigned , 2 > consumesBuffers; // indices into buffers
8787
8888 // Warp specialization (from Phase 1.5)
@@ -98,7 +98,7 @@ struct PipelineNode {
9898// Pipeline edge — producer-consumer dependency
9999// ============================================================================
100100
101- struct PipelineEdge {
101+ struct ScheduleEdge {
102102 unsigned srcId{};
103103 unsigned dstId{};
104104 int latency{};
@@ -112,7 +112,7 @@ struct PipelineEdge {
112112// / A pipelined loop with its schedule, nodes, edges, and buffers.
113113// / Analogous to a function: has inputs (consumed from outer scope),
114114// / outputs (produced for outer scope), and a body (nodes + edges).
115- struct PipelineLoop {
115+ struct ScheduleLoop {
116116 unsigned id{};
117117 scf::ForOp forOp;
118118
@@ -125,15 +125,15 @@ struct PipelineLoop {
125125 false }; // true if tripCount is estimated, not constant
126126
127127 // Body (kernel loop steady state)
128- llvm::SmallVector<PipelineNode , 16 > nodes;
129- llvm::SmallVector<PipelineEdge , 16 > edges;
128+ llvm::SmallVector<ScheduleNode , 16 > nodes;
129+ llvm::SmallVector<ScheduleEdge , 16 > edges;
130130
131131 // Expanded structure (populated after expansion, empty before)
132132 // Prologue: ops cloned before the loop (stage 0 of first iterations)
133133 // Epilogue: ops cloned after the loop (drain of last stage)
134- llvm::SmallVector<PipelineNode , 8 > prologueNodes;
135- llvm::SmallVector<PipelineNode , 8 > epilogueNodes;
136- bool isExpanded{false }; // true after expandPipelineGraph
134+ llvm::SmallVector<ScheduleNode , 8 > prologueNodes;
135+ llvm::SmallVector<ScheduleNode , 8 > epilogueNodes;
136+ bool isExpanded{false }; // true after expandScheduleGraph
137137
138138 // Memory interface (inputs/outputs crossing loop boundary)
139139 // These drive multi-buffering at the parent level.
@@ -151,18 +151,18 @@ struct PipelineLoop {
151151 llvm::SmallVector<MemPort, 4 > outputs; // produced for outer scope
152152
153153 // Multi-buffered allocations within this loop
154- llvm::SmallVector<PipelineBuffer , 4 > buffers;
154+ llvm::SmallVector<ScheduleBuffer , 4 > buffers;
155155
156156 // Lookup
157157 llvm::DenseMap<Operation *, unsigned > opToNodeId;
158158
159159 // Helpers
160- const PipelineNode &getNode (unsigned id) const {
160+ const ScheduleNode &getNode (unsigned id) const {
161161 assert (id < nodes.size () && " node id out of range" );
162162 return nodes[id];
163163 }
164164 // / Find the node for an MLIR op, or nullptr if not in this loop.
165- const PipelineNode *findNode (Operation *op) const {
165+ const ScheduleNode *findNode (Operation *op) const {
166166 auto it = opToNodeId.find (op);
167167 if (it == opToNodeId.end ())
168168 return nullptr ;
@@ -171,8 +171,8 @@ struct PipelineLoop {
171171 int numStages () const { return maxStage + 1 ; }
172172
173173 // / Get all nodes in a given stage.
174- llvm::SmallVector<const PipelineNode *> getNodesInStage (int stage) const {
175- llvm::SmallVector<const PipelineNode *> result;
174+ llvm::SmallVector<const ScheduleNode *> getNodesInStage (int stage) const {
175+ llvm::SmallVector<const ScheduleNode *> result;
176176 for (const auto &n : nodes)
177177 if (n.stage == stage)
178178 result.push_back (&n);
@@ -186,24 +186,24 @@ struct PipelineLoop {
186186
187187// / The complete pipeline graph for a kernel. Contains all pipelined loops
188188// / (potentially nested) and their relationships.
189- struct PipelineGraph {
190- llvm::SmallVector<PipelineLoop , 4 > loops;
189+ struct ScheduleGraph {
190+ llvm::SmallVector<ScheduleLoop , 4 > loops;
191191
192192 // / Add a new loop and return its id.
193193 unsigned addLoop (scf::ForOp forOp) {
194194 unsigned id = loops.size ();
195- PipelineLoop loop;
195+ ScheduleLoop loop;
196196 loop.id = id;
197197 loop.forOp = forOp;
198198 loops.push_back (std::move (loop));
199199 return id;
200200 }
201201
202- PipelineLoop &getLoop (unsigned id) {
202+ ScheduleLoop &getLoop (unsigned id) {
203203 assert (id < loops.size () && " loop id out of range" );
204204 return loops[id];
205205 }
206- const PipelineLoop &getLoop (unsigned id) const {
206+ const ScheduleLoop &getLoop (unsigned id) const {
207207 assert (id < loops.size () && " loop id out of range" );
208208 return loops[id];
209209 }
@@ -258,4 +258,4 @@ struct PipelineGraph {
258258
259259} // namespace mlir::triton::gpu
260260
261- #endif // TRITON_NVIDIA_HOPPER_MODULO_PIPELINE_IR_H
261+ #endif // TRITON_NVIDIA_HOPPER_MODULO_SCHEDULE_GRAPH_H
0 commit comments