aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--schedule.ccl7
-rw-r--r--src/Comm.c45
-rw-r--r--src/GHExtension.c7
-rw-r--r--src/SetupPGH.c10
-rw-r--r--src/SetupPGV.c9
-rw-r--r--src/include/pughi.h5
6 files changed, 59 insertions, 24 deletions
diff --git a/schedule.ccl b/schedule.ccl
index 860af1e..3544f6d 100644
--- a/schedule.ccl
+++ b/schedule.ccl
@@ -9,4 +9,9 @@ schedule PUGH_Startup at STARTUP as Driver_Startup
schedule PUGH_Report at BASEGRID
{
LANG:C
-} "Report on PUGH set up" \ No newline at end of file
+} "Report on PUGH set up"
+
+schedule PUGH_Terminate at TERMINATE as Driver_Terminate
+{
+ LANG:C
+} "Termination routine"
diff --git a/src/Comm.c b/src/Comm.c
index 31e2350..c932ce9 100644
--- a/src/Comm.c
+++ b/src/Comm.c
@@ -31,8 +31,6 @@ CCTK_FILEVERSION(CactusPUGH_PUGH_Comm_c)
static int PUGH_EnableGArrayGroupComm(pGH *pughGH,
int first_var,
int commflag);
-static int PUGH_DisableGArrayGroupComm(pGH *pughGH,
- int first_var);
static int PUGH_EnableComm(pGH *pughGH,
pComm *comm,
int commflag);
@@ -370,8 +368,8 @@ static int PUGH_EnableGArrayGroupComm(pGH *pughGH,
@history
@endhistory
@@*/
-static int PUGH_DisableGArrayGroupComm(pGH *pughGH,
- int first_var)
+int PUGH_DisableGArrayGroupComm(pGH *pughGH,
+ int first_var)
{
pGA *GA; /* first variable in group */
@@ -587,29 +585,38 @@ static int PUGH_DisableComm(pGH *pughGH,
fflush (stdout);
#endif
- /* free memory for communication buffers: 2 faces per direction */
- for (i = 0; i < 2 * GA->extras->dim; i++)
+ if (comm->commflag != PUGH_NOCOMM)
{
- if (comm->send_buffer[i])
+ /* free memory for communication buffers: 2 faces per direction */
+ for (i = 0; i < 2 * GA->extras->dim; i++)
{
- if (comm->sreq[i] != MPI_REQUEST_NULL)
+ if (comm->send_buffer[i])
{
- CACTUS_MPI_ERROR(MPI_Request_free(&comm->sreq[i]));
+ if (comm->sreq[i] != MPI_REQUEST_NULL)
+ {
+ CACTUS_MPI_ERROR(MPI_Request_free(&comm->sreq[i]));
+ }
+ free(comm->send_buffer[i]);
+ comm->send_buffer[i] = NULL;
}
- free(comm->send_buffer[i]);
- comm->send_buffer[i] = NULL;
- }
- if (comm->recv_buffer[i])
- {
- free(comm->recv_buffer[i]);
- comm->recv_buffer[i] = NULL;
+ if (comm->recv_buffer[i])
+ {
+ free(comm->recv_buffer[i]);
+ comm->recv_buffer[i] = NULL;
+ }
+
+ comm->buffer_sz[i] = 0;
}
- comm->buffer_sz[i] = 0;
+ comm->commflag = PUGH_NOCOMM;
+ }
+ else
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Communication already disabled for group of %d vars "
+ "and first var '%s'", comm->n_vars, GA->name);
}
-
- comm->commflag = PUGH_NOCOMM;
#endif /* CCTK_MPI */
return (1);
diff --git a/src/GHExtension.c b/src/GHExtension.c
index 23627ff..ebb8686 100644
--- a/src/GHExtension.c
+++ b/src/GHExtension.c
@@ -299,8 +299,11 @@ int PUGH_InitGH(cGH *GH)
int PUGH_ScheduleTraverseGH(cGH *GH,
const char *where)
{
- PUGH_InitGHBasics (GH);
- PUGH_InitGHVariables (GH);
+ if (strcmp ("CCTK_SHUTDOWN", where) != 0)
+ {
+ PUGH_InitGHBasics (GH);
+ PUGH_InitGHVariables (GH);
+ }
return CCTK_ScheduleTraverse(where, GH, NULL);
}
diff --git a/src/SetupPGH.c b/src/SetupPGH.c
index 3a49dce..1a5ae40 100644
--- a/src/SetupPGH.c
+++ b/src/SetupPGH.c
@@ -179,6 +179,16 @@ int pGH_SetupnProcs(pGH *GH, int dim)
}
+int PUGH_Terminate (cGH *GH)
+{
+ pGH *pughGH = PUGH_pGH (GH);
+
+
+ PUGH_DestroyPGH (&pughGH);
+ return (0);
+}
+
+
/*@@
@routine PUGH_DestroyPGH
@date Thu Aug 21 11:38:10 1997
diff --git a/src/SetupPGV.c b/src/SetupPGV.c
index d27ace0..d655438 100644
--- a/src/SetupPGV.c
+++ b/src/SetupPGV.c
@@ -1384,6 +1384,7 @@ pComm *PUGH_SetupGArrayComm(pGH *pughGH,
@@*/
void PUGH_DestroyComm(pComm **comm)
{
+
free ((*comm)->buffer_sz);
free ((*comm)->send_buffer);
free ((*comm)->recv_buffer);
@@ -1491,10 +1492,18 @@ void PUGH_DestroyGArray(pGA **GA)
/* destroy group comm buffers only once per group */
if((*GA)->groupcomm && (*GA)->groupcomm->first_var == (*GA)->id)
{
+ if ((*GA)->groupcomm->commflag != PUGH_NOCOMM)
+ {
+ PUGH_DisableGArrayGroupComm((pGH *) (*GA)->parent, (*GA)->id);
+ }
PUGH_DestroyComm(&(*GA)->groupcomm);
}
if((*GA)->comm)
{
+ if ((*GA)->comm->commflag != PUGH_NOCOMM)
+ {
+ PUGH_DisableGArrayComm(*GA);
+ }
PUGH_DestroyComm(&(*GA)->comm);
}
free((*GA)->name);
diff --git a/src/include/pughi.h b/src/include/pughi.h
index f6fdf1c..6847bdc 100644
--- a/src/include/pughi.h
+++ b/src/include/pughi.h
@@ -144,13 +144,14 @@ int PUGH_EnableGArrayDataStorage(pGA *GA,
int padding_size,
int padding_address_spacing);
-int PUGH_DisableGArrayDataStorage(pGA *GA);
-
int PUGH_EnableGArrayComm(pGA *GA,
int commflag);
int PUGH_DisableGArrayComm(pGA *GA);
+int PUGH_DisableGArrayGroupComm(pGH *pughGH,
+ int first_var);
+
int PUGH_SyncGArray(pGA *GA);
#ifdef CCTK_MPI