diff options
-rw-r--r-- | Carpet/CarpetLib/configuration.ccl | 2 | ||||
-rw-r--r-- | Carpet/CarpetLib/interface.ccl | 2 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/copy_3d.cc | 1 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/data.cc | 98 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/interpolate_3d_2tl.cc | 24 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/interpolate_3d_3tl.cc | 26 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/interpolate_3d_4tl.cc | 28 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/interpolate_3d_5tl.cc | 30 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/interpolate_eno_3d_3tl.cc | 50 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/restrict_3d_cc_rf2.cc | 1 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/restrict_3d_rf2.cc | 1 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/restrict_4d_rf2.cc | 1 |
12 files changed, 135 insertions, 129 deletions
diff --git a/Carpet/CarpetLib/configuration.ccl b/Carpet/CarpetLib/configuration.ccl index 8d806fdf5..3ad1b93bf 100644 --- a/Carpet/CarpetLib/configuration.ccl +++ b/Carpet/CarpetLib/configuration.ccl @@ -5,3 +5,5 @@ PROVIDES CarpetLib SCRIPT LANG } + +REQUIRES LoopControl diff --git a/Carpet/CarpetLib/interface.ccl b/Carpet/CarpetLib/interface.ccl index c88cf032d..82d9e83f5 100644 --- a/Carpet/CarpetLib/interface.ccl +++ b/Carpet/CarpetLib/interface.ccl @@ -2,6 +2,8 @@ IMPLEMENTS: CarpetLib +uses include header: loopcontrol.h + includes header: mpi_string.hh in mpi_string.hh includes header: defs.hh in defs.hh diff --git a/Carpet/CarpetLib/src/copy_3d.cc b/Carpet/CarpetLib/src/copy_3d.cc index 06adb0276..4c0319658 100644 --- a/Carpet/CarpetLib/src/copy_3d.cc +++ b/Carpet/CarpetLib/src/copy_3d.cc @@ -102,7 +102,6 @@ namespace CarpetLib { // Loop over region -#pragma omp parallel for for (int k=0; k<regkext; ++k) { for (int j=0; j<regjext; ++j) { for (int i=0; i<regiext; ++i) { diff --git a/Carpet/CarpetLib/src/data.cc b/Carpet/CarpetLib/src/data.cc index 9482ad518..61d809506 100644 --- a/Carpet/CarpetLib/src/data.cc +++ b/Carpet/CarpetLib/src/data.cc @@ -64,8 +64,9 @@ call_operator (void int const num_threads = omp_get_num_threads(); int const thread_num = omp_get_thread_num(); // Parallelise in z direction - // TODO: parallelise along longest extent - int const dir = 2; + // int const dir = 2; + // Parallelise along longest extent + int const dir = maxloc (regbbox.shape()); int const stride = regbbox.stride()[dir]; int const first_point = regbbox.lower()[dir]; int const last_point = regbbox.upper()[dir] + stride; @@ -407,21 +408,23 @@ copy_from_innerloop (gdata const * const gsrc, assert (dist::rank() == proc()); #if CARPET_DIM == 3 - copy_3d (static_cast <T const *> (src->storage()), - src->shape(), - static_cast <T *> (this->storage()), - this->shape(), - src->extent(), - this->extent(), - box); + call_operator<T> (& copy_3d, + static_cast <T const *> (src->storage()), + src->shape(), + static_cast <T *> (this->storage()), + this->shape(), + src->extent(), + this->extent(), + box); #elif CARPET_DIM == 4 - copy_4d (static_cast <T const *> (src->storage()), - src->shape(), - static_cast <T *> (this->storage()), - this->shape(), - src->extent(), - this->extent(), - box); + call_operator<T> (& copy_4d, + static_cast <T const *> (src->storage()), + src->shape(), + static_cast <T *> (this->storage()), + this->shape(), + src->extent(), + this->extent(), + box); #else # error "Value for CARPET_DIM not supported" #endif @@ -600,27 +603,27 @@ transfer_p_vc_cc (data const * const src, newdst->allocate (newdstbox, this->proc()); // Convert source to primitive representation - prolongate_3d_cc_rf2_std2prim - (static_cast <T const *> (src->storage()), - src->shape(), - static_cast <T *> (newsrc->storage()), - newsrc->shape(), - src->extent(), - newsrc->extent(), - newsrc->extent()); + call_operator<T> (& prolongate_3d_cc_rf2_std2prim, + static_cast <T const *> (src->storage()), + src->shape(), + static_cast <T *> (newsrc->storage()), + newsrc->shape(), + src->extent(), + newsrc->extent(), + newsrc->extent()); // Interpolate newdst->transfer_prolongate (newsrc, newdstbox, order_space); // Convert destination to standard representation - prolongate_3d_cc_rf2_prim2std - (static_cast <T const *> (newdst->storage()), - newdst->shape(), - static_cast <T *> (this->storage()), - this->shape(), - newdst->extent(), - this->extent(), - box); + call_operator<T> (& prolongate_3d_cc_rf2_prim2std, + static_cast <T const *> (newdst->storage()), + newdst->shape(), + static_cast <T *> (this->storage()), + this->shape(), + newdst->extent(), + this->extent(), + box); delete newsrc; delete newdst; @@ -958,25 +961,28 @@ transfer_restrict (data const * const src, case op_ENO: case op_WENO: case op_Lagrange_monotone: + case op_restrict: // enum centering { vertex_centered, cell_centered }; switch (cent) { case vertex_centered: - restrict_3d_rf2 (static_cast <T const *> (src->storage()), - src->shape(), - static_cast <T *> (this->storage()), - this->shape(), - src->extent(), - this->extent(), - box); + call_operator<T> (& restrict_3d_rf2, + static_cast <T const *> (src->storage()), + src->shape(), + static_cast <T *> (this->storage()), + this->shape(), + src->extent(), + this->extent(), + box); break; case cell_centered: - restrict_3d_cc_rf2 (static_cast <T const *> (src->storage()), - src->shape(), - static_cast <T *> (this->storage()), - this->shape(), - src->extent(), - this->extent(), - box); + call_operator<T> (& restrict_3d_cc_rf2, + static_cast <T const *> (src->storage()), + src->shape(), + static_cast <T *> (this->storage()), + this->shape(), + src->extent(), + this->extent(), + box); break; default: assert (0); diff --git a/Carpet/CarpetLib/src/interpolate_3d_2tl.cc b/Carpet/CarpetLib/src/interpolate_3d_2tl.cc index 9dad6a55d..1b9b010da 100644 --- a/Carpet/CarpetLib/src/interpolate_3d_2tl.cc +++ b/Carpet/CarpetLib/src/interpolate_3d_2tl.cc @@ -6,6 +6,8 @@ #include <cctk.h> #include <cctk_Parameters.h> +#include <loopcontrol.h> + #include "operator_prototypes_3d.hh" #include "typeprops.hh" @@ -120,18 +122,16 @@ namespace CarpetLib { // Loop over region -#pragma omp parallel for - for (int k=0; k<regkext; ++k) { - for (int j=0; j<regjext; ++j) { - for (int i=0; i<regiext; ++i) { - - dst [DSTIND3(i, j, k)] = - + s1fac * src1 [SRCIND3(i, j, k)] - + s2fac * src2 [SRCIND3(i, j, k)]; - - } - } - } +#pragma omp parallel + LC_LOOP3 (interpolate_3d_2tl, + i,j,k, 0,0,0, regiext,regjext,regkext, regiext,regjext,regkext) + { + + dst [DSTIND3(i, j, k)] = + + s1fac * src1 [SRCIND3(i, j, k)] + + s2fac * src2 [SRCIND3(i, j, k)]; + + } LC_ENDLOOP3 (interpolate_3d_2tl); } diff --git a/Carpet/CarpetLib/src/interpolate_3d_3tl.cc b/Carpet/CarpetLib/src/interpolate_3d_3tl.cc index 6fdaa854d..f605f67e7 100644 --- a/Carpet/CarpetLib/src/interpolate_3d_3tl.cc +++ b/Carpet/CarpetLib/src/interpolate_3d_3tl.cc @@ -6,6 +6,8 @@ #include <cctk.h> #include <cctk_Parameters.h> +#include <loopcontrol.h> + #include "operator_prototypes_3d.hh" #include "typeprops.hh" @@ -124,19 +126,17 @@ namespace CarpetLib { // Loop over region -#pragma omp parallel for - for (int k=0; k<regkext; ++k) { - for (int j=0; j<regjext; ++j) { - for (int i=0; i<regiext; ++i) { - - dst [DSTIND3(i, j, k)] = - + s1fac * src1 [SRCIND3(i, j, k)] - + s2fac * src2 [SRCIND3(i, j, k)] - + s3fac * src3 [SRCIND3(i, j, k)]; - - } - } - } +#pragma omp parallel + LC_LOOP3 (interpolate_3d_3tl, + i,j,k, 0,0,0, regiext,regjext,regkext, regiext,regjext,regkext) + { + + dst [DSTIND3(i, j, k)] = + + s1fac * src1 [SRCIND3(i, j, k)] + + s2fac * src2 [SRCIND3(i, j, k)] + + s3fac * src3 [SRCIND3(i, j, k)]; + + } LC_ENDLOOP3(interpolate_3d_3tl); } diff --git a/Carpet/CarpetLib/src/interpolate_3d_4tl.cc b/Carpet/CarpetLib/src/interpolate_3d_4tl.cc index 0a2f5c66c..879a2e1c4 100644 --- a/Carpet/CarpetLib/src/interpolate_3d_4tl.cc +++ b/Carpet/CarpetLib/src/interpolate_3d_4tl.cc @@ -6,6 +6,8 @@ #include <cctk.h> #include <cctk_Parameters.h> +#include <loopcontrol.h> + #include "operator_prototypes_3d.hh" #include "typeprops.hh" @@ -131,20 +133,18 @@ namespace CarpetLib { // Loop over region -#pragma omp parallel for - for (int k=0; k<regkext; ++k) { - for (int j=0; j<regjext; ++j) { - for (int i=0; i<regiext; ++i) { - - dst [DSTIND3(i, j, k)] = - + s1fac * src1 [SRCIND3(i, j, k)] - + s2fac * src2 [SRCIND3(i, j, k)] - + s3fac * src3 [SRCIND3(i, j, k)] - + s4fac * src4 [SRCIND3(i, j, k)]; - - } - } - } +#pragma omp parallel + LC_LOOP3 (interpolate_3d_4tl, + i,j,k, 0,0,0, regiext,regjext,regkext, regiext,regjext,regkext) + { + + dst [DSTIND3(i, j, k)] = + + s1fac * src1 [SRCIND3(i, j, k)] + + s2fac * src2 [SRCIND3(i, j, k)] + + s3fac * src3 [SRCIND3(i, j, k)] + + s4fac * src4 [SRCIND3(i, j, k)]; + + } LC_ENDLOOP3(interpolate_3d_5tl); } diff --git a/Carpet/CarpetLib/src/interpolate_3d_5tl.cc b/Carpet/CarpetLib/src/interpolate_3d_5tl.cc index 848d04a7e..bff765e7c 100644 --- a/Carpet/CarpetLib/src/interpolate_3d_5tl.cc +++ b/Carpet/CarpetLib/src/interpolate_3d_5tl.cc @@ -6,6 +6,8 @@ #include <cctk.h> #include <cctk_Parameters.h> +#include <loopcontrol.h> + #include "operator_prototypes_3d.hh" #include "typeprops.hh" @@ -136,21 +138,19 @@ namespace CarpetLib { // Loop over region -#pragma omp parallel for - for (int k=0; k<regkext; ++k) { - for (int j=0; j<regjext; ++j) { - for (int i=0; i<regiext; ++i) { - - dst [DSTIND3(i, j, k)] = - + s1fac * src1 [SRCIND3(i, j, k)] - + s2fac * src2 [SRCIND3(i, j, k)] - + s3fac * src3 [SRCIND3(i, j, k)] - + s4fac * src4 [SRCIND3(i, j, k)] - + s5fac * src5 [SRCIND3(i, j, k)]; - - } - } - } +#pragma omp parallel + LC_LOOP3 (interpolate_3d_5tl, + i,j,k, 0,0,0, regiext,regjext,regkext, regiext,regjext,regkext) + { + + dst [DSTIND3(i, j, k)] = + + s1fac * src1 [SRCIND3(i, j, k)] + + s2fac * src2 [SRCIND3(i, j, k)] + + s3fac * src3 [SRCIND3(i, j, k)] + + s4fac * src4 [SRCIND3(i, j, k)] + + s5fac * src5 [SRCIND3(i, j, k)]; + + } LC_ENDLOOP3(interpolate_3d_5tl); } diff --git a/Carpet/CarpetLib/src/interpolate_eno_3d_3tl.cc b/Carpet/CarpetLib/src/interpolate_eno_3d_3tl.cc index 729bb20b5..c1dad8e27 100644 --- a/Carpet/CarpetLib/src/interpolate_eno_3d_3tl.cc +++ b/Carpet/CarpetLib/src/interpolate_eno_3d_3tl.cc @@ -6,6 +6,8 @@ #include <cctk.h> #include <cctk_Parameters.h> +#include <loopcontrol.h> + #include "operator_prototypes_3d.hh" #include "typeprops.hh" @@ -163,33 +165,31 @@ namespace CarpetLib { // Loop over region -#pragma omp parallel for - for (int k=0; k<regkext; ++k) { - for (int j=0; j<regjext; ++j) { - for (int i=0; i<regiext; ++i) { - - T const s1 = src1 [SRCIND3(i, j, k)]; - T const s2 = src2 [SRCIND3(i, j, k)]; - T const s3 = src3 [SRCIND3(i, j, k)]; - - // 3-point interpolation - T d = s1fac3 * s1 + s2fac3 * s2 + s3fac3 * s3; - - // If the 3-point interpolation leads to a new extremum, - // fall back to 2-point interpolation instead - if (d > max3 (s1, s2, s3) or d < min3 (s1, s2, s3)) { - if (use_12) { - d = s1fac2_12 * s1 + s2fac2_12 * s2; - } else { - d = s2fac2_23 * s2 + s3fac2_23 * s3; - } - } - - dst [DSTIND3(i, j, k)] = d; - +#pragma omp parallel + LC_LOOP3 (interpolate_end_3d_3tl, + i,j,k, 0,0,0, regiext,regjext,regkext, regiext,regjext,regkext) + { + + T const s1 = src1 [SRCIND3(i, j, k)]; + T const s2 = src2 [SRCIND3(i, j, k)]; + T const s3 = src3 [SRCIND3(i, j, k)]; + + // 3-point interpolation + T d = s1fac3 * s1 + s2fac3 * s2 + s3fac3 * s3; + + // If the 3-point interpolation leads to a new extremum, + // fall back to 2-point interpolation instead + if (d > max3 (s1, s2, s3) or d < min3 (s1, s2, s3)) { + if (use_12) { + d = s1fac2_12 * s1 + s2fac2_12 * s2; + } else { + d = s2fac2_23 * s2 + s3fac2_23 * s3; } } - } + + dst [DSTIND3(i, j, k)] = d; + + } LC_ENDLOOP3(interpolate_end_3d_3tl); } diff --git a/Carpet/CarpetLib/src/restrict_3d_cc_rf2.cc b/Carpet/CarpetLib/src/restrict_3d_cc_rf2.cc index c2f89ae4d..ee9d246cb 100644 --- a/Carpet/CarpetLib/src/restrict_3d_cc_rf2.cc +++ b/Carpet/CarpetLib/src/restrict_3d_cc_rf2.cc @@ -114,7 +114,6 @@ namespace CarpetLib { // Loop over coarse region -#pragma omp parallel for for (int k=0; k<regkext; ++k) { for (int j=0; j<regjext; ++j) { for (int i=0; i<regiext; ++i) { diff --git a/Carpet/CarpetLib/src/restrict_3d_rf2.cc b/Carpet/CarpetLib/src/restrict_3d_rf2.cc index 1e0cc6ec4..96d557644 100644 --- a/Carpet/CarpetLib/src/restrict_3d_rf2.cc +++ b/Carpet/CarpetLib/src/restrict_3d_rf2.cc @@ -101,7 +101,6 @@ namespace CarpetLib { // Loop over coarse region -#pragma omp parallel for for (int k=0; k<regkext; ++k) { for (int j=0; j<regjext; ++j) { for (int i=0; i<regiext; ++i) { diff --git a/Carpet/CarpetLib/src/restrict_4d_rf2.cc b/Carpet/CarpetLib/src/restrict_4d_rf2.cc index 77bf2d28b..600e25178 100644 --- a/Carpet/CarpetLib/src/restrict_4d_rf2.cc +++ b/Carpet/CarpetLib/src/restrict_4d_rf2.cc @@ -106,7 +106,6 @@ namespace CarpetLib { // Loop over coarse region -#pragma omp parallel for for (int l=0; l<reglext; ++l) { for (int k=0; k<regkext; ++k) { for (int j=0; j<regjext; ++j) { |