@@ -48,14 +48,16 @@ bool isMappingIdType(const mapping::MappingId& id) {
48
48
}
49
49
50
50
/*
51
- * Is "tree" a mapping filter that maps a thread identifier?
51
+ * Is "tree" a mapping filter that maps identifiers of the type provided as
52
+ * template argument?
52
53
*/
53
- bool isThreadMapping (const detail::ScheduleTree* tree) {
54
+ template <typename MappingType>
55
+ bool isMappingTo (const detail::ScheduleTree* tree) {
54
56
using namespace detail ;
55
57
56
58
if (auto filterNode = tree->elemAs <ScheduleTreeElemMappingFilter>()) {
57
59
for (auto & kvp : filterNode->mapping ) {
58
- if (isMappingIdType<mapping::ThreadId >(kvp.first )) {
60
+ if (isMappingIdType<MappingType >(kvp.first )) {
59
61
return true ;
60
62
}
61
63
}
@@ -100,7 +102,7 @@ void mapCopiesToThreads(MappedScop& mscop, bool unroll) {
100
102
// Check that we are not mapping to threads below other thread mappings.
101
103
std::unordered_set<mapping::ThreadId, mapping::ThreadId::Hash> usedThreads;
102
104
for (auto n : node->ancestors (root)) {
103
- if (isThreadMapping (n)) {
105
+ if (isMappingTo<mapping::ThreadId> (n)) {
104
106
throw promotion::PromotionBelowThreadsException (
105
107
" attempted to map memory copies to threads below "
106
108
" another thread mapping" );
@@ -257,7 +259,7 @@ const detail::ScheduleTree* findThreadMappingAncestor(
257
259
const detail::ScheduleTree* root,
258
260
const detail::ScheduleTree* node) {
259
261
auto ancestors = node->ancestors (root);
260
- ancestors = functional::Filter (isThreadMapping , ancestors);
262
+ ancestors = functional::Filter (isMappingTo<mapping::ThreadId> , ancestors);
261
263
if (ancestors.size () < 1 ) {
262
264
throw promotion::PromotionLogicError (" missing MappingFilter" );
263
265
}
0 commit comments