[ET Trac] [Einstein Toolkit] #1550: Carpet Timer object gives 0 the first time it is read

Einstein Toolkit trac-noreply at einsteintoolkit.org
Sat Feb 22 00:41:55 CST 2014


#1550: Carpet Timer object gives 0 the first time it is read
--------------------+-------------------------------------------------------
 Reporter:  hinder  |       Owner:  eschnett           
     Type:  defect  |      Status:  new                
 Priority:  major   |   Milestone:  ET_2014_05         
Component:  Carpet  |     Version:  development version
 Keywords:          |  
--------------------+-------------------------------------------------------
 The getTime method of the Carpet Timer object returns a value of 0 the
 first time it is read.  The following test demonstrates the problem:

 {{{
 SCHEDULE Timer_TestTimer at startup
 {
   LANG: C
 } "Test the timers"
 }}}

 {{{
 #include <unistd.h>
   extern "C"
   int Timer_TestTimer()
   {
     Timer timer("Test");
     timer.start();
     unsigned int reason = sleep(1);
     double val = timer.getTime();
     assert(reason != 0 || val > 0.5);
     timer.stop();
   }
 }}}

 This is a regression since the original version of the Timer class,
 possibly introduced during the move of the class from Carpet to Timers.  A
 symptom is that the evolution timer tree shows "inf" for the percentage of
 the total time the first time it is used, since the Evolve timer used to
 normalise the time values has been read as zero.

 The underlying Cactus timers do not suffer from this problem, so there is
 something wrong in the logic for the Timer class.  The following test
 passes:

 {{{
 SCHEDULE Timer_TestCactusTimers at startup
 {
   LANG: C
 } "Test the Cactus timers"
 }}}

 {{{
   extern "C"
   int Timer_TestCactusTimers()
   {
     int handle = CCTK_TimerCreate("TestTimer");
     cout << "handle == " << handle << endl;
     assert(handle >= 0);
     CCTK_TimerStartI (handle);
     unsigned int reason = sleep(1);
     CCTK_TimerStopI (handle);

     static cTimerData * timer = 0;
     if (not timer) timer = CCTK_TimerCreateData ();
     assert (timer);
     CCTK_TimerI (handle, timer);

     const cTimerVal* tv = CCTK_GetClockValue("gettimeofday", timer);
     assert(tv);

     double val = CCTK_TimerClockSeconds(tv);
     assert(reason != 0 || val > 0.5);

     return 0;
   }
 }}}

-- 
Ticket URL: <https://trac.einsteintoolkit.org/ticket/1550>
Einstein Toolkit <http://einsteintoolkit.org>
The Einstein Toolkit


More information about the Trac mailing list