aboutsummaryrefslogtreecommitdiff
path: root/src/DumpGH.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/DumpGH.c')
-rw-r--r--src/DumpGH.c207
1 files changed, 154 insertions, 53 deletions
diff --git a/src/DumpGH.c b/src/DumpGH.c
index 9007189..2566d0c 100644
--- a/src/DumpGH.c
+++ b/src/DumpGH.c
@@ -18,6 +18,7 @@ static char *rcsid = "$Id$";
#include "cctk.h"
#include "cctk_parameters.h"
+#include "cctk_ParameterFunctions.h"
#include "CactusBase/IOUtil/src/ioGH.h"
#include "ioFlexGH.h"
@@ -131,7 +132,82 @@ void IOFlexIO_InitialDataDumpGH (cGH *GH)
}
-void IOFlexIO_IEEEIOStructDump (cGH *GH, IOFile iof)
+void IOFlexIO_DumpParams (cGH *GH, IOFile iof)
+{
+ int first;
+ const char *param;
+
+
+ first = 1;
+ while ((param = ParameterWalk (first, NULL)) != NULL) {
+ char *impl, *name, *msg;
+
+ first = 0;
+
+ if (Util_SplitString (&impl, &name, param, "::") != 0) {
+
+ msg = (char *) malloc (100 + strlen (param));
+ sprintf (msg, "Cannot dump parameter '%s' (SplitString failed)", param);
+ CCTK_WARN (2, msg);
+ free (msg);
+
+ } else {
+ int type;
+ void *data;
+
+ data = ParameterGet (name, CCTK_ImplementationThorn (impl), &type);
+ if (data == NULL) {
+
+ msg = (char *) malloc (100 + strlen (param));
+ sprintf(msg, "Cannot dump parameter '%s' (ParameterGet failed)", param);
+ CCTK_WARN (2, msg);
+ free (msg);
+
+ } else {
+ CCTK_INT4 i_tmp;
+
+ switch (type) {
+ case PARAMETER_KEYWORD:
+ case PARAMETER_STRING:
+ case PARAMETER_SENTENCE:
+ CACTUS_IEEEIO_ERROR (IOwriteAttribute (iof, param, FLEXIO_CHAR,
+ strlen (*(char **) data) + 1, *(char **)data));
+ break;
+
+ case PARAMETER_INT:
+ case PARAMETER_BOOLEAN:
+ /* CCTK_INTs are stored as 4 byte integers */
+ i_tmp = (CCTK_INT4) (*(CCTK_INT *) data);
+ CACTUS_IEEEIO_ERROR (IOwriteAttribute (iof, param, FLEXIO_INT4, 1,
+ &i_tmp));
+ break;
+
+ case PARAMETER_REAL:
+ CACTUS_IEEEIO_ERROR (IOwriteAttribute (iof, param, FLEXIO_REAL, 1,
+ data));
+ break;
+
+ default:
+ msg = (char *) malloc (100 + strlen (param));
+ sprintf (msg, "Cannot dump parameter '%s' (unknown type)", param);
+ CCTK_WARN (2, msg);
+ free (msg);
+ break;
+ }
+ }
+
+ free (impl);
+ free (name);
+
+ }
+
+ free ((void *) param);
+
+ } /* end of loop walking over all parameters */
+}
+
+
+void IOFlexIO_DumpGHExtensions (cGH *GH, IOFile iof)
{
CCTK_INT4 i_temp;
CCTK_REAL d_temp;
@@ -196,28 +272,20 @@ void IOFlexIO_DumpGH (cGH *GH, int called_from)
int old_downsample_x, old_downsample_y, old_downsample_z;
int old_out_single;
ioGH *ioUtilGH;
-#if 0
- cTimer total_time, write_time;
-#endif
+ flexioGH *myGH;
+ int total_time_handle, write_time_handle;
static char **dumpfnames = NULL; /* dump filename ring buffer */
static int findex = 0; /* index into ring buffer */
+ /* Get the handles for IOUtil and IOFlexIO extensions */
+ ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
+ myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")];
+
/* allocate the ring buffer for filenames */
if (! dumpfnames)
dumpfnames = (char **) calloc (checkpoint_keep, sizeof (char *));
-#if 0
- /* initialize timers */
- CactusResetTimer (&total_time);
- CactusResetTimer (&write_time);
-
- CactusStartTimer (&total_time);
-#endif
-
- /* Get the handle for IOUtil xtensions */
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
-
/* disable downsampling after saving original downsampling params */
old_downsample_x = ioUtilGH->downsample_x;
old_downsample_y = ioUtilGH->downsample_y;
@@ -228,6 +296,10 @@ void IOFlexIO_DumpGH (cGH *GH, int called_from)
old_out_single = ioUtilGH->out_single;
ioUtilGH->out_single = 0;
+ /* start the total timer */
+ if (print_timing_info)
+ CCTK_TimerStartI (myGH->checkpointTotalTimer);
+
/* sync all groups */
for (index = 0; index < CCTK_NumGroups (); index++) {
char *gname = CCTK_GroupName (index);
@@ -257,24 +329,29 @@ void IOFlexIO_DumpGH (cGH *GH, int called_from)
} else
iof = (IOFile) NULL;
-#if 0
/* Great; Now start dumping away! */
- CactusResetTimer (&write_time);
- CactusStartTimer (&write_time);
-#endif
+
+ /* start timer for dumping parameters */
+ if (print_timing_info) {
+ CCTK_TimerResetI (myGH->dumpParamsTimer);
+ CCTK_TimerStartI (myGH->dumpParamsTimer);
+ }
if (verbose)
printf ("Dumping Params ...\n -- ");
/* first the parameters ... */
if (iof) {
-/*** FIXME ***/
-#if 0
if (out3D_parameters)
- IOFlexIO_IEEEIOparamDump (iof);
-#endif
- if (out3D_structures)
- IOFlexIO_IEEEIOStructDump (GH, iof);
+ IOFlexIO_DumpParams (GH, iof);
+ IOFlexIO_DumpGHExtensions (GH, iof);
+ }
+
+ /* stop parameter timer and start timer for dumping datasets */
+ if (print_timing_info) {
+ CCTK_TimerStopI (myGH->dumpParamsTimer);
+ CCTK_TimerResetI (myGH->dumpVarsTimer);
+ CCTK_TimerStartI (myGH->dumpVarsTimer);
}
wrotech = 0;
@@ -283,8 +360,7 @@ void IOFlexIO_DumpGH (cGH *GH, int called_from)
for (index = 0; index < CCTK_NumVars (); index++) {
/* let only variables pass which have storage assigned */
- if (! CCTK_QueryGroupStorageI (GH,
- CCTK_GroupIndexFromVarI (index)))
+ if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index)))
continue;
if (verbose) {
@@ -308,34 +384,22 @@ void IOFlexIO_DumpGH (cGH *GH, int called_from)
IOFlexIO_DumpVar (GH, index, timelevel, iof);
} /* end of loop over all variables */
-#if 0
- CactusStopTimer (&write_time);
-#endif
+ /* stop timer for dumping datasets */
+ if (print_timing_info)
+ CCTK_TimerStopI (myGH->dumpVarsTimer);
CACTUS_IEEEIO_ERROR (IOclose (iof));
- if (verbose)
-#if 0
- printf ("\nTime to write: %f sec (%f sec per Grid Func)\n",
-/*** FIXME: choose right component of basic[] ***/
- write_time.total.basic [0],
- write_time.total.basic [0] / CCTK_NumVars ());
-#endif
-#ifndef WIN32
- /* PW: This should work on WIN32 also, since it
- is in stdio.h. Someone should check this
- if/when we go into WIN32 production.
- */
if (CCTK_MyProc (GH) == ioUtilGH->ioproc) {
if (rename (tmpfname, dumpfname)) {
char msg [512];
- sprintf (msg, "Could not rename temporary checkpoint file %s to %s", tmpfname, dumpfname);
+ sprintf (msg, "Could not rename temporary checkpoint file %s to %s",
+ tmpfname, dumpfname);
CCTK_WARN (0, msg);
/* should not return here */
}
}
-#endif
/* delete the oldest dumpfile if checkpoint_keep_all isn't set
and put the new filename into the ring buffer */
@@ -355,15 +419,52 @@ void IOFlexIO_DumpGH (cGH *GH, int called_from)
ioUtilGH->downsample_y = old_downsample_y;
ioUtilGH->downsample_z = old_downsample_z;
-#if 0
- CactusStopTimer (&total_time);
-#endif
+ /* stop total checkpoint timer and print timing info */
+ if (print_timing_info) {
+ t_TimerInfo *info;
- if (verbose) {
-#if 0
-/*** FIXME: choose right component of basic[] ***/
- printf ("Time to checkpoint: %f sec\n", total_time.total.basic [0]);
- printf ("------------------------------------------------------------\n");
-#endif
+ CCTK_TimerStopI (myGH->checkpointTotalTimer);
+
+ printf ("%s timing information for checkpointing:\n", CCTK_THORNSTRING);
+
+ info = CCTK_TimerCreateInfo ();
+ if (info) {
+
+ if (myGH->dumpParamsTimer >= 0) {
+ CCTK_TimerGetI (myGH->dumpParamsTimer, info);
+{
+/*** FIXME: select right timers and value types !!! ***/
+
+#include <assert.h>
+assert (info->n_vals >= 2);
+assert (info->vals [0].type == val_double && info->vals [1].type == val_double);
+}
+ printf (" Time to dump parameters: %5.1f sec (GetTimeOfDay), "
+ "%5.1f sec (GetrUsage)\n",
+ info->vals [0].val.d, info->vals [1].val.d);
+ }
+
+ if (myGH->dumpVarsTimer >= 0) {
+ CCTK_TimerGetI (myGH->dumpVarsTimer, info);
+ printf (" Time to dump datasets: %5.1f sec (GetTimeOfDay), "
+ "%5.1f sec (GetrUsage)\n",
+ info->vals [0].val.d, info->vals [1].val.d);
+ }
+
+ if (myGH->checkpointTotalTimer >= 0) {
+ CCTK_TimerGetI (myGH->checkpointTotalTimer, info);
+ printf (" Total time to checkpoint: %5.1f sec (GetTimeOfDay), "
+ "%5.1f sec (GetrUsage)\n",
+ info->vals [0].val.d, info->vals [1].val.d);
+ }
+
+ CCTK_TimerDestroyInfo (info);
+ } else
+ CCTK_WARN (1, "Couldn't create timer info structure ! No timing output "
+ "available.");
+
+ printf ("----------------------------------------------------------------"
+ "-----------\n");
}
+
}