@@ -64,7 +64,6 @@ struct Scop {
64
64
static std::unique_ptr<Scop> makeScop (const Scop& scop) {
65
65
auto res = std::unique_ptr<Scop>(new Scop ());
66
66
res->parameterValues = scop.parameterValues ;
67
- res->globalParameterContext = scop.globalParameterContext ;
68
67
res->halide = scop.halide ;
69
68
res->reads = scop.reads ;
70
69
res->writes = scop.writes ;
@@ -79,10 +78,20 @@ struct Scop {
79
78
return res;
80
79
}
81
80
82
- // Intersect globalParameterContext with extraGlobalParameterContext.
83
- inline void intersectContext (isl::set extraGlobalParameterContext) {
84
- auto context = globalParameterContext & extraGlobalParameterContext;
85
- globalParameterContext = context;
81
+ // Return a context encapsulating all known information about
82
+ // the parameters. In particular, all parameters are known
83
+ // to be non-negative and the parameters fixed by fixParameters
84
+ // have a known value.
85
+ // This context lives in a parameter space.
86
+ // The scop is not necessarily specialized to its context.
87
+ // Call specializeToContext to perform this specialization.
88
+ // The schedule tree of the scop does not necessarily have
89
+ // a context node. Call updateTopLevelContext on the schedule tree
90
+ // to introduce or refine such a context node.
91
+ isl::set context () const {
92
+ auto ctx = domain ().get_ctx ();
93
+ auto context = halide2isl::makeParamContext (ctx, halide.params );
94
+ return context.intersect (makeContext (parameterValues));
86
95
}
87
96
88
97
// Specialize a Scop by fixing the given parameters to the given sizes.
@@ -108,8 +117,9 @@ struct Scop {
108
117
return res;
109
118
}
110
119
111
- // Specialize the Scop with respect to its globalParameterContext .
120
+ // Specialize the Scop with respect to its context .
112
121
void specializeToContext () {
122
+ auto globalParameterContext = context ();
113
123
domainRef () = domain ().intersect_params (globalParameterContext);
114
124
reads = reads.intersect_params (globalParameterContext);
115
125
writes = writes.intersect_params (globalParameterContext);
@@ -135,15 +145,14 @@ struct Scop {
135
145
}
136
146
137
147
// Fix the values of the specified parameters in the context
138
- // to the corresponding specified values and keep track of them
148
+ // to the corresponding specified values by keeping track of them
139
149
// in parameterValues.
140
150
template <typename T>
141
151
void fixParameters (const std::unordered_map<std::string, T>& sizes) {
142
152
CHECK (parameterValues.size () == 0 );
143
153
for (const auto & kvp : sizes) {
144
154
parameterValues.emplace (kvp.first , kvp.second );
145
155
}
146
- intersectContext (makeContext (sizes));
147
156
}
148
157
149
158
// Return the list of parameter values in the same
@@ -491,22 +500,11 @@ struct Scop {
491
500
// of the ScheduleTree "function".
492
501
private:
493
502
isl::union_set& domainRef ();
503
+
494
504
public:
495
505
const isl::union_set domain () const ;
496
506
// The parameter values of a specialized Scop.
497
507
std::unordered_map<std::string, int > parameterValues;
498
- // A globalParameterContext is kept. This represents (partial)
499
- // parameter specialization coming from the outside.
500
- // This may be further specialized before codegen.
501
- // This globalParameterContext must not give rise to a context node in the
502
- // schedule tree.
503
- // This globalParameterContext is intersected with the domain of the
504
- // ScheduleTree for best possible specialization of polyhedral decisions and
505
- // transformations. By the analogy with generalized functions, the
506
- // globalParameterContext becomes part of the "support" of the ScheduleTree
507
- // "function".
508
- // This globalParameterContext lives in a parameter space.
509
- isl::set globalParameterContext; // TODO: not too happy about this name
510
508
511
509
isl::union_map reads;
512
510
isl::union_map writes;
0 commit comments