From 33cdb10598caa90acaadb568d4e869174ad70ec4 Mon Sep 17 00:00:00 2001 From: rhaas Date: Fri, 2 Aug 2013 21:34:14 +0000 Subject: add code to align allocated memory for vectorization git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@524 b61c5cb5-eaca-4651-9a7a-d64986f99364 --- configuration.ccl | 4 ++++ interface.ccl | 2 ++ src/Storage.c | 14 +++++++++++--- src/include/pughi.h | 2 ++ src/make.code.defn | 2 +- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/configuration.ccl b/configuration.ccl index 1a5e567..db93a45 100644 --- a/configuration.ccl +++ b/configuration.ccl @@ -10,3 +10,7 @@ PROVIDES PUGH OPTIONAL MPI { } + +OPTIONAL_IFACTIVE Vectors +{ +} diff --git a/interface.ccl b/interface.ccl index 95c3b2a..734ec17 100644 --- a/interface.ccl +++ b/interface.ccl @@ -6,3 +6,5 @@ implements: Driver INCLUDE HEADER: Register.h in pugh_Register.h USES INCLUDE: pugh_Register.h + +USES INCLUDE: Vectors.h diff --git a/src/Storage.c b/src/Storage.c index cbdf47d..0146b07 100644 --- a/src/Storage.c +++ b/src/Storage.c @@ -628,9 +628,17 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH, else if (! my_padding_active) { /* Easy case. */ - GA->data = malloc ((size_t) GA->extras->npoints * GA->varsize - * GA->vector_size); - GA->padddata = GA->data; + size_t align = PUGH_GetVectorSize() * GA->varsize; + GA->padddata = malloc ((size_t) GA->extras->npoints * GA->varsize + * GA->vector_size + align-1); + if (((size_t) GA->padddata) % align) + { + GA->data = (char *) GA->padddata + align - (((size_t) GA->padddata) % align); + } + else + { + GA->data = GA->padddata; + } } else { diff --git a/src/include/pughi.h b/src/include/pughi.h index b934690..67ec409 100644 --- a/src/include/pughi.h +++ b/src/include/pughi.h @@ -106,6 +106,8 @@ int PUGH_SyncGArray(pGA *GA); int PUGH_NumTimeLevels(const pGH *pughGH, int var); +size_t PUGH_GetVectorSize(void); + #ifdef CCTK_MPI void PostSendGA (pGH *pughGH, int dir, pComm *comm); void PostReceiveGA (pGH *pughGH, int dir, pComm *comm); diff --git a/src/make.code.defn b/src/make.code.defn index 4779272..bcb4e70 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -4,4 +4,4 @@ SRCS = Startup.c GHExtension.c Overloadables.c PughUtils.c LoadAware.c \ Evolve.c Comm.c Storage.c SetupPGH.c SetupGroup.c SetupPGV.c \ PostSendGA.c PostReceiveGA.c FinishReceiveGA.c Registration.c \ - P2LMappings.c Topology.c + P2LMappings.c Topology.c Vectors.cc -- cgit v1.2.3