Commit a64346c0 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

implementing update parallel

parent b5c4ffdb
......@@ -3,18 +3,35 @@
void Sums::Update(SampleSolution &fineSolution, SampleSolution &coarseSolution) {
double diffQ = fineSolution.Q - coarseSolution.Q; // Todo might be unstable!
Cost += fineSolution.Cost;
Q += fineSolution.Q;
Q2 += fineSolution.Q * fineSolution.Q;
Q3 += fineSolution.Q * fineSolution.Q * fineSolution.Q;
Q4 += fineSolution.Q * fineSolution.Q * fineSolution.Q * fineSolution.Q;
double Qf = fineSolution.Q;
double Qc = coarseSolution.Q;
double diffQ = Qf - Qc;
Q += Qf;
Q2 += Qf * Qf;
Q3 += Qf * Qf * Qf;
Q4 += Qf * Qf * Qf * Qf;
Y += diffQ;
Y2 += diffQ * diffQ;
Y3 += diffQ * diffQ * diffQ;
Y4 += diffQ * diffQ * diffQ * diffQ;
}
void Sums::UpdateParallel(SampleCounter ctr) {
for (int i = 0; i < ceil(log2(PPM->Size(0))) + 1; i++) {
if (ctr.commSplit == PPM->MaxCommSplit() - i) {
Q = PPM->SumOnCommSplit(Q, i);
Q2 = PPM->SumOnCommSplit(Q2, i);
Q3 = PPM->SumOnCommSplit(Q3, i);
Q4 = PPM->SumOnCommSplit(Q4, i);
Y = PPM->SumOnCommSplit(Y, i);
Y2 = PPM->SumOnCommSplit(Y2, i);
Y3 = PPM->SumOnCommSplit(Y3, i);
Y4 = PPM->SumOnCommSplit(Y4, i);
}
}
}
void Averages::Update(Sums sums, int M) {
Cost = sums.Cost / M;
Y = abs(sums.Y / M);
......@@ -25,14 +42,6 @@ void Averages::Update(Sums sums, int M) {
Q2 = sums.Q2 / M;
Q3 = sums.Q3 / M;
Q4 = sums.Q4 / M;
// Y = abs(PPM->SumOnCommSplit(sums.Y, 0) / M);
// Y2 = PPM->SumOnCommSplit(sums.Y2, 0) / M;
// Y3 = PPM->SumOnCommSplit(sums.Y3, 0) / M;
// Y4 = PPM->SumOnCommSplit(sums.Y4, 0) / M;
// Q = abs(PPM->SumOnCommSplit(sums.Q, 0) / M);
// Q2 = PPM->SumOnCommSplit(sums.Q2, 0) / M;
// Q3 = PPM->SumOnCommSplit(sums.Q3, 0) / M;
// Q4 = PPM->SumOnCommSplit(sums.Q4, 0) / M;
}
void Variances::Update(Averages avgs) {
......
......@@ -28,6 +28,8 @@ struct Sums {
Q(Q), Q2(Q2), Q3(Q3), Q4(Q4), Y(Y), Y2(Y2), Y3(Y3), Y4(Y4), Cost(Cost) {}
void Update(SampleSolution &fineSolution, SampleSolution &coarseSolution);
void UpdateParallel(SampleCounter ctr);
};
struct Averages {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment