JacobiHPC/src/main.c

45 lines
1004 B
C

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include "config.h"
#include "utils.h"
double *compute_jacobi(int n, double init_value, double threshold, borders b, int *iterations);
int main(int argc, char* argv[]) {
int n;
double init_value, threshold;
borders b;
int config_loaded;
configuration config;
double *x;
clock_t starttime, endtime;
int iterations;
config_loaded = load_config(&config);
if (config_loaded != 0) {
return 1;
}
n = config.n;
threshold = config.threshold;
init_value = config.init_value;
b.north = config.north;
b.south = config.south;
b.east = config.east;
b.west = config.west;
starttime = clock();
x = compute_jacobi(n, init_value, threshold, b, &iterations);
endtime = clock();
printf("clock time: %fs\n", (double)(endtime - starttime) / CLOCKS_PER_SEC);
printf("Iterations: %d\n", iterations);
if (n < 10) {
print_sa_matrix(x, n + 2, n + 2);
}
destroy_sa_matrix(x);
return 0;
}