Skip to content

Commit db03356

Browse files
Fixed a bug due to which a negative coefficient in a problem specification would generate incorrect high/low bounds while constructing the AAHR for a data-space.
1 parent dfb5770 commit db03356

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

src/workload/operation-space.cpp

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
65107
Point OperationSpace::Project(Shape::DataSpaceID d,
66108
const Workload* wc,
67109
const OperationPoint& problem_point)

src/workload/operation-space.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ class OperationSpace
6161
private:
6262
Point Project(Shape::DataSpaceID d, const Workload* wc,
6363
const OperationPoint& problem_point);
64+
void ProjectLowHigh(Shape::DataSpaceID d,
65+
const Workload* wc,
66+
const OperationPoint& problem_low,
67+
const OperationPoint& problem_high,
68+
Point& data_space_low,
69+
Point& data_space_high);
6470

6571
public:
6672
OperationSpace();

0 commit comments

Comments
 (0)