Skip to content

Commit

Permalink
TIMER: Run simulator pre-calibration for a minimum of 100ms
Browse files Browse the repository at this point in the history
Faster host systems today can get very fast instruction execution rates
for a short duration calibration test.  These may be skewed by round
off error, so we now run the calibration for a minimum of 100ms.
  • Loading branch information
markpizz committed Nov 18, 2020
1 parent 03a79b1 commit 8233fdc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sim_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3459,8 +3459,10 @@ sim_switches = saved_switches;
sim_cancel (&SIM_INTERNAL_UNIT);
sim_activate (&precalib_unit, sim_precalibrate_ips);
start = sim_os_msec();
sim_instr();
end = sim_os_msec();
do {
sim_instr();
end = sim_os_msec();
} while ((end - start) < SIM_PRE_CALIBRATE_MIN_MS);
sim_precalibrate_ips = (int32)(1000.0 * (sim_precalibrate_ips / (double)(end - start)));

for (tmr=0; tmr<=SIM_NTIMERS; tmr++) {
Expand Down
1 change: 1 addition & 0 deletions sim_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ int clock_gettime(int clock_id, struct timespec *tp);

#define SIM_INITIAL_IPS 5000000 /* uncalibrated assumption */
/* about instructions per second */
#define SIM_PRE_CALIBRATE_MIN_MS 100 /* minimum time to run precalibration activities */

#define SIM_IDLE_CAL 10 /* ms to calibrate */
#define SIM_IDLE_STMIN 2 /* min sec for stability */
Expand Down

0 comments on commit 8233fdc

Please sign in to comment.