Commit a75d9e78 authored by Björn Fischer's avatar Björn Fischer

parallize outer loop

parent 2799f3eb
......@@ -67,16 +67,15 @@ int Jacobi_Iterate(int neighbor_dim0_left, int neighbor_dim0_right, int neighbor
double delta_a;
double **swap;
double maxdiff = 0;
double inner_maxdiff;
int i,j;
#pragma omp parallel for private(delta_a, j, i) reduction(max: maxdiff) schedule(dynamic, 1) default(shared)
for(
int i = (neighbor_dim0_left == MPI_PROC_NULL) ? 2 : 1; // catch edges
i = (neighbor_dim0_left == MPI_PROC_NULL) ? 2 : 1; // catch edges
i < pi.end_m - pi.start_m + ((neighbor_dim0_right == MPI_PROC_NULL) ? 1 : 2);
i++
) {
inner_maxdiff = 0;
#pragma omp parallel for private(delta_a) reduction(max: inner_maxdiff) schedule(dynamic, 512) default(shared) num_threads(48)
for(
int j = (neighbor_dim1_left == MPI_PROC_NULL) ? 2 : 1; // catch edges
j = (neighbor_dim1_left == MPI_PROC_NULL) ? 2 : 1; // catch edges
j < pi.end_n - pi.start_n + ((neighbor_dim1_right == MPI_PROC_NULL) ? 1 : 2);
j++
) {
......@@ -87,11 +86,9 @@ int Jacobi_Iterate(int neighbor_dim0_left, int neighbor_dim0_right, int neighbor
delta_a = delta_a * delta_t;
(*partial_field_clipboard)[i][j] = (*partial_field)[i][j] + delta_a;
if(delta_a > inner_maxdiff)
inner_maxdiff = delta_a;
if(delta_a > maxdiff)
maxdiff = delta_a;
}
if(inner_maxdiff > maxdiff)
maxdiff = inner_maxdiff;
}
swap = *partial_field_clipboard;
*partial_field_clipboard = *partial_field;
......
all: main
main: matrix.c main.c args.c pid0.c pi.c cart.c mpi_util.c
mpicc matrix.c main.c args.c pid0.c pi.c cart.c mpi_util.c jacobi.c -std=c99 -lm -o main
mpicc matrix.c main.c args.c pid0.c pi.c cart.c mpi_util.c jacobi.c -fopenmp -std=c99 -lm -o main
ViewMatrix.class: ViewMatrix.java
javac ViewMatrix.java
......@@ -9,4 +9,4 @@ ViewMatrix.class: ViewMatrix.java
clean:
rm -f *.o *.c~ heat Matrix.txt
rm -f ViewMatrix.class
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment