diff options
author | eschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2012-05-08 16:17:32 +0000 |
---|---|---|
committer | eschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2012-05-08 16:17:32 +0000 |
commit | 5645fd9b058f0550de5464f9b1255e333d390f21 (patch) | |
tree | 93b896b018b30a8404e34ffe088885e6cb290e6d /src | |
parent | 286c8dbd8d4344f6258a2f47c188a25abf595af3 (diff) |
Add I/O timers to Cactus flesh
Add timers for each I/O method in the flesh.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@4816 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src')
-rw-r--r-- | src/IO/IOMethods.c | 27 | ||||
-rw-r--r-- | src/include/cctk_IOMethods.h | 3 |
2 files changed, 27 insertions, 3 deletions
diff --git a/src/IO/IOMethods.c b/src/IO/IOMethods.c index f18c84da..72230d09 100644 --- a/src/IO/IOMethods.c +++ b/src/IO/IOMethods.c @@ -10,6 +10,7 @@ /* #define DEBUG_IO 1 */ +#include <assert.h> #include <stdio.h> #include <stdlib.h> @@ -21,6 +22,7 @@ #include "cctk_FortranString.h" #include "cctk_WarnLevel.h" #include "cctk_IO.h" +#include "cctk_Timers.h" #include "util_String.h" static const char *rcsid = "$Header$"; @@ -108,6 +110,7 @@ int CCTKi_RegisterIOMethod (const char *thorn, const char *name) { int handle; struct IOMethod *new_method; + char *timername; /* Check that the method hasn't already been registered */ @@ -131,6 +134,13 @@ int CCTKi_RegisterIOMethod (const char *thorn, const char *name) new_method->TriggerOutput = DummyTriggerOutput; new_method->TimeToOutput = DummyTimeToOutput; + /* Create timer */ + Util_asprintf (&timername, "IO method %s", name); + assert (timername); + new_method->timer_handle = CCTK_TimerCreate (timername); + assert (new_method->timer_handle >= 0); + free (timername); + /* Remember how many methods there are */ num_methods++; } @@ -377,9 +387,14 @@ int CCTK_OutputVarAs (const cGH *GH, const char *var, const char *alias) for (handle = retval = 0; handle < num_methods; handle++) { method = (struct IOMethod *) Util_GetHandledData (IOMethods, handle); - if (method && method->OutputVarAs (GH, var, alias) == 0) + if (method) { - retval++; + CCTK_TimerStartI (method->timer_handle); + if (method->OutputVarAs (GH, var, alias) == 0) + { + retval++; + } + CCTK_TimerStopI (method->timer_handle); } } } @@ -712,7 +727,9 @@ int CactusDefaultOutputGH (const cGH *GH) method = (struct IOMethod *) Util_GetHandledData (IOMethods, handle); if (method) { + CCTK_TimerStartI (method->timer_handle); retval += method->OutputGH (GH); + CCTK_TimerStopI (method->timer_handle); } } } @@ -767,13 +784,17 @@ int CactusDefaultOutputVarAsByMethod (const cGH *GH, const char *alias) { int retval; + void *tmp; struct IOMethod *method; - Util_GetHandle (IOMethods, methodname, (void **) &method); + Util_GetHandle (IOMethods, methodname, &tmp); + method = tmp; if (method) { + CCTK_TimerStartI (method->timer_handle); retval = method->OutputVarAs (GH, var, alias); + CCTK_TimerStopI (method->timer_handle); } else { diff --git a/src/include/cctk_IOMethods.h b/src/include/cctk_IOMethods.h index fc2916cb..1bbf936d 100644 --- a/src/include/cctk_IOMethods.h +++ b/src/include/cctk_IOMethods.h @@ -23,6 +23,9 @@ struct IOMethod int (*OutputVarAs) (const cGH *GH, const char *vname, const char *alias); int (*TriggerOutput) (const cGH *GH, int vindex); int (*TimeToOutput) (const cGH *GH, int vindex); + + /* Timer data */ + int timer_handle; }; #define CCTK_RegisterIOMethod(a) CCTKi_RegisterIOMethod (CCTK_THORNSTRING, a) |