aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364>2000-03-13 09:54:41 +0000
committertradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364>2000-03-13 09:54:41 +0000
commit57df312b3027097a588b3782c9553471b82e3554 (patch)
treee700d69098113649d8b7ffc930a106bbf0fed22a
parent9fddfde02b02ae729e3398c576ec804636467d57 (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
-rw-r--r--src/PostReceiveGA.c2
-rw-r--r--src/SetupPGH.c42
-rw-r--r--src/SetupPGV.c137
-rw-r--r--src/pGF_PostRecv.c2
4 files changed, 148 insertions, 35 deletions
diff --git a/src/PostReceiveGA.c b/src/PostReceiveGA.c
index 6a0e85e..8ae855e 100644
--- a/src/PostReceiveGA.c
+++ b/src/PostReceiveGA.c
@@ -43,7 +43,7 @@ void PostReceiveGA(pGH *GH, pGA *GA, int dir)
{
#ifdef MPI
int rtag;
- int mpi_type;
+ MPI_Datatype mpi_type;
MPI_Datatype *recv_dt;
if (!(GA->storage))
diff --git a/src/SetupPGH.c b/src/SetupPGH.c
index 53e7f12..5d20194 100644
--- a/src/SetupPGH.c
+++ b/src/SetupPGH.c
@@ -28,6 +28,10 @@ void DestroyPGF(pGH *GH, pGF **GFin);
void pGH_DumpInfo(pGH *GH);
int SetupDefaultTopology(int dim, int *nprocs);
int pGH_SetupnProcs(pGH *GH,int dim);
+void pugh_DestroyConnectivity(pConnectivity **conn);
+void DestroyPGA(pGA **GA);
+void pugh_DestroyPGExtras(pGExtras **PGExtras);
+
/*@@
@routine PUGH_SetupPGH
@@ -778,7 +782,6 @@ void DestroyPGH(pGH **GHin)
pGH *GH;
cGroup pgroup;
int i;
- int didit;
int variable;
int group;
int this_var;
@@ -786,11 +789,10 @@ void DestroyPGH(pGH **GHin)
GH = *GHin;
#ifdef MPI
+ CACTUS_MPI_ERROR(MPI_Type_free (&GH->pugh_mpi_complex));
CACTUS_MPI_ERROR(MPI_Comm_free(&(GH->PUGH_COMM_WORLD)));
#endif
- didit = 0;
-
/* Great. Now go about the work of destroying me. */
variable = 0;
@@ -806,28 +808,34 @@ void DestroyPGH(pGH **GHin)
for (this_var = 0; this_var < pgroup.numvars; this_var++, variable++)
{
- switch(pgroup.grouptype)
+ for(i = 0; i < pgroup.numtimelevels; i++)
{
- case GROUP_GF:
- for(i = 0; i < pgroup.numtimelevels; i++)
- {
+ switch(pgroup.grouptype)
+ {
+ case GROUP_GF:
DestroyPGF(GH, &(((pGF ***)GH->variables)[variable][i]));
- }
- break;
- case CCTK_ARRAY:
- CCTK_WARN(1,"Need to add code for Destroying an Pugh array");
- break;
- case GROUP_SCALAR:
- for(i = 0; i < pgroup.numtimelevels; i++)
- {
+ break;
+ case CCTK_ARRAY:
+ DestroyPGA(&(((pGA ***)GH->variables)[variable][i]));
+ break;
+ case GROUP_SCALAR:
free(GH->variables[variable][i]);
- }
- break;
+ break;
+ }
}
free(GH->variables[variable]);
}
}
+ for (i=1;i<=GH->dim;i++)
+ {
+ pugh_DestroyConnectivity(&GH->Connectivity[i-1]);
+ pugh_DestroyPGExtras(&GH->GFExtras[i-1]);
+ }
+
+ free(GH->Connectivity);
+ free(GH->GFExtras);
+
free(GH->variables);
free(GH->lb[0]);
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)
}
}
-
-
-
-
diff --git a/src/pGF_PostRecv.c b/src/pGF_PostRecv.c
index e185890..26654cd 100644
--- a/src/pGF_PostRecv.c
+++ b/src/pGF_PostRecv.c
@@ -43,7 +43,7 @@ void pGF_PostRecv(pGH *GH, pGF *GF, int dir)
{
#ifdef MPI
int rtag;
- int mpi_type;
+ MPI_Datatype mpi_type;
MPI_Datatype *recv_dt;
/* Return if GF has no storage */