Commit 10232945 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Replace reduction(+ : findex) by #pragma omp atomic (bug fix).

parent f9bfb530
......@@ -458,12 +458,15 @@ setmisstodis(field_type *field1, field_type *field2, int numNeighbors)
double findex = 0;
#ifdef HAVE_OPENMP4
#pragma omp parallel for default(none) reduction(+ : findex) shared(knnWeights) shared(mindex, vindex, array1, array2, xvals, \
yvals, gs, nmiss, numNeighbors)
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(knnWeights, findex, mindex, vindex, array1, array2, xvals, \
yvals, gs, nmiss, numNeighbors)
#endif
for (size_t i = 0; i < nmiss; ++i)
{
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (cdo_omp_get_thread_num() == 0) progressStatus(0, 1, findex / nmiss);
......@@ -482,6 +485,8 @@ setmisstodis(field_type *field1, field_type *field2, int numNeighbors)
}
}
progressStatus(0, 1, 1);
finish = clock();
if (cdoVerbose) cdoPrint("Point search nearest: %.2f seconds", ((double) (finish - start)) / CLOCKS_PER_SEC);
......
......@@ -102,13 +102,16 @@ smooth(int gridID, double missval, const double *restrict array1, double *restri
double findex = 0;
#ifdef HAVE_OPENMP4
#pragma omp parallel for schedule(dynamic) default(none) reduction(+ : findex) reduction(+ : nmissx) shared( \
#pragma omp parallel for schedule(dynamic) default(none) reduction(+ : nmissx) shared(findex, \
cdoVerbose, knnWeights, spoint, mask, array1, array2, xvals, yvals, gs, gridsize, missval)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
int ompthID = cdo_omp_get_thread_num();
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (cdoVerbose && cdo_omp_get_thread_num() == 0) progressStatus(0, 1, findex / gridsize);
......@@ -129,6 +132,8 @@ smooth(int gridID, double missval, const double *restrict array1, double *restri
*nmiss = nmissx;
progressStatus(0, 1, 1);
finish = clock();
if (cdoVerbose) cdoPrint("Point search nearest: %.2f seconds", ((double) (finish - start)) / CLOCKS_PER_SEC);
......
......@@ -408,20 +408,22 @@ gridGenArea(int gridID, double *area)
progressInit();
#ifdef HAVE_OPENMP4
#pragma omp parallel for default(none) reduction(+ : findex) shared(gridsize, area, nv, grid_corner_lon, grid_corner_lat, \
grid_center_lon, grid_center_lat)
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(findex, gridsize, area, nv, grid_corner_lon, grid_corner_lat, \
grid_center_lon, grid_center_lat)
#endif
for (size_t i = 0; i < gridsize; ++i)
{
int lprogress = 1;
if (cdo_omp_get_thread_num() != 0) lprogress = 0;
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (lprogress) progressStatus(0, 1, findex / gridsize);
// area[i] = mod_cell_area(nv, grid_corner_lon+i*nv,
// grid_corner_lat+i*nv);
// area[i] = mod_cell_area(nv, grid_corner_lon+i*nv, grid_corner_lat+i*nv);
if (nv <= 4)
area[i] = mod_huiliers_area(nv, grid_corner_lon + i * nv, grid_corner_lat + i * nv);
else
......@@ -429,6 +431,8 @@ gridGenArea(int gridID, double *area)
grid_center_lat[i]);
}
progressStatus(0, 1, 1);
if (cdoVerbose)
{
double total_area = 0;
......
......@@ -229,9 +229,9 @@ intlinarr2(double missval, int lon_is_circular, size_t nxm, size_t nym, const do
progressInit();
#ifdef HAVE_OPENMP4
#pragma omp parallel for default(none) reduction(+ : findex) shared( \
Threading::ompNumThreads, field, fieldm, x, y, xm, ym, nxm, nym, gridsize2, missval, nlon1, lon_is_circular, grid1_mask)
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(findex, \
field, fieldm, x, y, xm, ym, nxm, nym, gridsize2, missval, nlon1, lon_is_circular, grid1_mask)
#endif
for (size_t i = 0; i < gridsize2; ++i)
{
......@@ -241,6 +241,9 @@ intlinarr2(double missval, int lon_is_circular, size_t nxm, size_t nym, const do
field[i] = missval;
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (lprogress) progressStatus(0, 1, findex / gridsize2);
......@@ -277,7 +280,7 @@ intlinarr2(double missval, int lon_is_circular, size_t nxm, size_t nym, const do
}
}
if (findex < gridsize2) progressStatus(0, 1, 1);
progressStatus(0, 1, 1);
if (grid1_mask) Free(grid1_mask);
}
......
......@@ -118,11 +118,14 @@ remapBicubicWeights(RemapSearch &rsearch, RemapVars &rv)
// Loop over destination grid
#ifdef HAVE_OPENMP4
#pragma omp parallel for default(none) reduction(+ : findex) shared(rsearch, weightLinks, tgt_grid_size, src_grid, tgt_grid, rv)
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(findex, rsearch, weightLinks, tgt_grid_size, src_grid, tgt_grid, rv)
#endif
for (size_t tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add)
{
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (cdo_omp_get_thread_num() == 0) progressStatus(0, 1, findex / tgt_grid_size);
......@@ -182,6 +185,8 @@ remapBicubicWeights(RemapSearch &rsearch, RemapVars &rv)
}
}
progressStatus(0, 1, 1);
weightLinks4ToRemapLinks(tgt_grid_size, weightLinks, rv);
if (cdoTimer) timer_stop(timer_remap_bic);
......@@ -221,12 +226,15 @@ remapBicubic(RemapSearch &rsearch, const double *restrict src_array, double *res
// Loop over destination grid
#ifdef HAVE_OPENMP4
#pragma omp parallel for default(none) reduction(+ : findex) shared(rsearch, tgt_grid_size, src_grid, tgt_grid, src_array, \
tgt_array, missval, gradients)
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(findex, rsearch, tgt_grid_size, src_grid, tgt_grid, src_array, \
tgt_array, missval, gradients)
#endif
for (size_t tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add)
{
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (cdo_omp_get_thread_num() == 0) progressStatus(0, 1, findex / tgt_grid_size);
......@@ -288,5 +296,7 @@ remapBicubic(RemapSearch &rsearch, const double *restrict src_array, double *res
}
}
progressStatus(0, 1, 1);
if (cdoTimer) timer_stop(timer_remap_bic);
} // remapBicubic
......@@ -181,12 +181,14 @@ remapBilinearWeights(RemapSearch &rsearch, RemapVars &rv)
// Loop over destination grid
#ifdef HAVE_OPENMP4
#pragma omp parallel for default(none) schedule(static) reduction(+ : findex) shared(rsearch, weightLinks, tgt_grid_size, \
src_grid, tgt_grid, rv)
#ifdef _OPENMP
#pragma omp parallel for default(none) schedule(static) shared(findex, rsearch, weightLinks, tgt_grid_size, src_grid, tgt_grid, rv)
#endif
for (size_t tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add)
{
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (cdo_omp_get_thread_num() == 0) progressStatus(0, 1, findex / tgt_grid_size);
......@@ -246,6 +248,8 @@ remapBilinearWeights(RemapSearch &rsearch, RemapVars &rv)
}
}
progressStatus(0, 1, 1);
weightLinksToRemapLinks(0, tgt_grid_size, weightLinks, rv);
if (cdoTimer) timer_stop(timer_remap_bil);
......@@ -282,12 +286,15 @@ remapBilinear(RemapSearch &rsearch, const double *restrict src_array, double *re
// Loop over destination grid
#ifdef HAVE_OPENMP4
#pragma omp parallel for default(none) schedule(static) reduction(+ : findex) shared( \
rsearch, Options::silentMode, tgt_grid_size, src_grid, tgt_grid, src_array, tgt_array, missval)
#ifdef _OPENMP
#pragma omp parallel for default(none) schedule(static) shared(findex, \
rsearch, tgt_grid_size, src_grid, tgt_grid, src_array, tgt_array, missval)
#endif
for (size_t tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add)
{
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (cdo_omp_get_thread_num() == 0) progressStatus(0, 1, findex / tgt_grid_size);
......@@ -349,5 +356,7 @@ remapBilinear(RemapSearch &rsearch, const double *restrict src_array, double *re
}
}
progressStatus(0, 1, 1);
if (cdoTimer) timer_stop(timer_remap_bil);
} // remapBilinear
......@@ -777,9 +777,9 @@ remapConservWeights(RemapSearch &rsearch, RemapVars &rv)
// Loop over destination grid
#ifdef HAVE_OPENMP4
#pragma omp parallel for schedule(dynamic) default(none) reduction(+ : findex) shared( \
rsearch, Threading::ompNumThreads, src_remap_grid_type, tgt_remap_grid_type, src_grid_bound_box, rv, cdoVerbose, \
#ifdef _OPENMP
#pragma omp parallel for schedule(dynamic) default(none) shared(findex, \
rsearch, src_remap_grid_type, tgt_remap_grid_type, src_grid_bound_box, rv, cdoVerbose, \
tgt_num_cell_corners, target_cell_type, weightLinks, srch_corners, src_grid, tgt_grid, tgt_grid_size, src_grid_size, \
search, srch_add, tgt_grid_cell, num_srch_cells_stat)
#endif
......@@ -791,6 +791,9 @@ remapConservWeights(RemapSearch &rsearch, RemapVars &rv)
size_t n, num_weights, num_weights_old;
int ompthID = cdo_omp_get_thread_num();
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (ompthID == 0) progressStatus(0, 1, findex / tgt_grid_size);
......@@ -967,6 +970,8 @@ remapConservWeights(RemapSearch &rsearch, RemapVars &rv)
// tgt_grid->cell_area[tgt_cell_add], tgt_area);
}
progressStatus(0, 1, 1);
#ifdef STIMER
printf("stime = %gs\n", stimer);
#endif
......
......@@ -1293,16 +1293,19 @@ remapConservWeightsScrip(RemapSearch &rsearch, RemapVars &rv)
if (cdoTimer) timer_start(timer_remap_con_l1);
#ifdef HAVE_OPENMP4
#pragma omp parallel for default(none) \
reduction(+ : findex) shared(rsearch, num_wts, src_centroid_lon, src_centroid_lat, grid_store, rv, cdoVerbose, max_subseg, \
srch_corner_lat, srch_corner_lon, max_srch_cells, src_num_cell_corners, srch_corners, \
src_grid, tgt_grid, tgt_grid_size, src_grid_size, srch_add)
#ifdef _OPENMP
#pragma omp parallel for default(none) \
shared(findex, rsearch, num_wts, src_centroid_lon, src_centroid_lat, grid_store, rv, cdoVerbose, max_subseg, \
srch_corner_lat, srch_corner_lon, max_srch_cells, src_num_cell_corners, srch_corners, \
src_grid, tgt_grid, tgt_grid_size, src_grid_size, srch_add)
#endif
for (long src_cell_add = 0; src_cell_add < src_grid_size; ++src_cell_add)
{
int ompthID = cdo_omp_get_thread_num();
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (ompthID == 0) progressStatus(0, 0.5, findex / src_grid_size);
......@@ -1494,16 +1497,19 @@ remapConservWeightsScrip(RemapSearch &rsearch, RemapVars &rv)
findex = 0;
#ifdef HAVE_OPENMP4
#pragma omp parallel for default(none) \
reduction(+ : findex) shared(rsearch, num_wts, tgt_centroid_lon, tgt_centroid_lat, grid_store, rv, cdoVerbose, max_subseg, \
srch_corner_lat, srch_corner_lon, max_srch_cells, tgt_num_cell_corners, srch_corners, \
src_grid, tgt_grid, tgt_grid_size, src_grid_size, srch_add)
#ifdef _OPENMP
#pragma omp parallel for default(none) \
shared(findex, rsearch, num_wts, tgt_centroid_lon, tgt_centroid_lat, grid_store, rv, cdoVerbose, max_subseg, \
srch_corner_lat, srch_corner_lon, max_srch_cells, tgt_num_cell_corners, srch_corners, \
src_grid, tgt_grid, tgt_grid_size, src_grid_size, srch_add)
#endif
for (long tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add)
{
int ompthID = cdo_omp_get_thread_num();
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (ompthID == 0) progressStatus(0.5, 0.5, findex / tgt_grid_size);
......@@ -1667,6 +1673,8 @@ remapConservWeightsScrip(RemapSearch &rsearch, RemapVars &rv)
}
}
progressStatus(0, 1, 1);
if (cdoTimer) timer_stop(timer_remap_con_l2);
/* Finished with all cells: deallocate search arrays */
......
......@@ -54,14 +54,17 @@ remapDistwgtWeights(size_t numNeighbors, RemapSearch &rsearch, RemapVars &rv)
double findex = 0;
#ifdef HAVE_OPENMP4
#pragma omp parallel for default(none) reduction(+ : findex) shared(rsearch, weightLinks, numNeighbors, src_grid, tgt_grid, \
tgt_grid_size, knnWeights)
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(findex, rsearch, weightLinks, numNeighbors, src_grid, tgt_grid, \
tgt_grid_size, knnWeights)
#endif
for (size_t tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add)
{
int ompthID = cdo_omp_get_thread_num();
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (ompthID == 0) progressStatus(0, 1, findex / tgt_grid_size);
......@@ -123,14 +126,17 @@ remapDistwgt(size_t numNeighbors, RemapSearch &rsearch, const double *restrict s
double findex = 0;
#ifdef HAVE_OPENMP4
#pragma omp parallel for default(none) reduction(+ : findex) shared(rsearch, numNeighbors, src_grid, tgt_grid, tgt_grid_size, \
src_array, tgt_array, missval, knnWeights)
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(findex, rsearch, numNeighbors, src_grid, tgt_grid, tgt_grid_size, \
src_array, tgt_array, missval, knnWeights)
#endif
for (size_t tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add)
{
int ompthID = cdo_omp_get_thread_num();
#ifdef _OPENMP
#pragma omp atomic
#endif
findex++;
if (ompthID == 0) progressStatus(0, 1, findex / tgt_grid_size);
......
Supports Markdown
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