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

Commit d9ae24d

Browse files
author
Sven Verdoolaege
committed
move mapToParameterWithExtent to mapped_scop.cc
Since the previous commit, this function is only called from within MappedScop::mapThreadsBackward and MappedScop::mapBlocksForward. Move it to mapped_scop.cc such that it can be reworked to only create a single mapping filter node.
1 parent 343a2d5 commit d9ae24d

File tree

3 files changed

+39
-47
lines changed

3 files changed

+39
-47
lines changed

tc/core/polyhedral/cuda/mapped_scop.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,45 @@ template <>
106106
const CudaDim& mappingSize<mapping::ThreadId>(const MappedScop* mscop) {
107107
return mscop->numThreads;
108108
}
109+
110+
// Map "pos"-th schedule dimension of the band node identified by "tree" to a
111+
// _new_ parameter identified by "id" and limited by 0 <= id < extent. The
112+
// parameter must not be present in the space of partial schedule of "tree" and
113+
// extent must be non-zero. The mapping corresponds to inserting a filter
114+
// node with condition 'dim % extent = id' where dim is "pos"-th
115+
// schedule dimension.
116+
//
117+
// Returns a pointer to the updated band (below the inserted filter)
118+
// for call chaining purposes.
119+
template <typename MappingIdType>
120+
detail::ScheduleTree* mapToParameterWithExtent(
121+
detail::ScheduleTree* root,
122+
detail::ScheduleTree* tree,
123+
size_t pos,
124+
MappingIdType id,
125+
size_t extent) {
126+
auto band = tree->elemAs<detail::ScheduleTreeElemBand>();
127+
CHECK(band) << "expected a band, got " << *tree;
128+
CHECK_GE(pos, 0u) << "dimension underflow";
129+
CHECK_LT(pos, band->nMember()) << "dimension overflow";
130+
CHECK_NE(extent, 0u) << "NYI: mapping to 0";
131+
132+
auto domain = activeDomainPoints(root, tree).universe();
133+
134+
// Introduce the "mapping" parameter after checking it is not already present
135+
// in the schedule space.
136+
CHECK(not band->mupa_.involves_param(id));
137+
138+
// Create mapping filter by equating the newly introduced
139+
// parameter "id" to the "pos"-th schedule dimension modulo its extent.
140+
auto upa =
141+
band->mupa_.get_union_pw_aff(pos).mod_val(isl::val(tree->ctx_, extent));
142+
upa = upa.sub(isl::union_pw_aff::param_on_domain(domain, id));
143+
auto filter = upa.zero_union_set();
144+
auto mapping =
145+
detail::ScheduleTree::makeMappingFilter<MappingIdType>(filter, {id});
146+
return insertNodeAbove(root, tree, std::move(mapping))->child({0});
147+
}
109148
} // namespace
110149

111150
template <typename MappingTypeId>

tc/core/polyhedral/schedule_transforms-inl.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,5 @@ inline detail::ScheduleTree* insertNodeBelow(
3939
tree->appendChild(std::move(node));
4040
return tree->child({0});
4141
}
42-
43-
template <typename MappingIdType>
44-
inline detail::ScheduleTree* mapToParameterWithExtent(
45-
detail::ScheduleTree* root,
46-
detail::ScheduleTree* tree,
47-
size_t pos,
48-
MappingIdType id,
49-
size_t extent) {
50-
auto band = tree->elemAs<detail::ScheduleTreeElemBand>();
51-
CHECK(band) << "expected a band, got " << *tree;
52-
CHECK_GE(pos, 0u) << "dimension underflow";
53-
CHECK_LT(pos, band->nMember()) << "dimension overflow";
54-
CHECK_NE(extent, 0u) << "NYI: mapping to 0";
55-
56-
auto domain = activeDomainPoints(root, tree).universe();
57-
58-
// Introduce the "mapping" parameter after checking it is not already present
59-
// in the schedule space.
60-
CHECK(not band->mupa_.involves_param(id));
61-
62-
// Create mapping filter by equating the newly introduced
63-
// parameter "id" to the "pos"-th schedule dimension modulo its extent.
64-
auto upa =
65-
band->mupa_.get_union_pw_aff(pos).mod_val(isl::val(tree->ctx_, extent));
66-
upa = upa.sub(isl::union_pw_aff::param_on_domain(domain, id));
67-
auto filter = upa.zero_union_set();
68-
auto mapping =
69-
detail::ScheduleTree::makeMappingFilter<MappingIdType>(filter, {id});
70-
return insertNodeAbove(root, tree, std::move(mapping))->child({0});
71-
}
7242
} // namespace polyhedral
7343
} // namespace tc

tc/core/polyhedral/schedule_transforms.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,6 @@ detail::ScheduleTree* bandScale(
114114
detail::ScheduleTree* tree,
115115
const std::vector<size_t>& scales);
116116

117-
// Map "pos"-th schedule dimension of the band node identified by "tree" to a
118-
// _new_ parameter identified by "id" and limited by 0 <= id < extent. The
119-
// parameter must not be present in the space of partial schedule of "tree" and
120-
// extent must be non-zero. The mapping corresponds to inserting a filter
121-
// node with condition 'dim % extent = id' where dim is "pos"-th
122-
// schedule dimension.
123-
//
124-
// Returns a pointer to the updated band (below the inserted filter)
125-
// for call chaining purposes.
126-
template <typename MappingIdType>
127-
detail::ScheduleTree* mapToParameterWithExtent(
128-
detail::ScheduleTree* root,
129-
detail::ScheduleTree* tree,
130-
size_t pos,
131-
MappingIdType id,
132-
size_t extent);
133-
134117
// Update the top-level conext node by intersecting it with "context". The
135118
// top-level context node must be located directly under the root of the tree.
136119
// If there is no such node, insert one with universe context first.

0 commit comments

Comments
 (0)