/* * 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. */ #include #include #include #include #include #include "likwid-marker.h" #include "parameter.h" #include "solver.h" #include "timing.h" #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 }; int main(int argc, char** argv) { int variant = SOR; double startTime, endTime; Parameter params; Solver solver; initParameter(¶ms); LIKWID_MARKER_INIT; if (argc < 2) { printf("Usage: %s \n", argv[0]); exit(EXIT_SUCCESS); } readParameter(¶ms, argv[1]); printParameter(¶ms); if (argc == 3) { variant = atoi(argv[2]); } initSolver(&solver, ¶ms, 2); 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; } printf("Solution took %.2fs\n", endTime - startTime); writeResult(&solver); LIKWID_MARKER_CLOSE; return EXIT_SUCCESS; }