diff options
author | eschnett <eschnett@20f44201-0f4f-0410-9130-e5fc2714a787> | 2011-05-09 00:17:00 +0000 |
---|---|---|
committer | eschnett <eschnett@20f44201-0f4f-0410-9130-e5fc2714a787> | 2011-05-09 00:17:00 +0000 |
commit | 5cb313ab6b512420aeedc35f5a0398b2cd8bc776 (patch) | |
tree | 3288357604c2695b84499f86eb9e723640f20277 | |
parent | 61cf82a71f92e41007fe03be4fa2dcf874b0fefe (diff) |
Use the new Slab API to set up the communication schedule only once
(per regridding), which saves some communication time when applying
symmetries.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/RotatingSymmetry180/trunk@62 20f44201-0f4f-0410-9130-e5fc2714a787
-rw-r--r-- | interface.ccl | 15 | ||||
-rw-r--r-- | src/rotatingsymmetry180.c | 69 |
2 files changed, 69 insertions, 15 deletions
diff --git a/interface.ccl b/interface.ccl index f196ba2..6bcbedd 100644 --- a/interface.ccl +++ b/interface.ccl @@ -88,6 +88,21 @@ USES FUNCTION GetDomainSpecification CCTK_INT FUNCTION \ + GetRegriddingEpoch \ + (CCTK_POINTER_TO_CONST IN cctkGH) +USES FUNCTION GetRegriddingEpoch + +CCTK_INT FUNCTION \ + GetRefinementLevel \ + (CCTK_POINTER_TO_CONST IN cctkGH) +USES FUNCTION GetRefinementLevel + +CCTK_INT FUNCTION \ + GetRefinementLevels \ + (CCTK_POINTER_TO_CONST IN cctkGH) +USES FUNCTION GetRefinementLevels + +CCTK_INT FUNCTION \ GetLocalComponents \ (CCTK_POINTER_TO_CONST IN cctkGH) USES FUNCTION GetLocalComponents diff --git a/src/rotatingsymmetry180.c b/src/rotatingsymmetry180.c index 1317f80..c12407c 100644 --- a/src/rotatingsymmetry180.c +++ b/src/rotatingsymmetry180.c @@ -1,19 +1,19 @@ -#include <assert.h> -#include <math.h> -#include <stdlib.h> -#include <string.h> - -#include "cctk.h" -#include "cctk_Arguments.h" -#include "cctk_Parameters.h" +#include <cctk.h> +#include <cctk_Arguments.h> +#include <cctk_Parameters.h> -#include "util_ErrorCodes.h" -#include "util_Table.h" +#include <util_ErrorCodes.h> +#include <util_Table.h> -#include "Slab.h" +#include <Slab.h> #include "rotatingsymmetry180.h" +#include <assert.h> +#include <math.h> +#include <stdlib.h> +#include <string.h> + int BndRot180VI (cGH const * restrict const cctkGH, @@ -478,10 +478,49 @@ int BndRot180VI (cGH const * restrict const cctkGH, options = Util_TableCreateFromString ("useghosts=1"); assert (options>=0); - ierr = Slab_MultiTransfer - (cctkGH, group.dim, xferinfo, options, - nvars, vartypes, varptrs, vartypes, varptrs); - assert (!ierr); + /* Can we use the more efficient interface? */ + if (CCTK_IsFunctionAliased ("GetRegriddingEpoch")) { + static int old_epoch = -1; + static struct slabsetup *restrict *restrict slab_setups = NULL; + static int num_slab_setups = 0; + int const epoch = GetRegriddingEpoch (cctkGH); + if (epoch > old_epoch) { + old_epoch = epoch; + /* Delete old slabbing setups */ + for (int rl=0; rl<num_slab_setups; ++rl) { + if (slab_setups[rl]) { + Slab_MultiTransfer_Finalize (cctkGH, slab_setups[rl]); + } + } + free (slab_setups); + num_slab_setups = GetRefinementLevels (cctkGH); + slab_setups = malloc (num_slab_setups * sizeof *slab_setups); + assert (slab_setups); + for (int rl=0; rl<num_slab_setups; ++rl) { + slab_setups[rl] = NULL; + } + } + /* Use existing slabbing setup */ + assert (slab_setups); + int const reflevel = GetRefinementLevel (cctkGH); + assert (reflevel>=0 && reflevel<num_slab_setups); + if (!slab_setups[reflevel]) { + slab_setups[reflevel] = + Slab_MultiTransfer_Init (cctkGH, group.dim, xferinfo, options); + } + assert (slab_setups[reflevel]); + ierr = Slab_MultiTransfer_Apply + (cctkGH, slab_setups[reflevel], + nvars, vartypes, varptrs, vartypes, varptrs); + assert (!ierr); + } else { + /* We can't use the more efficient interface, so fall back to + the old one */ + ierr = Slab_MultiTransfer + (cctkGH, group.dim, xferinfo, options, + nvars, vartypes, varptrs, vartypes, varptrs); + assert (!ierr); + } ierr = Util_TableDestroy (options); assert (!ierr); |