@@ -64,7 +64,6 @@ struct Scop {
6464 static std::unique_ptr<Scop> makeScop (const Scop& scop) {
6565 auto res = std::unique_ptr<Scop>(new Scop ());
6666 res->parameterValues = scop.parameterValues ;
67- res->globalParameterContext = scop.globalParameterContext ;
6867 res->halide = scop.halide ;
6968 res->reads = scop.reads ;
7069 res->writes = scop.writes ;
@@ -79,10 +78,20 @@ struct Scop {
7978 return res;
8079 }
8180
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));
8695 }
8796
8897 // Specialize a Scop by fixing the given parameters to the given sizes.
@@ -108,8 +117,9 @@ struct Scop {
108117 return res;
109118 }
110119
111- // Specialize the Scop with respect to its globalParameterContext .
120+ // Specialize the Scop with respect to its context .
112121 void specializeToContext () {
122+ auto globalParameterContext = context ();
113123 domainRef () = domain ().intersect_params (globalParameterContext);
114124 reads = reads.intersect_params (globalParameterContext);
115125 writes = writes.intersect_params (globalParameterContext);
@@ -135,15 +145,14 @@ struct Scop {
135145 }
136146
137147 // 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
139149 // in parameterValues.
140150 template <typename T>
141151 void fixParameters (const std::unordered_map<std::string, T>& sizes) {
142152 CHECK (parameterValues.size () == 0 );
143153 for (const auto & kvp : sizes) {
144154 parameterValues.emplace (kvp.first , kvp.second );
145155 }
146- intersectContext (makeContext (sizes));
147156 }
148157
149158 // Return the list of parameter values in the same
@@ -491,22 +500,11 @@ struct Scop {
491500 // of the ScheduleTree "function".
492501 private:
493502 isl::union_set& domainRef ();
503+
494504 public:
495505 const isl::union_set domain () const ;
496506 // The parameter values of a specialized Scop.
497507 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
510508
511509 isl::union_map reads;
512510 isl::union_map writes;
0 commit comments