aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--param.ccl4
-rw-r--r--src/Comm.c102
2 files changed, 81 insertions, 25 deletions
diff --git a/param.ccl b/param.ccl
index 83fcb6f..be87f3d 100644
--- a/param.ccl
+++ b/param.ccl
@@ -205,3 +205,7 @@ STRING partition_3d_z "Tells how to partition on direction z"
{
.* ::
} ""
+
+LOGICAL storage_verbose "Report on memory assignment"
+{
+} "no" \ No newline at end of file
diff --git a/src/Comm.c b/src/Comm.c
index 47870bb..c734802 100644
--- a/src/Comm.c
+++ b/src/Comm.c
@@ -21,9 +21,13 @@
#include "pugh.h"
#include "pugh_Comm.h"
+#include "cctk_Parameters.h"
static char *rcsid="$Header$";
+static int totalstorage=0; /* Storage for GAs in Bytes */
+static int totalnumber=0; /* Number of stored GAs */
+
/* index into GH->extensions[] to get the PUGH extension handle */
extern int PUGH_GHExtension;
@@ -39,12 +43,6 @@ int pugh_SyncGAs(pGH *pughGH,
int first_var,
int n_vars,
int timelevel);
-int pugh_DisableArrayGroupStorage(cGH *GH,
- int group,
- int vtype,
- int dim,
- int n_variables,
- int n_timelevels);
int pugh_EnableArrayGroupStorage(cGH *GH,
int group,
int vtype,
@@ -244,7 +242,7 @@ int *pugh_ArrayGroupSize (cGH *GH, int dir, int group, const char *groupname)
break;
default :
sizep = NULL;
- printf("Wrong value for dir in pugh_ArrayGroupSize\n");
+ CCTK_WARN(1,"Wrong value for dir in pugh_ArrayGroupSize");
break;
}
}
@@ -379,9 +377,14 @@ int pugh_QueryGroupStorage(cGH *GH, int group, const char *groupname)
int pugh_EnableGroupStorage(cGH *GH, const char *groupname)
{
+
+ DECLARE_CCTK_PARAMETERS
+
int group; /* group index */
cGroup pgroup; /* pointer to group information */
int rc; /* return code */
+ pGH *pughGH;
+ int first_var;
#ifdef DEBUG_PUGH
printf(" pugh_EnableGroupStorage: request for group -%s-\n",groupname);
@@ -424,7 +427,36 @@ int pugh_EnableGroupStorage(cGH *GH, const char *groupname)
break;
}
+ /* Report on memory usage */
+ if (storage_verbose)
+ {
+ /* get PUGH extension handle */
+ pughGH = (pGH *) GH->extensions [PUGH_GHExtension];
+
+ /* get global index of first variable in group */
+ first_var = CCTK_FirstVarIndexI (group);
+
+ if (rc == 0)
+ {
+ /* Memory toggled */
+ totalnumber = totalnumber + pgroup.numvars;
+ totalstorage = totalstorage +
+ ((pGA ***)pughGH->variables)[first_var][0]->extras->npoints
+ *CCTK_VarTypeSize(pgroup.vartype)
+ *pgroup.numtimelevels
+ *pgroup.numvars;
+ printf("Switched memory on for %s \n [Num Arrays: %d Total Size: %d]\n",
+ groupname,totalnumber,totalstorage);
+ }
+ else if (rc == 1)
+ {
+ /* Memory already on */
+ printf("Memory already on for %s\n",groupname);
+ }
+ }
+
return (rc);
+
}
@@ -436,7 +468,6 @@ int pugh_EnableGroupStorage(cGH *GH, const char *groupname)
Disables storage for all variables in the group indicated by groupname.
@enddesc
@calls CCTK_DecomposeName CCTK_GroupIndex CCTK_GroupData CCTK_WARN
- pugh_DisableArrayGroupStorage
@history
@endhistory
@@ -454,12 +485,15 @@ int pugh_EnableGroupStorage(cGH *GH, const char *groupname)
int pugh_DisableGroupStorage(cGH *GH, const char *groupname)
{
+ DECLARE_CCTK_PARAMETERS
+
int group; /* group index */
cGroup pgroup; /* pointer to group information */
int rc; /* return code */
pGH *pughGH; /* PUGH extension reference */
int level;
int first_var,var;
+ int unchanged; /* count how many aren't toggled */
/* get PUGH extension handle */
pughGH = (pGH *) GH->extensions [PUGH_GHExtension];
@@ -477,6 +511,7 @@ int pugh_DisableGroupStorage(cGH *GH, const char *groupname)
/* get the group info from its index */
CCTK_GroupData (group,&pgroup);
+ unchanged = 0;
switch (pgroup.grouptype)
{
case GROUP_SCALAR :
@@ -488,7 +523,8 @@ int pugh_DisableGroupStorage(cGH *GH, const char *groupname)
{
for (level = 0; level < pgroup.numtimelevels; level++)
{
- pugh_DisableGADataStorage ((pGA *)(pughGH->variables[var][level]));
+ unchanged = unchanged +
+ pugh_DisableGADataStorage ((pGA *)(pughGH->variables[var][level]));
}
}
rc = 1;
@@ -499,7 +535,8 @@ int pugh_DisableGroupStorage(cGH *GH, const char *groupname)
{
for (level = 0; level < pgroup.numtimelevels; level++)
{
- pugh_DisableGADataStorage ((pGA *)(pughGH->variables[var][level]));
+ unchanged = unchanged +
+ pugh_DisableGADataStorage ((pGA *)(pughGH->variables[var][level]));
}
}
rc = 1;
@@ -511,6 +548,32 @@ int pugh_DisableGroupStorage(cGH *GH, const char *groupname)
break;
}
+ /* Report on memory usage */
+ if (storage_verbose)
+ {
+ if (unchanged == 0)
+ {
+ /* Memory toggled */
+ totalnumber = totalnumber - pgroup.numvars;
+ totalstorage = totalstorage -
+ ((pGA ***)pughGH->variables)[first_var][0]->extras->npoints
+ *CCTK_VarTypeSize(pgroup.vartype)
+ *pgroup.numtimelevels
+ *pgroup.numvars;
+ printf("Switched memory off for %s \n [Num Arrays: %d Total Size: %d]\n",
+ groupname,totalnumber,totalstorage);
+ }
+ else if (unchanged == pgroup.numvars)
+ {
+ /* Memory already off */
+ printf("Memory already off for %s\n",groupname);
+ }
+ else
+ {
+ CCTK_WARN(1,"Inconsistency in group memory assignment");
+ }
+ }
+
return (rc);
}
@@ -654,8 +717,8 @@ int pugh_DisableGroupComm(cGH *GH, const char *groupname)
{
for (level = 0; level < pgroup.numtimelevels; level++)
{
- pugh_GAComm ((pGA *)(pughGH->variables[var][level]),
- PUGH_NOCOMM);
+ pugh_GAComm ((pGA *)(pughGH->variables[var][level]),
+ PUGH_NOCOMM);
}
}
rc = 1;
@@ -665,8 +728,8 @@ int pugh_DisableGroupComm(cGH *GH, const char *groupname)
for (var = first_var; var < first_var+pgroup.numvars; var++)
for (level = 0; level < pgroup.numtimelevels; level++)
{
- pugh_GAComm ((pGA *)(pughGH->variables[var][level]),
- PUGH_NOCOMM);
+ pugh_GAComm ((pGA *)(pughGH->variables[var][level]),
+ PUGH_NOCOMM);
}
rc = 1;
break;
@@ -1002,17 +1065,6 @@ int pugh_EnableArrayGroupStorage(cGH *GH,
}
-int pugh_DisableArrayGroupStorage(cGH *GH,
- int group,
- int vtype,
- int dim,
- int n_variables,
- int n_timelevels)
-{
- return 0;
-}
-
-
int pugh_MyProc(cGH *GH)
{
int myproc;