@@ -429,6 +429,22 @@ std::vector<detail::ScheduleTree*> bandsSplitAfterDepth(
429
429
return functional::Map (splitAtDepth, bands);
430
430
}
431
431
432
+ /*
433
+ * Check if "node" or any of its ancestors until "root" are thread mappings.
434
+ */
435
+ bool isInThreadMappedScope (
436
+ const detail::ScheduleTree* root,
437
+ const detail::ScheduleTree* node) {
438
+ auto ancestors = node->ancestors (root);
439
+ ancestors.push_back (node);
440
+ for (auto ancestor : ancestors) {
441
+ if (isMappingTo<mapping::ThreadId>(ancestor)) {
442
+ return true ;
443
+ }
444
+ }
445
+ return false ;
446
+ }
447
+
432
448
/*
433
449
* Promote to shared memory in "scop" below "node". Use at most
434
450
* "remainingMemory" bytes, and update the variable to reflect the amount of
@@ -443,13 +459,9 @@ void promoteToSharedBelow(
443
459
// Promotion to shared below threads does not make sense because the computed
444
460
// groups would be specific to threads thus not benefiting from coalescing or
445
461
// inter-thread communication through shared memory (use registers instead).
446
- auto ancestors = node->ancestors (root);
447
- ancestors.push_back (node);
448
- for (auto ancestor : ancestors) {
449
- if (isMappingTo<mapping::ThreadId>(ancestor)) {
450
- throw promotion::IncorrectScope (
451
- " shared memory promotion below thread mapping" );
452
- }
462
+ if (isInThreadMappedScope (root, node)) {
463
+ throw promotion::IncorrectScope (
464
+ " shared memory promotion below thread mapping" );
453
465
}
454
466
// Children of a sequence/set band must be filters, but promotion would
455
467
// insert an extension node.
0 commit comments