@@ -52,8 +52,10 @@ OperationSpace::OperationSpace(const Workload* wc, const OperationPoint& low, co
5252 // a data-space may not result in the exclusive high point in that data-space.
5353 for (unsigned space_id = 0 ; space_id < wc->GetShape ()->NumDataSpaces ; space_id++)
5454 {
55- auto space_low = Project (space_id, workload_, low);
56- auto space_high = Project (space_id, workload_, high);
55+ Point space_low (workload_->GetShape ()->DataSpaceOrder .at (space_id));
56+ Point space_high (workload_->GetShape ()->DataSpaceOrder .at (space_id));
57+
58+ ProjectLowHigh (space_id, workload_, low, high, space_low, space_high);
5759
5860 // Increment the high points by 1 because the AAHR constructor wants
5961 // an exclusive max point.
@@ -62,6 +64,46 @@ OperationSpace::OperationSpace(const Workload* wc, const OperationPoint& low, co
6264 }
6365}
6466
67+ void OperationSpace::ProjectLowHigh (Shape::DataSpaceID d,
68+ const Workload* wc,
69+ const OperationPoint& problem_low,
70+ const OperationPoint& problem_high,
71+ Point& data_space_low,
72+ Point& data_space_high)
73+ {
74+ for (unsigned data_space_dim = 0 ; data_space_dim < wc->GetShape ()->DataSpaceOrder .at (d); data_space_dim++)
75+ {
76+ data_space_low[data_space_dim] = 0 ;
77+ data_space_high[data_space_dim] = 0 ;
78+
79+ for (auto & term : wc->GetShape ()->Projections .at (d).at (data_space_dim))
80+ {
81+ Coordinate low = problem_low[term.second ];
82+ Coordinate high = problem_high[term.second ];
83+ if (term.first != wc->GetShape ()->NumCoefficients )
84+ {
85+ // If Coefficient is negative, flip high/low.
86+ auto coeff = wc->GetCoefficient (term.first );
87+ if (coeff < 0 )
88+ {
89+ data_space_low[data_space_dim] += (high * coeff);
90+ data_space_high[data_space_dim] += (low * coeff);
91+ }
92+ else
93+ {
94+ data_space_low[data_space_dim] += (low * coeff);
95+ data_space_high[data_space_dim] += (high * coeff);
96+ }
97+ }
98+ else
99+ {
100+ data_space_low[data_space_dim] += low;
101+ data_space_high[data_space_dim] += high;
102+ }
103+ }
104+ }
105+ }
106+
65107Point OperationSpace::Project (Shape::DataSpaceID d,
66108 const Workload* wc,
67109 const OperationPoint& problem_point)
0 commit comments