This commit is contained in:
Fabio Salvini
2016-11-13 10:39:28 +01:00
parent 784416b7ca
commit 51442687a0
3 changed files with 54 additions and 44 deletions

View File

@@ -1,7 +1,7 @@
# Configuration file for the Jacobi project.
# The size of the matrix (borders excluded).
N 5000
N 3000
# The value at each border.
NORTH 0.0

View File

@@ -9,7 +9,7 @@
#include "../config/config.h"
#include "../utils/utils.h"
void compute_jacobi(int n, double init_value, double threshold, borders b);
double **compute_jacobi(int n, double init_value, double threshold, borders b);
int main(int argc, char* argv[]) {
int numprocs;
@@ -17,6 +17,7 @@ int main(int argc, char* argv[]) {
configuration config;
borders b;
double startwtime = 0.0, endwtime;
double **x;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
@@ -36,17 +37,18 @@ int main(int argc, char* argv[]) {
b.west = config.west;
startwtime = MPI_Wtime();
compute_jacobi(config.n, config.init_value, config.threshold, b);
x = compute_jacobi(config.n, config.init_value, config.threshold, b);
endwtime = MPI_Wtime();
printf("Wall clock time: %fs\n", endwtime - startwtime);
destroy_matrix(x, config.n + 2);
MPI_Finalize();
return 0;
}
void compute_jacobi(int n, double init_value, double threshold, borders b) {
double **compute_jacobi(int n, double init_value, double threshold, borders b) {
double **x;
double max_diff, new_x;
int i, j;
@@ -76,6 +78,5 @@ void compute_jacobi(int n, double init_value, double threshold, borders b) {
}
}
} while (max_diff > threshold);
destroy_matrix(x, n + 2);
return x;
}