Commit 6593019e authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

added new test cases for sVar

parent b1d7c9f2
Pipeline #162408 canceled with stages
in 9 minutes and 39 seconds
......@@ -19,141 +19,7 @@ protected:
aggregate(WelfordAggregate(GetParam(), true)) {
}
/*
* Todo Test class with other than 2^K
*/
void TestUpdateSampleCounter(int samples) {
switch(samples) {
case 4:
switch(PPM->Size(0)) {
case 8:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 1);
EXPECT_EQ(aggregate.commSplit, 2);
break;
case 4:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 1);
EXPECT_EQ(aggregate.commSplit, 2);
break;
case 2:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 2);
EXPECT_EQ(aggregate.commSplit, 1);
break;
case 1:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 4);
EXPECT_EQ(aggregate.commSplit, 0);
break;
default: Warning("No test case for this amount of processes")
break;
}
break;
case 8:
switch(PPM->Size(0)) {
case 8:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 1);
EXPECT_EQ(aggregate.commSplit, 3);
break;
case 4:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 2);
EXPECT_EQ(aggregate.commSplit, 2);
break;
case 2:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 4);
EXPECT_EQ(aggregate.commSplit, 1);
break;
case 1:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 8);
EXPECT_EQ(aggregate.commSplit, 0);
break;
default: Warning("No test case for this amount of processes")
break;
}
break;
case 16:
switch(PPM->Size(0)) {
case 8:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 2);
EXPECT_EQ(aggregate.commSplit, 3);
break;
case 4:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 4);
EXPECT_EQ(aggregate.commSplit, 2);
break;
case 2:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 8);
EXPECT_EQ(aggregate.commSplit, 1);
break;
case 1:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 16);
EXPECT_EQ(aggregate.commSplit, 0);
break;
default: Warning("No test case for this amount of processes")
break;
}
break;
case 1000:
switch(PPM->Size(0)) {
case 8:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 125);
EXPECT_EQ(aggregate.commSplit, 3);
break;
case 4:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 250);
EXPECT_EQ(aggregate.commSplit, 2);
break;
case 2:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 500);
EXPECT_EQ(aggregate.commSplit, 1);
break;
case 1:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 1000);
EXPECT_EQ(aggregate.commSplit, 0);
break;
default: Warning("No test case for this amount of processes")
}
break;
}
}
void TestSampleCounterParallel() {
pout << "Before update: " << aggregate.ctr << endl;
while (aggregate.ctr.dMcomm != 0) aggregate.Update(1.0, 0.0, 0.0, 0.0);
pout << "After update: " << aggregate.ctr << endl;
aggregate.UpdateParallel();
pout << "After parallel update: " << aggregate.ctr << endl;
EXPECT_EQ(aggregate.ctr.M, numInitSamples);
}
void TestMeanParallel() {
pout << "Before update: " << aggregate.mean << endl;
while (aggregate.ctr.dMcomm != 0) aggregate.Update(1.0, 0.0, PPM->Proc(0), 0.0);
pout << "After update: " << aggregate.mean << endl;
aggregate.UpdateParallel();
pout << "After parallel update: " << aggregate.mean << endl;
double sumGauss = (pow((PPM->Size(0) - 1), 2) + (PPM->Size(0) - 1)) / 2.0;
double referenceMean = sumGauss / PPM->Size(0);
EXPECT_EQ(aggregate.mean.Q, referenceMean);
}
void TestSVarParallel() {
if (GetParam() == 4 || GetParam() == 8) return;
void TestSVarExample() {
pout << "Before update: " << DOUT(aggregate.sVar.Q) << endl;
pout << "Before update: " << DOUT(aggregate.mean.Q) << endl;
......@@ -210,11 +76,119 @@ protected:
};
INSTANTIATE_TEST_SUITE_P(TestWelfordAggregate, TestWelfordAggregate, Values(
4, 8, 16
4, 8, 16, 1000
));
/*
* Todo Test class with other than 2^K
*/
TEST_P(TestWelfordAggregate, TestInstanciation) {
TestUpdateSampleCounter(numInitSamples);
switch(numInitSamples) {
case 4:
switch(PPM->Size(0)) {
case 8:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 1);
EXPECT_EQ(aggregate.commSplit, 2);
break;
case 4:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 1);
EXPECT_EQ(aggregate.commSplit, 2);
break;
case 2:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 2);
EXPECT_EQ(aggregate.commSplit, 1);
break;
case 1:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 4);
EXPECT_EQ(aggregate.commSplit, 0);
break;
default: Warning("No test case for this amount of processes")
break;
}
break;
case 8:
switch(PPM->Size(0)) {
case 8:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 1);
EXPECT_EQ(aggregate.commSplit, 3);
break;
case 4:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 2);
EXPECT_EQ(aggregate.commSplit, 2);
break;
case 2:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 4);
EXPECT_EQ(aggregate.commSplit, 1);
break;
case 1:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 8);
EXPECT_EQ(aggregate.commSplit, 0);
break;
default: Warning("No test case for this amount of processes")
break;
}
break;
case 16:
switch(PPM->Size(0)) {
case 8:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 2);
EXPECT_EQ(aggregate.commSplit, 3);
break;
case 4:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 4);
EXPECT_EQ(aggregate.commSplit, 2);
break;
case 2:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 8);
EXPECT_EQ(aggregate.commSplit, 1);
break;
case 1:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 16);
EXPECT_EQ(aggregate.commSplit, 0);
break;
default: Warning("No test case for this amount of processes")
break;
}
break;
case 1000:
switch(PPM->Size(0)) {
case 8:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 125);
EXPECT_EQ(aggregate.commSplit, 3);
break;
case 4:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 250);
EXPECT_EQ(aggregate.commSplit, 2);
break;
case 2:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 500);
EXPECT_EQ(aggregate.commSplit, 1);
break;
case 1:
pout << DOUT(aggregate.ctr) << DOUT(aggregate.commSplit) << endl;
EXPECT_EQ(aggregate.ctr.dMcomm, 1000);
EXPECT_EQ(aggregate.commSplit, 0);
break;
default: Warning("No test case for this amount of processes")
}
break;
}
}
TEST_P(TestWelfordAggregate, TestIndex) {
......@@ -246,15 +220,76 @@ TEST_P(TestWelfordAggregate, TestIndex) {
}
TEST_P(TestWelfordAggregate, TestSampleCounter) {
TestSampleCounterParallel();
pout << "Before update: " << aggregate.ctr << endl;
while (aggregate.ctr.dMcomm != 0) aggregate.Update(1.0, 0.0, 0.0, 0.0);
pout << "After update: " << aggregate.ctr << endl;
aggregate.UpdateParallel();
pout << "After parallel update: " << aggregate.ctr << endl;
EXPECT_EQ(aggregate.ctr.M, numInitSamples);
}
TEST_P(TestWelfordAggregate, TestMean) {
TestMeanParallel();
pout << "Before update: " << aggregate.mean << endl;
while (aggregate.ctr.dMcomm != 0) aggregate.Update(1.0, 0.0, PPM->Proc(0), 0.0);
pout << "After update: " << aggregate.mean << endl;
aggregate.UpdateParallel();
pout << "After parallel update: " << aggregate.mean << endl;
double sumGauss = (pow((PPM->Size(0) - 1), 2) + (PPM->Size(0) - 1)) / 2.0;
double referenceMean = sumGauss / PPM->Size(0);
EXPECT_EQ(aggregate.mean.Q, referenceMean);
}
TEST_P(TestWelfordAggregate, TestSVar) {
TestSVarParallel();
switch(numInitSamples) {
case 4:
switch(PPM->Size(0)) {
case 8:
case 4:
case 2:
TestSVarExample();
break;
case 1:
TestSVarExample();
break;
default: Warning("No test case for this amount of processes")
}
break;
case 8:
switch(PPM->Size(0)) {
case 8:
case 4:
TestSVarExample();
break;
case 2:
TestSVarExample();
break;
case 1:
default: Warning("No test case for this amount of processes")
}
break;
case 16:
switch(PPM->Size(0)) {
case 8:
TestSVarExample();
break;
case 4:
TestSVarExample();
break;
case 2:
case 1:
default: Warning("No test case for this amount of processes")
}
break;
case 1000:
switch(PPM->Size(0)) {
case 8:
case 4:
case 2:
case 1:
default: Warning("No test case for this amount of processes")
}
break;
}
}
#endif //TESTWELFORDAGGREGATE_HPP
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