13 int timecheck(
int whichlocation,
SFTYPE comptstart)
16 static long long int nsteplasttime;
17 static long long int startnstep;
18 long long int diffnstep;
24 int numzones,numcompzones;
28 FTYPE var_ete,var_wt,var_tuperhr,var_eff,var_fracdiagtime;
29 long long int var_zc,var_tzc;
31 FTYPE var_lete,var_lwt,var_ltuperhr,var_leff,var_lfracdiagtime;
32 long long int var_lzc,var_ltzc;
35 static SFTYPE diagwalltimecumulative=0.0,localdiagwalltimecumulative=0.0;
43 static time_t timestart,timestop;
44 static time_t gtimestart,gtimestop,checktime;
46 static time_t diagtimestart,diagtimestop;
47 static time_t diaggtimestart,diaggtimestop;
49 static struct timeval timestart,timestop, gtimestart,gtimestop,checktime;
GETTIMEZONETYPE tz;
51 static struct timeval diagtimestart,diagtimestop, diaggtimestart,diaggtimestop;
GETTIMEZONETYPE diagtz;
52 #elif((TIMEMETHOD==2)||(TIMEMETHOD==3))
53 static clock_t timestart,timestop, gtimestart,gtimestop,checktime;
55 static clock_t diagtimestart,diagtimestop, diaggtimestart,diaggtimestop;
57 static SFTYPE walltime=0,walltimelocal=0,walltot=0;
59 static clock_t usertmstimestart,usertmstimestop,systmstimestart,systmstimestop;
60 static struct timeval wttimestart,wttimestop;
62 static SFTYPE diagwalltime=0,diagwalltimelocal=0,diagwalltot=0;
63 static clock_t diagusertmstimestart,diagusertmstimestop,diagsystmstimestart,diagsystmstimestop;
64 static struct timeval diagwttimestart,diagwttimestop;
76 #if(GETTIMEOFDAYPROBLEM==1)
86 diffnstep=
nstep-startnstep;
96 myustimes2(&usertmstimestart,&systmstimestart);
102 myustimes2(&usertmstimestop,&systmstimestop);
106 if(walltime<1
E-5) walltime=1
E-5;
119 myustimes2(&usertmstimestart,&systmstimestart);
127 myustimes2(&usertmstimestop,&systmstimestop);
134 myustimes2(&diagusertmstimestart,&diagsystmstimestart);
140 myustimes2(&diagusertmstimestop,&diagsystmstimestop);
146 diagwalltimecumulative += diagwallstep;
148 localdiagwalltimecumulative += diagwallstep;
157 if((diffnstep==1)||( (!(diffnstep%
NTIMECHECK))) ){
163 dualfprintf(
fail_file,
"Warning: walltime=%21.15g < %21.15g\n",walltime,
SMALL);
168 diagwalltime=diagwalltimecumulative;
213 diagwalltime=(
SFTYPE) (diagwalltimecumulative);
217 diagwalltimelocal=(
SFTYPE) (localdiagwalltimecumulative);
218 if(diagwalltimelocal<
SMALL) diagwalltimelocal=
SMALL;
226 numcompzones=numzones;
236 var_ete=((
tf-
t+1.0E-6)/(
t-comptstart+1.0
E-6)*walltime*
SEC2HOUR);
238 var_zc=(int)((
FTYPE)(numzones)*(
FTYPE)(diffnstep)/walltime);
239 var_tzc=(int)((
FTYPE)(numcompzones)*(
FTYPE)(diffnstep)/walltime);
240 var_tuperhr=((
t-comptstart)/(walltime*SEC2HOUR));
243 var_fracdiagtime = diagwalltime/walltime;
245 var_lete=((
tf-
t+1.0E-6)/(
t-tlasttime+1.0
E-6)*walltimelocal*
SEC2HOUR);
249 var_ltuperhr=((
t-tlasttime)/(walltimelocal*SEC2HOUR));
252 var_lfracdiagtime = diagwalltimelocal/walltimelocal;
254 myfprintf(fileit,
"#t ete n wt zc tzc tu/hr Eff FracDiag lete ln lwt lzc ltzc ltu/hr lEff lFracDiag \n");
255 myfprintf(fileit,
"%15.10g %15.10g %10ld %15.10g %10lld %10lld %10.5g %10.5g %10.5g"
256 " %15.10g %5d %15.10g %10lld %10lld %10.5g %10.5g %10.5g\n"
282 #define DIAGFACTOR (10.0)
292 if((walltimelocal-diagwalltimelocal)/(
t-tlasttime) < DIAGFACTOR*diagwalltimelocal/
DTdumpgen[ii]){
294 myfprintf(fileit,
"#LOGDIAG(DTbased)!: %d : %21.15g\n",ii,diagwalltimelocal*(
t-tlasttime)/(
DTdumpgen[ii])/(walltimelocal-diagwalltimelocal));
298 if((walltimelocal-diagwalltimelocal)/((
FTYPE)(
nstep-nsteplasttime)) < DIAGFACTOR*diagwalltimelocal/
DTr){
300 myfprintf(fileit,
"#LOGDIAG(nstepbased)!: %d : %21.15g\n",ii,diagwalltimelocal*((
FTYPE)(
nstep-nsteplasttime))/((
FTYPE)
DTr)/(walltimelocal-diagwalltimelocal));
306 if((walltimelocal-diagwalltimelocal) < DIAGFACTOR*diagwalltimelocal){
307 myfprintf(fileit,
"#INSTANTLOGDIAG!\n");
310 if((walltime-diagwalltime) < DIAGFACTOR*diagwalltime){
311 myfprintf(fileit,
"#GLOBALLOGDIAG!\n");
317 localdiagwalltimecumulative=0.0;
326 if(walltime<1
E-5) walltime=1
E-5;
335 stderrfprintf(
"PERFTEST: nstep=%ld/%d t=%15.10g/%15.10g wt=%15.10g/%15.10g\n",
nstep,itemp,
t,
tf,walltime,(
SFTYPE)itemp*(
SFTYPE)walltime/(
SFTYPE)
nstep); fflush(stderr);
358 sprintf(temps,
"%sfinalperf%s",
DATADIR,
".txt") ;
359 if(!(perfout=fopen(temps,
"at"))){
360 dualfprintf(
fail_file,
"Can't open %s\n",temps);
363 stderrfprintf(
"opened: %s\n", temps);
369 if(walltime<1
E-5) walltime=1
E-5;
376 stderrfprintf(
"#(sec) walltime: %21.15g usertime: %21.15g systime: %21.15g\n",
diffmicrotime(wttimestop,wttimestart),
diffmyustimes(usertmstimestop,usertmstimestart),
diffmyustimes(systmstimestop,systmstimestart));
379 myfprintf(
logperf_file,
"#done: steps: %10ld wtime: %10.2g tzcycles: %10d t: %10.2g tu/hour: %10.5g\n",
nstep,walltime*SEC2HOUR,(
int)((
FTYPE)(
realtotalzones)*(
FTYPE)diffnstep/walltime),(
t-comptstart),(
t-comptstart)/(walltime*SEC2HOUR)) ;
398 MPI_Bcast(&
reallaststep,1,MPI_INT,MPIid[0], MPI_COMM_GRMHD);
419 long clockspersecond;
421 clockspersecond=sysconf(_SC_CLK_TCK);
423 *time=(clock_t) (1000000.0*(
SFTYPE)(mytimes.tms_utime+mytimes.tms_stime+mytimes.tms_cutime+mytimes.tms_cstime)/(
SFTYPE)clockspersecond );
425 void myustimes2(clock_t *usertime,clock_t *systime)
429 long clockspersecond;
431 clockspersecond=sysconf(_SC_CLK_TCK);
433 *usertime=(clock_t) (1000000.0*(
SFTYPE)(mytimes.tms_utime+mytimes.tms_stime)/(
SFTYPE)clockspersecond );
434 *systime=(clock_t) (1000000.0*(
SFTYPE)(mytimes.tms_cutime+mytimes.tms_cstime)/(
SFTYPE)clockspersecond );
440 void myustimes2(clock_t *usertime,clock_t *systime)
449 int gettimeofday(
struct timeval *tv,
struct timezone *tz)
452 unsigned __int64 tmpres = 0;
456 GetSystemTimeAsFileTime(&ft);
457 tmpres |= ft.dwHighDateTime;
459 tmpres |= ft.dwLowDateTime;
462 tmpres -= DELTA_EPOCH_IN_MICROSECS;
463 tv->tv_sec = (long)(tmpres / 1000000UL);
464 tv->tv_usec = (long)(tmpres % 1000000UL);
473 tz->tz_minuteswest = _timezone / 60;
474 tz->tz_dsttime = _daylight;
490 int output_steptimedt_info(
SFTYPE comptstart)
523 myfprintf(fileit,
"#t dt cour nstep realnstep strokeperzone:\n"
526 if(i==1) myfprintf(fileit,
"#");