Skip to content
Snippets Groups Projects
Commit b66e6190 authored by David Goz's avatar David Goz :sleeping:
Browse files

small refinements serial/ omp/

parent 97eda2f1
No related branches found
No related tags found
No related merge requests found
...@@ -51,7 +51,7 @@ valgrind_callgrind: $(PROG_CALLGRIND) ...@@ -51,7 +51,7 @@ valgrind_callgrind: $(PROG_CALLGRIND)
valgrind_cachegrind: $(PROG_CACHEGRIND) valgrind_cachegrind: $(PROG_CACHEGRIND)
@echo 'oooOOO... valgrind_cachegrind ...OOOooo' @echo 'oooOOO... valgrind_cachegrind ...OOOooo'
valgrind --tool=cachegrind --log-file=valgrind_cachegrind_log_.%p.txt ./$< 128 128 2 valgrind --tool=cachegrind --cache-sim=yes --log-file=valgrind_cachegrind_log_.%p.txt ./$< 128 128 2
@echo '$$ cg_annotate --auto=yes cachegrind.out.<pid> | less' @echo '$$ cg_annotate --auto=yes cachegrind.out.<pid> | less'
@echo '(kcachegrind is required in order to visualize the output using the GUI)' @echo '(kcachegrind is required in order to visualize the output using the GUI)'
@echo 'oooOOO... valgrind_cachegrind ...OOOooo' @echo 'oooOOO... valgrind_cachegrind ...OOOooo'
......
...@@ -234,9 +234,6 @@ void JacobiAlgorithm(MyData **const restrict Phi, ...@@ -234,9 +234,6 @@ void JacobiAlgorithm(MyData **const restrict Phi,
#pragma omp barrier #pragma omp barrier
#endif /* DEBUG */ #endif /* DEBUG */
/***** MISSING LOOP(s) PARALLELIZATION *****/
for (int j=jbeg ; j<=jend ; j++) for (int j=jbeg ; j<=jend ; j++)
{ {
for (int i=ibeg ; i<=iend ; i++) for (int i=ibeg ; i<=iend ; i++)
...@@ -244,10 +241,7 @@ void JacobiAlgorithm(MyData **const restrict Phi, ...@@ -244,10 +241,7 @@ void JacobiAlgorithm(MyData **const restrict Phi,
Phi[j][i] = 0.25 * (Phi0[j][i-1] + Phi0[j][i+1] + Phi[j][i] = 0.25 * (Phi0[j][i-1] + Phi0[j][i+1] +
Phi0[j-1][i] + Phi0[j+1][i]); Phi0[j-1][i] + Phi0[j+1][i]);
#pragma omp critical
{
*error += delta[X] * delta[Y] * fabs(Phi[j][i] - Phi0[j][i]); *error += delta[X] * delta[Y] * fabs(Phi[j][i] - Phi0[j][i]);
}
} /* loop over columns */ } /* loop over columns */
} /* loop over rows */ } /* loop over rows */
} /* omp parallel */ } /* omp parallel */
......
...@@ -48,7 +48,7 @@ valgrind_callgrind: $(PROG_CALLGRIND) ...@@ -48,7 +48,7 @@ valgrind_callgrind: $(PROG_CALLGRIND)
valgrind_cachegrind: $(PROG_CACHEGRIND) valgrind_cachegrind: $(PROG_CACHEGRIND)
@echo 'oooOOO... valgrind_cachegrind ...OOOooo' @echo 'oooOOO... valgrind_cachegrind ...OOOooo'
valgrind --tool=cachegrind --log-file=valgrind_cachegrind_log_.%p.txt ./$< 128 128 valgrind --tool=cachegrind --cache-sim=yes --log-file=valgrind_cachegrind_log_.%p.txt ./$< 128 128
@echo '$$ cg_annotate --auto=yes cachegrind.out.<pid> | less' @echo '$$ cg_annotate --auto=yes cachegrind.out.<pid> | less'
@echo '(kcachegrind is required in order to visualize the output using the GUI)' @echo '(kcachegrind is required in order to visualize the output using the GUI)'
@echo 'oooOOO... valgrind_cachegrind ...OOOooo' @echo 'oooOOO... valgrind_cachegrind ...OOOooo'
......
...@@ -48,7 +48,7 @@ valgrind_callgrind: $(PROG_CALLGRIND) ...@@ -48,7 +48,7 @@ valgrind_callgrind: $(PROG_CALLGRIND)
valgrind_cachegrind: $(PROG_CACHEGRIND) valgrind_cachegrind: $(PROG_CACHEGRIND)
@echo 'oooOOO... valgrind_cachegrind ...OOOooo' @echo 'oooOOO... valgrind_cachegrind ...OOOooo'
valgrind --tool=cachegrind --log-file=valgrind_cachegrind_log_.%p.txt ./$< 128 128 valgrind --tool=cachegrind --cache-sim=yes --log-file=valgrind_cachegrind_log_.%p.txt ./$< 128 128
@echo '$$ cg_annotate --auto=yes cachegrind.out.<pid> | less' @echo '$$ cg_annotate --auto=yes cachegrind.out.<pid> | less'
@echo '(kcachegrind is required in order to visualize the output using the GUI)' @echo '(kcachegrind is required in order to visualize the output using the GUI)'
@echo 'oooOOO... valgrind_cachegrind ...OOOooo' @echo 'oooOOO... valgrind_cachegrind ...OOOooo'
......
...@@ -214,10 +214,13 @@ void JacobiAlgorithm(MyData **const restrict Phi, ...@@ -214,10 +214,13 @@ void JacobiAlgorithm(MyData **const restrict Phi,
{ {
for (int i=ibeg ; i<=iend ; i++) for (int i=ibeg ; i<=iend ; i++)
{ {
Phi[j][i] = 0.25 * (Phi0[j][i-1] + Phi0[j][i+1] + Phi[j][i] = 0.25 * (Phi0[j][i-1] +
Phi0[j-1][i] + Phi0[j+1][i]); Phi0[j][i+1] +
Phi0[j-1][i] +
Phi0[j+1][i]);
*error += delta[X] * delta[Y] * fabs(Phi[j][i] - Phi0[j][i]); *error += (delta[X] * delta[Y]) *
fabs(Phi[j][i] - Phi0[j][i]);
} /* loop over columns */ } /* loop over columns */
} /* loop over rows */ } /* loop over rows */
......
...@@ -51,9 +51,8 @@ void Show_2DdblArray(const MyData **const A, ...@@ -51,9 +51,8 @@ void Show_2DdblArray(const MyData **const A,
double seconds() double seconds()
{ {
struct timeval tmp; struct timespec ts;
gettimeofday(&tmp, (struct timezone *)0); return (clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &ts ),
double sec = tmp.tv_sec + ((double)tmp.tv_usec)/1000000.0; (double)ts.tv_sec +
(double)ts.tv_nsec * 1e-9);
return sec;
} }
...@@ -48,7 +48,7 @@ valgrind_callgrind: $(PROG_CALLGRIND) ...@@ -48,7 +48,7 @@ valgrind_callgrind: $(PROG_CALLGRIND)
valgrind_cachegrind: $(PROG_CACHEGRIND) valgrind_cachegrind: $(PROG_CACHEGRIND)
@echo 'oooOOO... valgrind_cachegrind ...OOOooo' @echo 'oooOOO... valgrind_cachegrind ...OOOooo'
valgrind --tool=cachegrind --log-file=valgrind_cachegrind_log_.%p.txt ./$< 128 128 valgrind --tool=cachegrind --cache-sim=yes --log-file=valgrind_cachegrind_log_.%p.txt ./$< 128 128
@echo '$$ cg_annotate --auto=yes cachegrind.out.<pid> | less' @echo '$$ cg_annotate --auto=yes cachegrind.out.<pid> | less'
@echo '(kcachegrind is required in order to visualize the output using the GUI)' @echo '(kcachegrind is required in order to visualize the output using the GUI)'
@echo 'oooOOO... valgrind_cachegrind ...OOOooo' @echo 'oooOOO... valgrind_cachegrind ...OOOooo'
......
...@@ -212,13 +212,19 @@ void JacobiAlgorithm(MyData **const restrict Phi, ...@@ -212,13 +212,19 @@ void JacobiAlgorithm(MyData **const restrict Phi,
{ {
for (int i=ibeg ; i<=iend ; i++) for (int i=ibeg ; i<=iend ; i++)
{ {
Phi[j][i] = 0.25 * (Phi0[j][i-1] + Phi0[j][i+1] + Phi[j][i] = 0.25 * (Phi0[j ][i-1] +
Phi0[j-1][i] + Phi0[j+1][i]); Phi0[j ][i+1] +
Phi0[j-1][i ] +
*error += delta[X] * delta[Y] * fabs(Phi[j][i] - Phi0[j][i]); Phi0[j+1][i ]);
/* avoid fabs from math library */
const MyData diff = (Phi[j][i] - Phi0[j][i]);
*error += ((diff > 0) ? diff : -diff);
} /* loop over columns */ } /* loop over columns */
} /* loop over rows */ } /* loop over rows */
*error *= (delta[X] * delta[Y]);
return; return;
} }
......
...@@ -51,9 +51,8 @@ void Show_2DdblArray(const MyData **const A, ...@@ -51,9 +51,8 @@ void Show_2DdblArray(const MyData **const A,
double seconds() double seconds()
{ {
struct timeval tmp; struct timespec ts;
gettimeofday(&tmp, (struct timezone *)0); return (clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &ts ),
double sec = tmp.tv_sec + ((double)tmp.tv_usec)/1000000.0; (double)ts.tv_sec +
(double)ts.tv_nsec * 1e-9);
return sec;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment