aboutsummaryrefslogtreecommitdiff
path: root/src/Storage.c
diff options
context:
space:
mode:
authorallen <allen@b61c5cb5-eaca-4651-9a7a-d64986f99364>2001-09-16 10:13:01 +0000
committerallen <allen@b61c5cb5-eaca-4651-9a7a-d64986f99364>2001-09-16 10:13:01 +0000
commit46a7d6ef731e9e26279fab0514c91ad41fbac170 (patch)
tree9c4e4e639714a18cde9375456fa1a92652bb8c4a /src/Storage.c
parent5c1f3ae9d5de43fe1d47463222791b6cdb49dc47 (diff)
Extended storage_verbose parameter to give a report on the maximum amount of storage assigned during a run.
The options are now storage_verbose = "yes" -> show everything (enabling, disabling and report) storage_verbose = "report" -> just show report storage_verbose = "no" (the default) -> show nothing The report will be given at termination, and also at every storage_report_every iterations (default is only at termination). I could extend the report to give a list of the GAs with storage at the max if anyone wants that. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@346 b61c5cb5-eaca-4651-9a7a-d64986f99364
Diffstat (limited to 'src/Storage.c')
-rw-r--r--src/Storage.c79
1 files changed, 56 insertions, 23 deletions
diff --git a/src/Storage.c b/src/Storage.c
index b6d312d..1357a72 100644
--- a/src/Storage.c
+++ b/src/Storage.c
@@ -28,8 +28,9 @@ 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 totalnumber = 0; /* Number of stored GAs */
-
+static int maxnumber = 0; /* Maximum number of stored GFs */
/********************************************************************
******************** Internal Routines ************************
@@ -47,6 +48,11 @@ static void PUGH_InitializeMemory (const char *initialize_memory,
int bytes,
void *data);
+/********************************************************************
+ ******************** External Routines ************************
+ ********************************************************************/
+void PUGHi_PrintStorageReport (void);
+
/*@@
@routine PUGH_ArrayGroupSize
@@ -131,13 +137,13 @@ const int *PUGH_ArrayGroupSize (cGH *GH,
if (groupname)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Invalid group name '%s' in PUGH_ArrayGroupSize",
+ "PUGH_ArrayGroupSize: Invalid group name '%s'",
groupname);
}
else
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Invalid group ID %d in PUGH_ArrayGroupSize",
+ "PUGH_ArrayGroupSize: Invalid group ID %d",
group);
}
@@ -240,13 +246,13 @@ int PUGH_QueryGroupStorage (cGH *GH, int group, const char *groupname)
if (groupname)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Invalid group name '%s' in PUGH_ArrayGroupSize",
+ "PUGH_ArrayGroupSize: Invalid group name '%s'",
groupname);
}
else
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Invalid group ID %d in PUGH_ArrayGroupSize",
+ "PUGH_ArrayGroupSize: Invalid group ID %d",
group);
}
}
@@ -329,29 +335,33 @@ int PUGH_EnableGroupStorage (cGH *GH, const char *groupname)
first_var,
pgroup.numvars,
pgroup.numtimelevels);
- if (retval == 0)
+ if (!CCTK_Equals(storage_verbose,"no") && retval == 0)
{
/* get GA pointer of first var in group */
GA = (pGA *) pughGH->variables[first_var][0];
totalnumber += pgroup.numvars * pgroup.numtimelevels;
+ maxnumber = totalnumber > maxnumber ? totalnumber : maxnumber;
totalstorage += (GA->extras->npoints * GA->varsize *
pgroup.numtimelevels * pgroup.numvars) /
(float) (1024*1024);
+ maxstorage = totalstorage > maxstorage ? totalstorage : maxstorage;
+
+ /* Report on memory usage */
+ if (CCTK_Equals(storage_verbose,"yes"))
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "Switched memory on for group '%s'"
+ " [Num Arrays: %d Total Size: %6.2fMB]",
+ groupname, totalnumber, totalstorage);
+ }
}
+
}
else
{
- CCTK_WARN (1, "Unknown group type in PUGH_EnableGroupStorage");
+ CCTK_WARN (1, "PUGH_EnableGroupStorage: Unknown group type");
retval = -1;
}
- /* Report on memory usage */
- if (storage_verbose && retval == 0)
- {
- printf ("Switched memory on for group '%s'\n"
- " [Num Arrays: %d Total Size: %6.2fMB]\n",
- groupname, totalnumber, totalstorage);
- }
}
else
{
@@ -469,28 +479,34 @@ int PUGH_DisableGroupStorage (cGH *GH, const char *groupname)
}
/* Report on memory usage */
- if (storage_verbose && retval >= 0)
+ if (!CCTK_Equals(storage_verbose,"no") && retval >= 0)
{
if (unchanged == 0)
{
+
/* Memory toggled */
totalnumber -= pgroup.numvars;
totalstorage -= (variables[first_var][0]->extras->npoints *
variables[first_var][0]->varsize *
- pgroup.numtimelevels * pgroup.numvars) /
- (float) (1024 * 1024);
- printf ("Switched memory off for group '%s'\n"
- " [Num Arrays: %d Total Size: %6.2fMB]\n",
- groupname, totalnumber, totalstorage);
+ pgroup.numtimelevels * pgroup.numvars) / (float) (1024 * 1024);
+ if (CCTK_Equals(storage_verbose,"yes"))
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "Switched memory off for group '%s'"
+ " [Num Arrays: %d Total Size: %6.2fMB]",
+ groupname, totalnumber, totalstorage);
+ }
}
else if (unchanged == pgroup.numvars)
{
/* Memory already off */
- printf ("Memory already off for group '%s'\n", groupname);
+ if (CCTK_Equals(storage_verbose,"yes"))
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "Memory already off for group '%s'", groupname);
+ }
}
else
{
- CCTK_WARN (1, "Inconsistency in group memory assignment");
+ CCTK_WARN (1, "PUGH_DisableGroupStorage: Inconsistency in group memory assignment");
}
}
@@ -785,7 +801,7 @@ static int PUGH_EnableGArrayGroupStorage (pGH *pughGH,
if (retval)
{
CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "FATAL ERROR: Cannot allocate data for '%s' [%d]\n",
+ "PUGH_EnableGArrayDataStorage: Cannot allocate data for '%s' [%d]",
GA->name, GA->id);
}
@@ -906,3 +922,20 @@ static void PUGH_InitializeMemory (const char *initialize_memory,
"parameter 'initialize_memory'", initialize_memory);
}
}
+
+
+
+ /*@@
+ @routine PUGHi_PrintStorageInfo
+ @author Gabrielle Allen
+ @date 16th Sept 2001
+ @desc
+ Print a report about the use of storage
+ @enddesc
+@@*/
+void PUGHi_PrintStorageReport ()
+{
+ CCTK_INFO("Storage statistics");
+ CCTK_VInfo(CCTK_THORNSTRING, " Maximum number of GAs: %d",maxnumber);
+ CCTK_VInfo(CCTK_THORNSTRING, " Maximum storage assigned: %6.2fMB",maxstorage);
+}