Initial commit
This commit is contained in:
Executable
+47
@@ -0,0 +1,47 @@
|
||||
if (!disableCheck) {
|
||||
double t = omp_get_wtime();
|
||||
omp_set_schedule(omp_sched_dynamic, chunksize);
|
||||
#pragma omp parallel
|
||||
for(int iter=0; iter<iterMax; ++iter) {
|
||||
//#pragma omp for schedule(dynamic,32)
|
||||
#pragma omp for schedule(runtime)
|
||||
for(int i=1; i<2*N-2; ++i) {
|
||||
if(i<N) {
|
||||
for(int j=1; j<=i; ++j) {
|
||||
int x = i-j+1;
|
||||
double old = mat_b[Idx2D(x, j)];
|
||||
mat_b[Idx2D(x, j)] = 0.8*old + 0.2*0.25*mat_b[Idx2D(x-1, j)]*mat_b[Idx2D(x+1, j)]*mat_b[Idx2D(x, j-1)]*mat_b[Idx2D(x, j+1)];
|
||||
}
|
||||
} else {
|
||||
for(int j=i-N+2; j<N; ++j) {
|
||||
int x = i-j+1;
|
||||
double old = mat_b[Idx2D(x, j)];
|
||||
mat_b[Idx2D(x, j)] = 0.9*old + 0.1*0.25*mat_b[Idx2D(x-1, j)]*mat_b[Idx2D(x+1, j)]*mat_b[Idx2D(x, j-1)]*mat_b[Idx2D(x, j+1)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("OMP Complete: %8.4lf\n", omp_get_wtime()-t);
|
||||
int ok = 0;
|
||||
int nok = 0;
|
||||
int nan = 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
for (int j = 0; j < N; j++) {
|
||||
if (isnan(mat_a[Idx2D(i, j)]) || isinf(mat_a[Idx2D(i, j)]) || isnan(mat_b[Idx2D(i, j)]) || isinf(mat_b[Idx2D(i, j)])) {
|
||||
nan++;
|
||||
} else if (fabs(mat_a[Idx2D(i, j)] - mat_b[Idx2D(i, j)]) < (double)0.000001) {
|
||||
ok++;
|
||||
} else {
|
||||
//printf("diff[%d,%d]: %.40lf - %.40lf = %.40lf\n", i,j,mat_a[Idx2D(i, j)], mat_b[Idx2D(i, j)], mat_a[Idx2D(i, j)] - mat_b[Idx2D(i, j)]);
|
||||
nok++;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("nan: %d, ok: %d, nok: %d\n", nan, ok, nok);
|
||||
if (nok != 0) {
|
||||
#include <sstream>
|
||||
std::stringstream ss;
|
||||
ss << "Test Failure: nok [" << nok << "] is not zero.";
|
||||
throw wfr::exception::wfr_fatal_error(ss.str());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user