Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 6c79479

Browse files
committed
extractDomainToIds: do not assume all mapping nodes contain the given ids
A subtree may have mapping filter nodes with different ids. If this function is called on such subtree, it would fail even if all branches of a subtree are mapped to the given ids because it sees a mapping filter node with different ids. Simply ignore the node that does not contain all of the requested ids. The check was originally introduced in extractDomainToThreads and was meant to ensure that all branches in the subtree are indeed mapped to threads. Instead, perform a stricter check inside extractDomainToIds that all active domain elements were indeed mapped to the given identifiers.
1 parent eb1cb66 commit 6c79479

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

tc/core/polyhedral/cuda/mapped_scop.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ isl::multi_union_pw_aff MappedScop::threadMappingSchedule(
509509
ids.emplace_back(mapping::ThreadId::makeId(i));
510510
}
511511
auto tupleId = isl::id(tree->ctx_, kBlock);
512-
return extractDomainToIds(tree, ids, tupleId);
512+
return extractDomainToIds(scop_->scheduleRoot(), tree, ids, tupleId);
513513
}
514514

515515
isl::multi_union_pw_aff MappedScop::blockMappingSchedule(

tc/core/polyhedral/schedule_transforms.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ void orderAfter(ScheduleTree* root, ScheduleTree* tree, isl::union_set filter) {
806806
* The result lives in a space of the form "tupleId"["ids"...].
807807
*/
808808
isl::multi_union_pw_aff extractDomainToIds(
809+
const detail::ScheduleTree* root,
809810
const detail::ScheduleTree* tree,
810811
const std::vector<mapping::MappingId>& ids,
811812
isl::id tupleId) {
@@ -821,14 +822,24 @@ isl::multi_union_pw_aff extractDomainToIds(
821822
auto mappingNode = mapping->elemAs<ScheduleTreeElemMappingFilter>();
822823
auto list = isl::union_pw_aff_list(tree->ctx_, ids.size());
823824
for (auto id : ids) {
824-
CHECK_GT(mappingNode->mapping.count(id), 0) << "no mapping to id " << id;
825+
if (mappingNode->mapping.count(id) == 0) {
826+
break;
827+
}
825828
auto idMap = mappingNode->mapping.at(id);
826829
list = list.add(idMap);
827830
}
831+
// Ignore this node if it does not map to all required ids.
832+
if (static_cast<size_t>(list.n()) != ids.size()) {
833+
continue;
834+
}
828835
auto nodeToIds = isl::multi_union_pw_aff(space, list);
829836
domainToIds = domainToIds.union_add(nodeToIds);
830837
}
831838

839+
TC_CHECK(activeDomainPoints(root, tree).is_subset(domainToIds.domain()))
840+
<< "not all domain points of" << activeDomainPoints(root, tree)
841+
<< "were mapped to the required ids";
842+
832843
return domainToIds;
833844
}
834845

tc/core/polyhedral/schedule_transforms.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,12 @@ isl::union_set activeDomainPointsBelow(
326326
const detail::ScheduleTree* root,
327327
const detail::ScheduleTree* node);
328328

329-
// Extract a mapping from the domain elements active at "tree"
330-
// to identifiers "ids", where all branches in "tree"
331-
// are assumed to have been mapped to these identifiers.
332-
// The result lives in a space of the form "tupleId"["ids"...].
329+
// Extract a mapping from the domain elements active at "tree" (in a tree
330+
// rooted at "root") to identifiers "ids", where all branches in "tree" are
331+
// assumed to have been mapped to these identifiers. The result lives in a
332+
// space of the form "tupleId"["ids"...].
333333
isl::multi_union_pw_aff extractDomainToIds(
334+
const detail::ScheduleTree* root,
334335
const detail::ScheduleTree* tree,
335336
const std::vector<mapping::MappingId>& ids,
336337
isl::id tupleId);

0 commit comments

Comments
 (0)