aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhaas <rhaas@b61c5cb5-eaca-4651-9a7a-d64986f99364>2013-08-02 21:34:14 +0000
committerrhaas <rhaas@b61c5cb5-eaca-4651-9a7a-d64986f99364>2013-08-02 21:34:14 +0000
commit33cdb10598caa90acaadb568d4e869174ad70ec4 (patch)
treed4ae7fba0aa6f85808e7a238c4c76e6451fe921b
parent5d9cf6b6570334ab9c8078790c61d091fcb8b78a (diff)
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
-rw-r--r--configuration.ccl4
-rw-r--r--interface.ccl2
-rw-r--r--src/Storage.c14
-rw-r--r--src/include/pughi.h2
-rw-r--r--src/make.code.defn2
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