diff options
author | tradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 2000-03-13 09:54:41 +0000 |
---|---|---|
committer | tradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 2000-03-13 09:54:41 +0000 |
commit | 57df312b3027097a588b3782c9553471b82e3554 (patch) | |
tree | e700d69098113649d8b7ffc930a106bbf0fed22a /src/SetupPGV.c | |
parent | 9fddfde02b02ae729e3398c576ec804636467d57 (diff) |
Completed DestroyPGH(), added DestroyConnectivity() and DestroyPGextras().
This should fix the memory leak in BAM as well as running out of
MPI_Type_requests.
Thomas
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@177 b61c5cb5-eaca-4651-9a7a-d64986f99364
Diffstat (limited to 'src/SetupPGV.c')
-rw-r--r-- | src/SetupPGV.c | 137 |
1 files changed, 121 insertions, 16 deletions
diff --git a/src/SetupPGV.c b/src/SetupPGV.c index f48396a..9e943a1 100644 --- a/src/SetupPGV.c +++ b/src/SetupPGV.c @@ -163,6 +163,54 @@ pGExtras *pugh_SetupPGExtras(int dim, } /*@@ + @routine pugh_DestroyPGExtras + @date Mar 12 2000 + @author Thomas Radke + @desc + Destroys a PGExtras structure. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +void pugh_DestroyPGExtras(pGExtras **PGExtras) +{ + if(PGExtras && *PGExtras) + { + int i, j; + + for(i = 0 ; i < PUGH_NSTAGGER; i++) + { + for(j = 0; j < 2; j++) + { + free((*PGExtras)->ghosts[i][j][0]); + free((*PGExtras)->overlap[i][j][0]); + free((*PGExtras)->ownership[i][j]); + free((*PGExtras)->ghosts[i][j]); + free((*PGExtras)->overlap[i][j]); + } + } + free((*PGExtras)->lb[0]); + free((*PGExtras)->ub[0]); + free((*PGExtras)->rnsize[0]); + + free((*PGExtras)->lb); + free((*PGExtras)->ub); + free((*PGExtras)->rnsize); + free((*PGExtras)->rnpoints); + free((*PGExtras)->nghostzones); + free((*PGExtras)->nsize); + free((*PGExtras)->lnsize); + + free(*PGExtras); + *PGExtras = NULL; + } +} + + /*@@ @routine pugh_SetupConnectivity @date Fri Nov 5 11:32:12 1999 @author Tom Goodale @@ -243,6 +291,34 @@ pConnectivity *pugh_SetupConnectivity(int dim, } /*@@ + @routine pugh_DestroyConnectivity + @date Mar 12 2000 + @author Thomas Radke + @desc + Destroys a connectivity structure containing + all the details of processor connectivities + for this processor layout. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +void pugh_DestroyConnectivity(pConnectivity **conn) +{ + if (conn && *conn) + { + free((*conn)->neighbours[0]); + free((*conn)->neighbours); + free((*conn)->nprocs); + free(*conn); + *conn = NULL; + } +} + + /*@@ @routine pugh_GenerateTopology @date Fri Nov 5 11:31:21 1999 @author Tom Goodale @@ -1311,6 +1387,44 @@ pGA *SetupPGA(void *parent, return this; } + /*@@ + @routine DestroyPGA + @date Mar 12 2000 + @author Thomas Radke + @desc + Destroys a pGA object. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +void DestroyPGA(pGA **GA) +{ + if(GA && *GA) + { + if((*GA)->storage != PUGH_NOSTORAGE) + { + pugh_DisableGADataStorage(*GA); + } + free((*GA)->name); + free((*GA)->buffer_sz); + free((*GA)->send_buffer); + free((*GA)->recv_buffer); + free((*GA)->docomm); + free((*GA)->padddata); + +#ifdef MPI + free((*GA)->sreq); + free((*GA)->rreq); +#endif + free(*GA); + *GA = NULL; + } +} + int pugh_EnablePGAStorage(pGA *GA, int this_proc, int zero_memory, @@ -1421,12 +1535,10 @@ int pugh_EnablePGAStorage(pGA *GA, if (special_pad > padding_size) { - char msg [100]; - - sprintf (msg, "FATAL ERROR: padding size not large enough for cache type " - "specified %d %d %d\n", special_pad, padding_size, cache_size); - CCTK_WARN (0, msg); - free(msg); + CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, + "FATAL ERROR: padding size not large enough for cache " + "type specified %d %d %d\n", + special_pad, padding_size, cache_size); } retval = 0; @@ -1436,12 +1548,9 @@ int pugh_EnablePGAStorage(pGA *GA, if (!GA->padddata) { - char *msg = (char *) malloc (80 + strlen (GA->name)); - - sprintf (msg, "FATAL ERROR: Cannot allocate data for %s [%d]\n", - GA->name, GA->id); - CCTK_WARN (0, msg); - free (msg); + CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, + "FATAL ERROR: Cannot allocate data for %s [%d]\n", + GA->name, GA->id); } GA->storage = PUGH_STORAGE; @@ -1580,7 +1689,3 @@ void pugh_GAComm(pGA *GA, int docomm) } } - - - - |