From 883cd5fc83a82725ff21ffce9ac17a21c2b9d012 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sun, 10 Aug 2008 19:29:40 -0500 Subject: CarpetInterp2: Parallelise with OpenMP --- Carpet/CarpetInterp2/src/fasterp.cc | 48 ++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'Carpet/CarpetInterp2/src/fasterp.cc') diff --git a/Carpet/CarpetInterp2/src/fasterp.cc b/Carpet/CarpetInterp2/src/fasterp.cc index 66c9e9fd1..4b951b081 100644 --- a/Carpet/CarpetInterp2/src/fasterp.cc +++ b/Carpet/CarpetInterp2/src/fasterp.cc @@ -39,18 +39,22 @@ namespace CarpetInterp2 { template<> int get_poison () { return ipoison; } template<> CCTK_REAL get_poison () { return poison; } - // template - // void fill (vector & v, T const & val) - // { - // fill (v.begin(), v.end(), val); - // } + template + void fill (vector & v, T const & val) + { + // fill (v.begin(), v.end(), val); +#pragma omp parallel for + for (int n=0; n void fill_with_poison (vector & v) { #ifndef NDEBUG - // fill (v, get_poison()); - fill (v.begin(), v.end(), get_poison()); + fill (v, get_poison()); + // fill (v.begin(), v.end(), get_poison()); #endif } @@ -585,14 +589,19 @@ namespace CarpetInterp2 { int const recv_npoints = index.AT(pp) - recv_descr.procs.AT(pp).offset; ASSERT (recv_npoints == recv_descr.procs.AT(pp).npoints); } - vector received (npoints, false); +#ifndef NDEBUG + vector received (npoints); + fill (received, false); +#pragma omp parallel for for (int n=0; n recv_npoints (nprocs, 0), recv_offsets (nprocs); + vector recv_npoints (nprocs), recv_offsets (nprocs); + fill (recv_npoints, 0); fill_with_poison (recv_offsets); { int offset = 0; @@ -629,6 +639,7 @@ namespace CarpetInterp2 { // Scatter the location information into a send-array, and // exchange it with MPI vector scattered_ilocs(npoints); +#pragma omp parallel for for (int n=0; n npoints_comp (maxmrc, 0); + vector npoints_comp (maxmrc); + fill (npoints_comp, 0); + // TODO: parallelise with OpenMP for (int n=0; n::iterator const destit2 = destit + n * nvars; + ASSERT (destit2 + nvars <= endit); send_comp.locs.AT(n).interpolate - (send_comp.lsh, order, varptrs, & * destit); - destit += nvars; + (send_comp.lsh, order, varptrs, & * destit2); } + destit += nvars * send_comp.locs.size(); } // for comps @@ -853,6 +870,7 @@ namespace CarpetInterp2 { // Gather send points vector gathered_send_points (send_proc.npoints * nvars); fill_with_poison (gathered_send_points); +#pragma omp parallel for for (int n=0; n