Changed wall clock time calculation

This commit is contained in:
Fabio Salvini 2016-12-01 19:44:37 +01:00
parent 060ab4483e
commit ec073db31d
4 changed files with 17 additions and 15 deletions

View File

@ -40,14 +40,14 @@ mpi_line_async: config utils main_mpi
${SRC}/impl/mpi_line_async.c \
-o ${BIN}/jacobi_mpi_line_async
main: ${SRC}/main.c
main: ${SRC}/main/main.c
${CC_MPI} -c ${CFLAGS} \
${SRC}/main.c \
${SRC}/main/main.c \
-o ${BUILD}/main.o
main_mpi: ${SRC}/main_mpi.c
main_mpi: ${SRC}/main/main_mpi.c
${CC_MPI} -c ${CFLAGS} \
${SRC}/main_mpi.c \
${SRC}/main/main_mpi.c \
-o ${BUILD}/main_mpi.o
config: ${SRC}/config.c

View File

@ -36,11 +36,10 @@ double *compute_jacobi(int n, double init_value, double threshold, borders b, in
}
}
/* Iterative refinement of x until values converge */
omp_set_num_threads(2);
*iterations = 0;
do {
max_diff = 0;
#pragma omp parallel for schedule(static, 20) \
#pragma omp parallel for schedule(static) \
reduction (max:max_diff) \
default(none) private(new_value, j) firstprivate(n, nb) shared(x, new_x)
for (i = 1; i <= n; i++) {

View File

@ -1,9 +1,9 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include "config.h"
#include "utils.h"
#include <sys/time.h>
#include "../config.h"
#include "../utils.h"
double *compute_jacobi(int n, double init_value, double threshold, borders b, int *iterations);
@ -14,8 +14,9 @@ int main(int argc, char* argv[]) {
int config_loaded;
configuration config;
double *x;
clock_t starttime, endtime;
int iterations;
struct timeval start, end;
long secs_used, micros_used;
config_loaded = load_config(&config);
if (config_loaded != 0) {
@ -29,11 +30,13 @@ int main(int argc, char* argv[]) {
b.east = config.east;
b.west = config.west;
starttime = clock();
gettimeofday(&start, NULL);
x = compute_jacobi(n, init_value, threshold, b, &iterations);
endtime = clock();
gettimeofday(&end, NULL);
printf("clock time: %fs\n", (double)(endtime - starttime) / CLOCKS_PER_SEC);
secs_used = (end.tv_sec - start.tv_sec);
micros_used = ((secs_used * 1000000) + end.tv_usec) - (start.tv_usec);
printf("Wall clock time: %fs\n", (double) micros_used / 1000000);
printf("Iterations: %d\n", iterations);
if (n < 10) {
print_sa_matrix(x, n + 2, n + 2);

View File

@ -2,8 +2,8 @@
#include <string.h>
#include <math.h>
#include <mpi.h>
#include "config.h"
#include "utils.h"
#include "../config.h"
#include "../utils.h"
double *compute_jacobi(int rank, int numprocs, int n, double init_value, double threshold, borders b, int *iterations);