Commit 790645a6 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

calc_bin_addr: added openmp support.

parent 7a2c0dab
......@@ -33,43 +33,48 @@ case "${HOSTNAME}" in
bailung*|d133*|d134*)
CDOLIBS="--enable-nearpt3 \
--with-fftw3 \
--with-grib_api=$HOME/local/grib_api-1.14.7aec \
--with-netcdf=$HOME/local/netcdf-c-4.3.3.1-threadsafe \
--with-hdf5=$HOME/local/hdf5-1.8.15-threadsafe \
--with-eccodes=$HOME/local/eccodes-2.3.0 \
--with-netcdf=$HOME/local/netcdf-4.4.1.1 \
--with-hdf5=$HOME/local/hdf5-1.8.19-threadsafe \
--with-udunits2=/opt/local \
--with-curl=/opt/local \
--with-libxml2=/usr \
--with-magics=$HOME/local/Magics-2.25.3 \
--with-proj=/opt/local \
--with-szlib=$HOME/local/libaec-0.3.2"
--with-szlib=$HOME/local"
# --with-magics=$HOME/local/Magics-2.25.3 \
if test "$COMP" = intel ; then
${CONFPATH}configure \
$CDOLIBS \
LDFLAGS="-Wl,-rpath,$HOME/local/eccodes-2.3.0/lib -Wl,-rpath,/opt/intel/lib" \
CXX=icpc CXXFLAGS="-g -Wall -O2 -qopt-report=5 -march=native" \
CC=icc CFLAGS="-g -Wall -O2 -qopt-report=5 -march=native"
elif test "$COMP" = clang ; then
${CONFPATH}configure --prefix=$HOME/local \
--enable-maintainer-mode \
$CDOLIBS \
LDFLAGS="-Wl,-rpath,$HOME/local/eccodes-2.3.0/lib" \
CXX=clang++ CXXFLAGS="-g -Wall -O3" \
CC=clang CFLAGS="-g -Wall -O3"
elif test "$COMP" = gnu4.9 ; then
${CONFPATH}configure --prefix=$HOME/local \
--enable-maintainer-mode \
$CDOLIBS \
LDFLAGS="-Wl,-rpath,$HOME/local/eccodes-2.3.0/lib" \
CXX=g++-mp-4.9 CXXFLAGS="-g -Wall -W -Wfloat-equal -pedantic -O3 -march=native" \
CC=gcc-mp-4.9 CFLAGS="-g -Wall -W -Wfloat-equal -pedantic -O3 -march=native"
elif test "$COMP" = gnu5 ; then
${CONFPATH}configure --prefix=$HOME/local \
--enable-maintainer-mode \
$CDOLIBS \
LDFLAGS="-Wl,-rpath,$HOME/local/eccodes-2.3.0/lib" \
CXX=g++-mp-5 CXXFLAGS="-g -Wall -W -Wfloat-equal -pedantic -O3 -march=native" \
CC=gcc-mp-5 CFLAGS="-g -Wall -W -Wfloat-equal -pedantic -O3 -march=native"
elif test "$COMP" = gnu ; then
${CONFPATH}configure --prefix=$HOME/local \
--enable-maintainer-mode \
$CDOLIBS \
LDFLAGS="-Wl,-rpath,$HOME/local/eccodes-2.3.0/lib" \
CXX=g++ CXXFLAGS="-g -Wall -W -Wfloat-equal -pedantic -O3 -march=native" \
CC=gcc CFLAGS="-g -Wall -W -Wfloat-equal -pedantic -O3 -march=native"
# --with-libxml2=/usr
......
......@@ -214,7 +214,6 @@ void write_remap_scrip(const char *interp_file, int map_type, int submap_type, i
void read_remap_scrip(const char *interp_file, int gridID1, int gridID2, int *map_type, int *submap_type, int *num_neighbors,
int *remap_order, remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
void calc_bin_addr(long gridsize, long nbins, const restr_t* restrict bin_lats, const restr_t* restrict cell_bound_box, int* restrict bin_addr);
void calc_lat_bins(remapgrid_t* src_grid, remapgrid_t* tgt_grid, int map_type);
long get_srch_cells(long tgt_cell_add, long nbins, int *bin_addr1, int *bin_addr2,
restr_t *tgt_cell_bound_box, restr_t *src_cell_bound_box, long src_grid_size, int *srch_add);
......
#include "cdo_int.h"
#include "grid.h"
#include "remap.h"
/*
#if defined(_OPENMP)
# include <omp.h>
#endif
*/
void calc_bin_addr(long gridsize, long nbins, const restr_t* restrict bin_lats, const restr_t* restrict cell_bound_box, int* restrict bin_addr)
{
long n, n2, nele, nele4;
restr_t cell_bound_box_lat1, cell_bound_box_lat2;
for ( n = 0; n < nbins; ++n )
{
n2 = n<<1;
bin_addr[n2 ] = gridsize;
bin_addr[n2+1] = 0;
}
for ( nele = 0; nele < gridsize; ++nele )
{
nele4 = nele<<2;
cell_bound_box_lat1 = cell_bound_box[nele4 ];
cell_bound_box_lat2 = cell_bound_box[nele4+1];
for ( n = 0; n < nbins; ++n )
{
n2 = n<<1;
if ( cell_bound_box_lat1 <= bin_lats[n2+1] &&
cell_bound_box_lat2 >= bin_lats[n2 ] )
{
bin_addr[n2 ] = MIN(nele, bin_addr[n2 ]);
bin_addr[n2+1] = MAX(nele, bin_addr[n2+1]);
}
}
}
}
/*
void calc_bin_addr_omp(long gridsize, long nbins, const restr_t* restrict bin_lats, const restr_t* restrict cell_bound_box, int* restrict bin_addr)
static
void calc_bin_addr(long gridsize, long nbins, const restr_t* restrict bin_lats, const restr_t* restrict cell_bound_box, int* restrict bin_addr)
{
long n, n2, nele, nele4;
restr_t cell_bound_box_lat1, cell_bound_box_lat2;
#if defined(_OPENMP)
extern int ompNumThreads;
restr_t (*omp_bin_addr)[ompNumThreads] = Malloc(nbins*sizeof(*omp_bin_addr));
for ( int ompthID = 0; ompthID < ompNumThreads; ++ompthID )
for ( n = 0; n < nbins; ++n )
{
n2 = n<<1;
omp_bin_addr[ompthID][n2 ] = gridsize;
omp_bin_addr[ompthID][n2+1] = 0;
}
#endif
long n2;
for ( n = 0; n < nbins; ++n )
for ( long n = 0; n < nbins; ++n )
{
n2 = n<<1;
bin_addr[n2 ] = gridsize;
......@@ -64,48 +17,31 @@ void calc_bin_addr_omp(long gridsize, long nbins, const restr_t* restrict bin_la
#if defined(_OPENMP)
#pragma omp parallel for default(none) \
private(n, n2, nele4, cell_bound_box_lat1, cell_bound_box_lat2) \
shared(gridsize, nbins, bin_lats, cell_bound_box, omp_bin_addr)
private(n2) shared(gridsize, nbins, bin_lats, bin_addr, cell_bound_box)
#endif
for ( nele = 0; nele < gridsize; ++nele )
for ( long nele = 0; nele < gridsize; ++nele )
{
#if defined(_OPENMP)
int ompthID = omp_get_thread_num();
#endif
nele4 = nele<<2;
cell_bound_box_lat1 = cell_bound_box[nele4 ];
cell_bound_box_lat2 = cell_bound_box[nele4+1];
for ( n = 0; n < nbins; ++n )
long nele4 = nele<<2;
restr_t cell_bound_box_lat1 = cell_bound_box[nele4 ];
restr_t cell_bound_box_lat2 = cell_bound_box[nele4+1];
for ( long n = 0; n < nbins; ++n )
{
n2 = n<<1;
if ( cell_bound_box_lat1 <= bin_lats[n2+1] &&
cell_bound_box_lat2 >= bin_lats[n2 ] )
{
#if defined(_OPENMP)
omp_bin_addr[ompthID][n2 ] = MIN(nele, omp_bin_addr[ompthID][n2 ]);
omp_bin_addr[ompthID][n2+1] = MAX(nele, omp_bin_addr[ompthID][n2+1]);
#else
bin_addr[n2 ] = MIN(nele, bin_addr[n2 ]);
bin_addr[n2+1] = MAX(nele, bin_addr[n2+1]);
#pragma omp critical
#endif
}
{
bin_addr[n2 ] = MIN(nele, bin_addr[n2 ]);
bin_addr[n2+1] = MAX(nele, bin_addr[n2+1]);
}
}
}
}
#if defined(_OPENMP)
for ( int ompthID = 0; ompthID < ompNumThreads; ++ompthID )
{
for ( n = 0; n < nbins; ++n )
{
n2 = n<<1;
bin_addr[n2 ] = MIN(omp_bin_addr[ompthID][n2 ], bin_addr[n2 ]);
bin_addr[n2+1] = MAX(omp_bin_addr[ompthID][n2+1], bin_addr[n2+1]);
}
}
Free(omp_bin_addr);
#endif
}
*/
void calc_lat_bins(remapgrid_t* src_grid, remapgrid_t* tgt_grid, int map_type)
{
......
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