From 555ff0dd99d1d42e1169516733e79e12e37d22d6 Mon Sep 17 00:00:00 2001 From: goodale Date: Thu, 21 Oct 1999 13:17:00 +0000 Subject: Changes for new timer stuff. Currently have #if 0ed out all references to old timers in thorns and flesh to act as placeholders for new timer stuff. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@1079 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/include/CactusTimers.h | 27 ++-- src/include/cctk_Flesh.h | 2 +- src/main/CactusDefaultEvolve.c | 18 ++- src/main/CactusDefaultInitialise.c | 6 +- src/main/InitialiseDataStructures.c | 3 +- src/util/CactusTimers.c | 282 ++++++++++++++++++++++++------------ 6 files changed, 223 insertions(+), 115 deletions(-) diff --git a/src/include/CactusTimers.h b/src/include/CactusTimers.h index f5f75531..31d4c9bc 100644 --- a/src/include/CactusTimers.h +++ b/src/include/CactusTimers.h @@ -15,17 +15,6 @@ /* Typedefs */ -typedef struct -{ - double basic[4]; -} cInternalTimer; - -typedef struct -{ - cInternalTimer total; - cInternalTimer last; -} cTimer; - typedef struct { void *(*create)(int); @@ -44,13 +33,17 @@ typedef struct extern "C" { #endif -cTimer *CactusNewTimer(void); - -void CactusStartTimer(cTimer *timer); -void CactusStopTimer(cTimer *timer); -void CactusResetTimer(cTimer *timer); - int CCTK_TimerRegister(const char *name, t_TimerFuncs *functions); +void CCTK_TimerDestroy(const char *name); +void CCTK_TimerDestroyI(int this_timer); +void CCTK_TimerStart(const char *name); +void CCTK_TimerStartI(int this_timer); +void CCTK_TimerStop(const char *name); +void CCTK_TimerStopI(int this_timer); +void CCTK_TimerReset(const char *name); +void CCTK_TimerResetI(int this_timer); +char *CCTK_TimerGet(const char *name); +char *CCTK_TimerGetI(int this_timer); #ifdef __cplusplus } diff --git a/src/include/cctk_Flesh.h b/src/include/cctk_Flesh.h index 7a3d6b3d..6b0c80b8 100644 --- a/src/include/cctk_Flesh.h +++ b/src/include/cctk_Flesh.h @@ -69,7 +69,7 @@ typedef struct cGH **GH; unsigned int nGHs; - cTimer *timer[3]; + /* cTimer *timer[3];*/ } tFleshConfig; diff --git a/src/main/CactusDefaultEvolve.c b/src/main/CactusDefaultEvolve.c index 41260f56..7ee8d090 100644 --- a/src/main/CactusDefaultEvolve.c +++ b/src/main/CactusDefaultEvolve.c @@ -118,8 +118,10 @@ int CactusDefaultEvolve(tFleshConfig *config) CCTK_PRINTSEPARATOR #endif - +#if 0 CactusStartTimer(config->timer[OUTPUT]); +#endif + /*** Call OUTPUT for this GH (this routine ***/ /*** checks if output is necessary) and makes ***/ /*** an rfrTraverse with CCTK_ANALYSIS ***/ @@ -129,13 +131,12 @@ int CactusDefaultEvolve(tFleshConfig *config) CCTK_OutputGH(config->GH[convergence_level]); } EndForallConvLevels; - - CactusStopTimer(config->timer[OUTPUT]); - +#if 0 + CactusStopTimer(config->timer[OUTPUT]); CactusStartTimer(config->timer[EVOLUTION]); - +#endif /* CCTK_InfoHeader(config); */ @@ -175,7 +176,9 @@ int CactusDefaultEvolve(tFleshConfig *config) EndForallConvLevels; /* Output perhaps */ +#if 0 CactusStartTimer(config->timer[OUTPUT]); +#endif /*** Call OUTPUT for this GH (this routine ***/ /*** checks if output is necessary) and makes ***/ /*** an rfrTraverse with CCTK_ANALYSIS ***/ @@ -186,8 +189,9 @@ int CactusDefaultEvolve(tFleshConfig *config) } EndForallConvLevels; +#if 0 CactusStopTimer(config->timer[OUTPUT]); - +#endif #if 0 ConvergenceReport(config->GH, iteration); @@ -200,7 +204,9 @@ int CactusDefaultEvolve(tFleshConfig *config) } /*** END OF MAIN ITERATION LOOP ***/ +#if 0 CactusStopTimer(config->timer[EVOLUTION]); +#endif return 0; } diff --git a/src/main/CactusDefaultInitialise.c b/src/main/CactusDefaultInitialise.c index 0960f51e..5befd58a 100644 --- a/src/main/CactusDefaultInitialise.c +++ b/src/main/CactusDefaultInitialise.c @@ -48,11 +48,13 @@ int CactusDefaultInitialise(tFleshConfig *config) cGH *GH; int convergence_level; +#if 0 CactusResetTimer(config->timer[INITIALISATION]); CactusResetTimer(config->timer[EVOLUTION]); CactusResetTimer(config->timer[ELLIPTIC]); CactusStartTimer(config->timer[INITIALISATION]); +#endif convergence_level = 0; while((GH = CCTK_SetupGH(config, convergence_level))) @@ -64,8 +66,10 @@ int CactusDefaultInitialise(tFleshConfig *config) convergence_level++; }; +#if 0 CactusStopTimer(config->timer[INITIALISATION]); - +#endif + return 0; } diff --git a/src/main/InitialiseDataStructures.c b/src/main/InitialiseDataStructures.c index 28a08fd5..ad656c03 100644 --- a/src/main/InitialiseDataStructures.c +++ b/src/main/InitialiseDataStructures.c @@ -44,10 +44,11 @@ int InitialiseDataStructures(tFleshConfig *ConfigData) ConfigData->nGHs = 0; ConfigData->GH = NULL; +#if 0 ConfigData->timer[INITIALISATION] = CactusNewTimer(); ConfigData->timer[EVOLUTION] = CactusNewTimer(); ConfigData->timer[ELLIPTIC] = CactusNewTimer(); - +#endif /* Initialise appropriate subsystems. */ diff --git a/src/util/CactusTimers.c b/src/util/CactusTimers.c index 5ba8d47b..308bd355 100644 --- a/src/util/CactusTimers.c +++ b/src/util/CactusTimers.c @@ -17,36 +17,16 @@ static char *rcsid = "$Header$"; - - -cTimer *CactusNewTimer(void) -{ - cTimer *timer; - - timer = (cTimer*) malloc(sizeof(cTimer)); - - return timer; -} - - - -void CactusStartTimer(cTimer *timer) -{ -} - -void CactusStopTimer(cTimer *timer) -{ -} - -void CactusResetTimer(cTimer *timer) -{ -} - typedef struct { void **data; } t_Timer; +static void CCTKi_TimerDestroy(int this_timer, t_Timer *timer); +static void CCTKi_TimerStart(int this_timer, t_Timer *timer); +static void CCTKi_TimerStop(int this_timer, t_Timer *timer); +static void CCTKi_TimerReset(int this_timer, t_Timer *timer); +static char *CCTKi_TimerGet(int this_timer, t_Timer *timer); static int n_timertypes = 0; static cHandledData *handles = NULL; @@ -173,25 +153,70 @@ void CCTK_TimerDestroy(const char *name) if(this_timer = Util_GetHandle(timers, name, (void **)&timer)) { - if(timer) + CCTKi_TimerDestroy(this_timer, timer); + } +} + + /*@@ + @routine CCTK_TimerDestroyI + @date Thu Oct 21 14:12:51 1999 + @author Tom Goodale + @desc + Destroys a timer by its handle index + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +void CCTK_TimerDestroyI(int this_timer) +{ + t_Timer *timer; + + if(timer = Util_GetHandledData(timers, this_timer)) + { + CCTKi_TimerDestroy(this_timer, timer); + } +} + + /*@@ + @routine CCTKi_TimerDestroy + @date Thu Oct 21 14:14:58 1999 + @author Tom Goodale + @desc + Internal function which destroys a timer. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ +static void CCTKi_TimerDestroy(int this_timer, t_Timer *timer) +{ + t_TimerFuncs *funcs; + int handle; + + if(timer) + { + if(timer->data) { - if(timer->data) + /* Destroy the timer info for this timer */ + for(handle = 0; handle < n_timertypes; handle++) { - /* Destroy the timer info for this timer */ - for(handle = 0; handle < n_timertypes; handle++) - { - funcs = (t_TimerFuncs *)Util_GetHandledData(handles, handle); - funcs->destroy(this_timer, timer->data[handle]); - } - free(timer->data); - free(timer); - Util_DeleteHandle(timers, this_timer); + funcs = (t_TimerFuncs *)Util_GetHandledData(handles, handle); + funcs->destroy(this_timer, timer->data[handle]); } + free(timer->data); + free(timer); + Util_DeleteHandle(timers, this_timer); } } } - /*@@ @routine CCTK_TimerStart @date Wed Sep 1 10:10:38 1999 @@ -209,22 +234,38 @@ void CCTK_TimerDestroy(const char *name) void CCTK_TimerStart(const char *name) { t_Timer *timer; - t_TimerFuncs *funcs; int this_timer; - int handle; if(this_timer = Util_GetHandle(timers, name, (void **)&timer)) { - if(timer) + CCTKi_TimerStart(this_timer, timer); + } +} + +void CCTK_TimerStartI(int this_timer) +{ + t_Timer *timer; + + if(timer = Util_GetHandledData(timers, this_timer)) + { + CCTKi_TimerStart(this_timer, timer); + } +} + +static void CCTKi_TimerStart(int this_timer, t_Timer *timer) +{ + t_TimerFuncs *funcs; + int handle; + + if(timer) + { + if(timer->data) { - if(timer->data) + /* Start the timer info for this timer */ + for(handle = 0; handle < n_timertypes; handle++) { - /* Start the timer info for this timer */ - for(handle = 0; handle < n_timertypes; handle++) - { - funcs = (t_TimerFuncs *)Util_GetHandledData(handles, handle); - funcs->start(this_timer, timer->data[handle]); - } + funcs = (t_TimerFuncs *)Util_GetHandledData(handles, handle); + funcs->start(this_timer, timer->data[handle]); } } } @@ -247,22 +288,38 @@ void CCTK_TimerStart(const char *name) void CCTK_TimerStop(const char *name) { t_Timer *timer; - t_TimerFuncs *funcs; int this_timer; - int handle; if(this_timer = Util_GetHandle(timers, name, (void **)&timer)) { - if(timer) + CCTKi_TimerStop(this_timer, timer); + } +} + +void CCTK_TimerStopI(int this_timer) +{ + t_Timer *timer; + + if(timer = Util_GetHandledData(timers, this_timer)) + { + CCTKi_TimerStop(this_timer, timer); + } +} + +static void CCTKi_TimerStop(int this_timer, t_Timer *timer) +{ + t_TimerFuncs *funcs; + int handle; + + if(timer) + { + if(timer->data) { - if(timer->data) + /* Start the timer info for this timer */ + for(handle = 0; handle < n_timertypes; handle++) { - /* Stop the timer info for this timer */ - for(handle = 0; handle < n_timertypes; handle++) - { - funcs = (t_TimerFuncs *)Util_GetHandledData(handles, handle); - funcs->stop(this_timer, timer->data[handle]); - } + funcs = (t_TimerFuncs *)Util_GetHandledData(handles, handle); + funcs->stop(this_timer, timer->data[handle]); } } } @@ -285,22 +342,38 @@ void CCTK_TimerStop(const char *name) void CCTK_TimerReset(const char *name) { t_Timer *timer; - t_TimerFuncs *funcs; int this_timer; - int handle; if(this_timer = Util_GetHandle(timers, name, (void **)&timer)) { - if(timer) + CCTKi_TimerReset(this_timer, timer); + } +} + +void CCTK_TimerResetI(int this_timer) +{ + t_Timer *timer; + + if(timer = Util_GetHandledData(timers, this_timer)) + { + CCTKi_TimerReset(this_timer, timer); + } +} + +static void CCTKi_TimerReset(int this_timer, t_Timer *timer) +{ + t_TimerFuncs *funcs; + int handle; + + if(timer) + { + if(timer->data) { - if(timer->data) + /* Start the timer info for this timer */ + for(handle = 0; handle < n_timertypes; handle++) { - /* Start the timer info for this timer */ - for(handle = 0; handle < n_timertypes; handle++) - { - funcs = (t_TimerFuncs *)Util_GetHandledData(handles, handle); - funcs->reset(this_timer, timer->data[handle]); - } + funcs = (t_TimerFuncs *)Util_GetHandledData(handles, handle); + funcs->reset(this_timer, timer->data[handle]); } } } @@ -323,45 +396,76 @@ void CCTK_TimerReset(const char *name) char *CCTK_TimerGet(const char *name) { t_Timer *timer; - t_TimerFuncs *funcs; int this_timer; + char *retval; + + if(this_timer = Util_GetHandle(timers, name, (void **)&timer)) + { + retval = CCTKi_TimerGet(this_timer, timer); + } + else + { + retval = NULL; + } + + return retval; + +} + +char *CCTK_TimerGetI(int this_timer) +{ + t_Timer *timer; + char *retval; + + if(timer = Util_GetHandledData(timers, this_timer)) + { + retval = CCTKi_TimerGet(this_timer, timer); + } + else + { + retval = NULL; + } + + return retval; +} + +static char *CCTKi_TimerGet(int this_timer, t_Timer *timer) +{ + t_TimerFuncs *funcs; int handle; char this_val[100]; char *retval; char *temp; int retlength; + retlength = 0; retval = NULL; - if(this_timer = Util_GetHandle(timers, name, (void **)&timer)) + if(timer) { - if(timer) + if(timer->data) { - if(timer->data) + /* Start the timer info for this timer */ + for(handle = 0; handle < n_timertypes; handle++) { - /* Start the timer info for this timer */ - for(handle = 0; handle < n_timertypes; handle++) - { - funcs = (t_TimerFuncs *)Util_GetHandledData(handles, handle); - sprintf(this_val, "%lf", funcs->get(this_timer, timer->data[handle])); - retlength += 2+strlen(this_val); - temp = realloc(retval, retlength); - if(temp) - { - retval = temp; - - /* If this isn't the first one, add a couple of spaces. */ - if(retlength > 2+strlen(this_val)) strcat(retval, " "); - - strcat(retval, this_val); - } - } + funcs = (t_TimerFuncs *)Util_GetHandledData(handles, handle); + sprintf(this_val, "%lf", funcs->get(this_timer, timer->data[handle])); + retlength += 2+strlen(this_val); + temp = realloc(retval, retlength); + if(temp) + { + retval = temp; + + /* If this isn't the first one, add a couple of spaces. */ + if(retlength > 2+strlen(this_val)) strcat(retval, " "); + + strcat(retval, this_val); + } } } } return retval; - } -- cgit v1.2.3