aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364>2006-06-15 16:15:19 +0000
committertradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364>2006-06-15 16:15:19 +0000
commitdf76f6a88df32597d6a4f819024d165a41787f47 (patch)
tree63ce1e73e67de7acf0a23c0dae71e52e53a7e4bb
parentfba3c7e979a4b10815683703eb4bd6ff05244f22 (diff)
Erik's patch to "Make PUGH's memory statistics work again".
See http://www.cactuscode.org/old/pipermail/patches/2005-November/000118.html for the start of the thread. The final patch is not available on the patches mailing list but can eventually be refered to via http://www.aei.mpg.de/~jthorn/spool/pugh-memstats-2.diff. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@480 b61c5cb5-eaca-4651-9a7a-d64986f99364
-rw-r--r--src/Storage.c145
-rw-r--r--src/include/pGV.h5
2 files changed, 57 insertions, 93 deletions
diff --git a/src/Storage.c b/src/Storage.c
index 066fe18..5c9f1cb 100644
--- a/src/Storage.c
+++ b/src/Storage.c
@@ -27,12 +27,10 @@ CCTK_FILEVERSION(CactusPUGH_PUGH_Storage_c);
/********************************************************************
******************** Static Variables *************************
********************************************************************/
-static float totalstorage = 0; /* Storage for GAs in Bytes */
-static float maxstorage = 0; /* Maximum storage for GAs in MBytes */
-static int totalnumberGA = 0; /* Number of stored GAs */
-static int totalnumberGF = 0; /* Number of stored GFs */
-static int numberGA = 0; /* Number of GAs at max */
-static int numberGF = 0; /* Number of GFs at max */
+static double totalstorage = 0; /* Storage for GVs in Bytes */
+static double maxstorage = 0; /* Maximum storage for GVs in Bytes */
+static int totalnumberGVTL = 0; /* Number of stored GV time levels */
+static int numberGVTL = 0; /* Number of GV time levels at max */
/********************************************************************
******************** Internal Routines ************************
@@ -300,7 +298,6 @@ int PUGH_EnableGroupStorage (const cGH *GH, const char *groupname)
int first_var; /* first variable's index */
cGroup pgroup; /* group information */
int retval;
- pGA *GA;
pGH *pughGH;
@@ -326,36 +323,6 @@ int PUGH_EnableGroupStorage (const cGH *GH, const char *groupname)
first_var,
pgroup.numvars,
pgroup.numtimelevels);
- if (!CCTK_Equals(storage_verbose,"no") && retval == 0)
- {
- /* get GA pointer of first var in group */
- GA = (pGA *) pughGH->variables[first_var][0];
- if (pgroup.grouptype == CCTK_GF)
- {
- totalnumberGF += pgroup.numvars * pgroup.numtimelevels;
- }
- else
- {
- totalnumberGA += pgroup.numvars * pgroup.numtimelevels;
- }
- totalstorage += (GA->extras->npoints * GA->varsize *
- pgroup.numtimelevels * pgroup.numvars) /
- (float) (1024*1024);
- if (totalstorage > maxstorage)
- {
- numberGF = totalnumberGF;
- numberGA = totalnumberGA;
- maxstorage = totalstorage;
- }
-
- /* Report on memory usage */
- if (CCTK_Equals(storage_verbose,"yes"))
- {
- CCTK_VInfo (CCTK_THORNSTRING, "Switched memory on for group '%s'"
- " [GFs: %d GAs: %d Total Size: %6.2fMB]",
- groupname, totalnumberGF, totalnumberGA, totalstorage);
- }
- }
}
else
{
@@ -455,46 +422,6 @@ int PUGH_DisableGroupStorage (const cGH *GH, const char *groupname)
}
}
- /* Report on memory usage */
- if (!CCTK_Equals(storage_verbose,"no") && retval >= 0)
- {
- if (unchanged == 0)
- {
-
- /* Memory toggled */
- if (pgroup.grouptype == CCTK_GF)
- {
- totalnumberGF -= pgroup.numvars;
- }
- else
- {
- totalnumberGA -= pgroup.numvars;
- }
- totalstorage -= (variables[first_var][0]->extras->npoints *
- variables[first_var][0]->varsize *
- pgroup.numtimelevels * pgroup.numvars) /
- (float) (1024 * 1024);
- if (CCTK_Equals(storage_verbose,"yes"))
- {
- CCTK_VInfo (CCTK_THORNSTRING, "Switched memory off for group '%s'"
- " [GFs: %d GAs: %d Total Size: %6.2fMB]",
- groupname, totalnumberGF, totalnumberGA, totalstorage);
- }
- }
- else if (unchanged == pgroup.numvars)
- {
- /* Memory already off */
- if (CCTK_Equals(storage_verbose,"yes"))
- {
- CCTK_VInfo (CCTK_THORNSTRING, "Memory already off for group '%s'", groupname);
- }
- }
- else
- {
- CCTK_WARN (1, "PUGH_DisableGroupStorage: Inconsistency in group memory assignment");
- }
- }
-
return (retval);
}
@@ -643,21 +570,22 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
@@*/
/* static */ int PUGH_EnableGArrayDataStorage (pGA *GA,
int this_proc,
- const char *initialize_memory,
- int padding_active,
- int padding_cacheline_bits,
- int padding_size,
- int padding_address_spacing)
+ const char *my_initialize_memory,
+ int my_padding_active,
+ int my_padding_cacheline_bits,
+ int my_padding_size,
+ int my_padding_address_spacing)
{
+ DECLARE_CCTK_PARAMETERS;
int i, global_size, retval;
/* avoid compiler warnings about unused parameters */
this_proc = this_proc;
- padding_active = padding_active;
- padding_cacheline_bits = padding_cacheline_bits;
- padding_size = padding_size;
- padding_address_spacing = padding_address_spacing;
+ my_padding_active = my_padding_active;
+ my_padding_cacheline_bits = my_padding_cacheline_bits;
+ my_padding_size = my_padding_size;
+ my_padding_address_spacing = my_padding_address_spacing;
retval = 0;
if (GA->storage == PUGH_NOSTORAGE)
@@ -700,7 +628,7 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
}
GA->data = GA->padddata = NULL;
}
- else if (! padding_active)
+ else if (! my_padding_active)
{
/* Easy case. */
GA->data = malloc (GA->extras->npoints * GA->varsize * GA->vector_size);
@@ -713,16 +641,35 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
GA->extras->npoints * GA->varsize * GA->vector_size,
&GA->padddata);
}
+ GA->npoints = GA->extras->npoints;
#ifdef DEBUG_PUGH
printf (" PUGH_EnableGArrayDataStorage: new pointer is %p (%p)\n",
GA->padddata, GA->data);
fflush (stdout);
#endif
+ /* Keep track of allocated memory */
+ totalstorage += GA->npoints * GA->varsize * GA->vector_size;
+ totalnumberGVTL += GA->vector_size;
+ if (totalstorage > maxstorage)
+ {
+ numberGVTL = totalnumberGVTL;
+ maxstorage = totalstorage;
+ }
+
+ /* Report on memory usage */
+ if (CCTK_Equals(storage_verbose,"yes"))
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "Switched memory on for variable '%s'"
+ " [GV TLs: %d Total Size: %6.2f MB]",
+ GA->name,
+ totalnumberGVTL, totalstorage / (double)(1024*1024));
+ }
+
/* Initialize the memory if desired. */
if (GA->data)
{
- PUGH_InitializeMemory (initialize_memory, GA->vtype,
+ PUGH_InitializeMemory (my_initialize_memory, GA->vtype,
GA->extras->npoints * GA->varsize * GA->vector_size, GA->data);
}
@@ -766,6 +713,7 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
@@*/
/* static */ int PUGH_DisableGArrayDataStorage (pGA *GA)
{
+ DECLARE_CCTK_PARAMETERS
int retval;
retval = GA->storage != PUGH_STORAGE;
@@ -798,6 +746,19 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
GA->data = GA->padddata;
}
+ /* Keep track of allocated memory */
+ totalstorage -= GA->npoints * GA->varsize * GA->vector_size;
+ totalnumberGVTL -= GA->vector_size;
+
+ /* Report on memory usage */
+ if (CCTK_Equals(storage_verbose,"yes"))
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "Switched memory off for variable '%s'"
+ " [GV TLs: %d Total Size: %6.2f MB]",
+ GA->name,
+ totalnumberGVTL, totalstorage / (double)(1024*1024));
+ }
+
GA->storage = PUGH_NOSTORAGE;
}
@@ -880,8 +841,10 @@ void PUGH_InitializeMemory (const char *do_initialize_memory,
void PUGHi_PrintStorageReport ()
{
CCTK_INFO("Storage statistics");
- CCTK_VInfo(CCTK_THORNSTRING, " Maximum storage: %6.2fMB",maxstorage);
- CCTK_VInfo(CCTK_THORNSTRING, " [%d Grid Functions, %d Grid Arrays]",numberGF,numberGA);
+ CCTK_VInfo(CCTK_THORNSTRING, " Maximum storage: %6.2f MB",
+ maxstorage / (double)(1024*1024));
+ CCTK_VInfo(CCTK_THORNSTRING, " [%d grid variable time levels]",
+ numberGVTL);
}
@@ -894,7 +857,7 @@ void PUGHi_PrintStorageReport ()
to the specified number of timelevels of each listed group, returning the
previous number of timelevels enable for that group in the status array,
if that is not NULL. It should never decrease the number of timelevels enabled,
- i.e. if it is asked to enable less timelevels than are already enable it should
+ i.e., if it is asked to enable less timelevels than are already enable it should
not change the storage for that group.
@enddesc
diff --git a/src/include/pGV.h b/src/include/pGV.h
index 13d3214..8219847 100644
--- a/src/include/pGV.h
+++ b/src/include/pGV.h
@@ -95,11 +95,12 @@ typedef struct PGA
void *padddata; /* Storage for the data. */
void *data; /* See the note above. */
int storage; /* Do we have storage or not? */
+ int npoints; /* Number of points (for memory statistics) */
int *stagger; /* [dim] directional stagger indicies */
void *parent; /* The GH to which I belong */
- /* Note this is struct PGH whic is
- typedeffed to pGH in pGH.h, but
+ /* Note this is struct PGH which is
+ typedef'd to pGH in pGH.h, but
that is included AFTER this so we
need the full name for the lookahead
structure reference thingy.