@@ -321,6 +321,8 @@ struct ScheduleTreeAndDomain {
321
321
* recursively descending over the Stmt.
322
322
* "s" is the current position in the recursive descent.
323
323
* "set" describes the bounds on the outer loop iterators.
324
+ * "outer" contains the names of the outer loop iterators
325
+ * from outermost to innermost.
324
326
* Return the schedule tree corresponding to the subtree at "s",
325
327
* along with a separated out domain.
326
328
*
@@ -329,14 +331,18 @@ struct ScheduleTreeAndDomain {
329
331
* (for the writes) to the corresponding tag in the access relations.
330
332
* "statements" collects the mapping from instance set tuple identifiers
331
333
* to the corresponding Provide node.
334
+ * "iterators" collects the mapping from instance set tuple identifiers
335
+ * to the corresponding outer loop iterator names, from outermost to innermost.
332
336
*/
333
337
ScheduleTreeAndDomain makeScheduleTreeHelper (
334
338
const Stmt& s,
335
339
isl::set set,
340
+ std::vector<std::string>& outer,
336
341
isl::union_map* reads,
337
342
isl::union_map* writes,
338
343
AccessMap* accesses,
339
- StatementMap* statements) {
344
+ StatementMap* statements,
345
+ IteratorMap* iterators) {
340
346
ScheduleTreeAndDomain result;
341
347
if (auto op = s.as <For>()) {
342
348
// Add one additional dimension to our set of loop variables
@@ -372,8 +378,17 @@ ScheduleTreeAndDomain makeScheduleTreeHelper(
372
378
}
373
379
374
380
// Recursively descend.
381
+ auto outerNext = outer;
382
+ outerNext.push_back (op->name );
375
383
auto body = makeScheduleTreeHelper (
376
- op->body , set, reads, writes, accesses, statements);
384
+ op->body ,
385
+ set,
386
+ outerNext,
387
+ reads,
388
+ writes,
389
+ accesses,
390
+ statements,
391
+ iterators);
377
392
378
393
// Create an affine function that defines an ordering for all
379
394
// the statements in the body of this loop over the values of
@@ -419,8 +434,8 @@ ScheduleTreeAndDomain makeScheduleTreeHelper(
419
434
// children.
420
435
std::vector<ScheduleTreeUPtr> trees;
421
436
for (Stmt s : stmts) {
422
- auto mem =
423
- makeScheduleTreeHelper ( s, set, reads, writes, accesses, statements);
437
+ auto mem = makeScheduleTreeHelper (
438
+ s, set, outer, reads, writes, accesses, statements, iterators );
424
439
ScheduleTreeUPtr filter;
425
440
if (mem.tree ) {
426
441
// No statement instances are shared between the blocks, so we
@@ -452,6 +467,7 @@ ScheduleTreeAndDomain makeScheduleTreeHelper(
452
467
size_t stmtIndex = statements->size ();
453
468
isl::id id (set.get_ctx (), kStatementLabel + std::to_string (stmtIndex));
454
469
statements->emplace (id, op);
470
+ iterators->emplace (id, outer);
455
471
isl::set domain = set.set_tuple_id (id);
456
472
result.domain = domain;
457
473
@@ -474,13 +490,16 @@ ScheduleTreeAndAccesses makeScheduleTree(isl::space paramSpace, const Stmt& s) {
474
490
result.writes = result.reads = isl::union_map::empty (paramSpace);
475
491
476
492
// Walk the IR building a schedule tree
493
+ std::vector<std::string> outer;
477
494
auto treeAndDomain = makeScheduleTreeHelper (
478
495
s,
479
496
isl::set::universe (paramSpace),
497
+ outer,
480
498
&result.reads ,
481
499
&result.writes ,
482
500
&result.accesses ,
483
- &result.statements );
501
+ &result.statements ,
502
+ &result.iterators );
484
503
485
504
// TODO: This fails if the stmt is just a Provide node, I'm not sure
486
505
// what the schedule tree should look like in that case.
0 commit comments