Implemented Function pointer for SOR, RB and RBA variants
This commit is contained in:
@@ -26,7 +26,7 @@ enum VARIANT { SOR = 1, RB, RBA };
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int variant = SOR;
|
||||
int variant = RB;
|
||||
double startTime, endTime;
|
||||
Parameter params;
|
||||
Solver solver;
|
||||
@@ -39,27 +39,30 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
readParameter(¶ms, argv[1]);
|
||||
printParameter(¶ms);
|
||||
//printParameter(¶ms);
|
||||
|
||||
|
||||
|
||||
initSolver(&solver, ¶ms, 2);
|
||||
if (argc == 3) {
|
||||
variant = atoi(argv[2]);
|
||||
}
|
||||
|
||||
initSolver(&solver, ¶ms, 2);
|
||||
|
||||
switch (variant) {
|
||||
case SOR:
|
||||
printf("Plain SOR\n");
|
||||
//printf("Plain SOR\n");
|
||||
LIKWID_PROFILE("SOR", solve);
|
||||
break;
|
||||
case RB:
|
||||
printf("Red-black SOR\n");
|
||||
//printf("Red-black SOR\n");
|
||||
LIKWID_PROFILE("RB", solveRB);
|
||||
break;
|
||||
case RBA:
|
||||
printf("Red-black SOR with acceleration\n");
|
||||
//printf("Red-black SOR with acceleration\n");
|
||||
LIKWID_PROFILE("RBA", solveRBA);
|
||||
break;
|
||||
}
|
||||
printf("Solution took %.2fs\n", endTime - startTime);
|
||||
//printf("Solution took %.2fs\n", endTime - startTime);
|
||||
writeResult(&solver);
|
||||
|
||||
LIKWID_MARKER_CLOSE;
|
||||
|
@@ -108,7 +108,8 @@ void solve(Solver* solver)
|
||||
it++;
|
||||
}
|
||||
|
||||
printf("Solver took %d iterations to reach %f\n", it, sqrt(res));
|
||||
//printf("Solver took %d iterations to reach %f\n", it, sqrt(res));
|
||||
printf("%d, %f\n", it, solver->omega);
|
||||
}
|
||||
|
||||
void solveRB(Solver* solver)
|
||||
@@ -168,7 +169,8 @@ void solveRB(Solver* solver)
|
||||
it++;
|
||||
}
|
||||
|
||||
printf("Solver took %d iterations to reach %f\n", it, sqrt(res));
|
||||
//printf("Solver took %d iterations to reach %f\n", it, sqrt(res));
|
||||
printf("%d, %f\n", it, solver->omega);
|
||||
}
|
||||
|
||||
void solveRBA(Solver* solver)
|
||||
@@ -232,8 +234,9 @@ void solveRBA(Solver* solver)
|
||||
it++;
|
||||
}
|
||||
|
||||
printf("Final omega: %f\n", omega);
|
||||
printf("Solver took %d iterations to reach %f\n", it, sqrt(res));
|
||||
//printf("Final omega: %f\n", omega);
|
||||
//printf("Solver took %d iterations to reach %f\n", it, sqrt(res));
|
||||
printf("%d, %f\n", it, omega);
|
||||
}
|
||||
|
||||
void writeResult(Solver* solver)
|
||||
|
Reference in New Issue
Block a user