Index: src/Storage.c =================================================================== RCS file: /cactusdevcvs/CactusPUGH/PUGH/src/Storage.c,v retrieving revision 1.51 diff -u -r1.51 Storage.c --- src/Storage.c 26 Sep 2005 00:27:59 -0000 1.51 +++ src/Storage.c 2 Nov 2005 21:04:48 -0000 @@ -27,12 +27,10 @@ /******************************************************************** ******************** 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 first_var; /* first variable's index */ cGroup pgroup; /* group information */ int retval; - pGA *GA; pGH *pughGH; @@ -326,36 +323,6 @@ 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 @@ } } - /* 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_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 @@ } 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); @@ -719,10 +647,28 @@ fflush (stdout); #endif + /* Keep track of allocated memory */ + totalstorage += GA->extras->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 +712,7 @@ @@*/ /* static */ int PUGH_DisableGArrayDataStorage (pGA *GA) { + DECLARE_CCTK_PARAMETERS int retval; retval = GA->storage != PUGH_STORAGE; @@ -798,6 +745,19 @@ GA->data = GA->padddata; } + /* Keep track of allocated memory */ + totalstorage -= GA->extras->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 +840,10 @@ 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 +856,7 @@ 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 cvs diff: Diffing src/include