NuSiF-Solver/PoissonSolver/2D-seq/src/main.c

68 lines
1.8 KiB
C
Raw Normal View History

2023-02-05 07:34:23 +01:00
/*
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
* All rights reserved.
* Use of this source code is governed by a MIT-style
* license that can be found in the LICENSE file.
*/
2023-06-18 10:08:56 +02:00
#include <float.h>
#include <limits.h>
2023-02-05 07:34:23 +01:00
#include <stdio.h>
2023-06-18 10:08:56 +02:00
#include <stdlib.h>
2023-02-05 07:34:23 +01:00
#include <unistd.h>
2023-06-18 13:55:23 +02:00
#include "likwid-marker.h"
2023-02-05 07:34:23 +01:00
#include "parameter.h"
#include "solver.h"
2023-06-18 10:08:56 +02:00
#include "timing.h"
2023-02-05 07:34:23 +01:00
2023-06-18 13:55:23 +02:00
#define LIKWID_PROFILE(tag, call) \
startTime = getTimeStamp(); \
LIKWID_MARKER_START(#tag); \
call(&solver); \
LIKWID_MARKER_STOP(#tag); \
endTime = getTimeStamp();
enum VARIANT { SOR = 1, RB, RBA };
2023-06-18 10:08:56 +02:00
int main(int argc, char** argv)
2023-02-05 07:34:23 +01:00
{
2023-06-18 13:55:23 +02:00
int variant = SOR;
2023-06-18 10:08:56 +02:00
double startTime, endTime;
2023-02-05 07:34:23 +01:00
Parameter params;
Solver solver;
initParameter(&params);
2023-06-18 13:55:23 +02:00
LIKWID_MARKER_INIT;
2023-02-05 07:34:23 +01:00
2023-06-18 13:55:23 +02:00
if (argc < 2) {
2023-06-18 10:08:56 +02:00
printf("Usage: %s <configFile>\n", argv[0]);
2023-02-05 07:34:23 +01:00
exit(EXIT_SUCCESS);
}
readParameter(&params, argv[1]);
printParameter(&params);
2023-06-18 13:55:23 +02:00
if (argc == 3) {
variant = atoi(argv[2]);
}
2023-02-05 07:34:23 +01:00
initSolver(&solver, &params, 2);
2023-06-18 13:55:23 +02:00
switch (variant) {
case SOR:
printf("Plain SOR\n");
LIKWID_PROFILE("SOR", solve);
break;
case RB:
printf("Red-black SOR\n");
LIKWID_PROFILE("RB", solveRB);
break;
case RBA:
printf("Red-black SOR with acceleration\n");
LIKWID_PROFILE("RBA", solveRBA);
break;
}
2023-06-18 10:08:56 +02:00
printf("Solution took %.2fs\n", endTime - startTime);
2023-02-05 07:34:23 +01:00
writeResult(&solver);
2023-06-18 13:55:23 +02:00
LIKWID_MARKER_CLOSE;
2023-02-05 07:34:23 +01:00
return EXIT_SUCCESS;
}