[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tmoverhd calibration



These comments are based on examination of the PowerPC MCP750 BSP
timing driver and timing tests.  I don't know if they apply across all BSPs.
I am running the code on a Motorola MVME2306 board.

The tmoverhd test is used to measure overhead calibration values for
use in the other timing tests.  In the case of the MCP750 BSP at least,
the calibration values calculated are in units of decrementer ticks
because Set_find_average_overhead(TRUE) is called.  However, when the
actual timing tests are run, they use timing units of nsec since
Set_find_average_overhead(TRUE) is not called.  In the case of my
board, ticks are 60 nsec, so the calibration factor is way off the 
mark.  Either Set_find_average_overhead(TRUE) should not be called,
or the driver should be changed to report consistently in either
ticks or nsec.

In addition, the calibration appears incorrect with respect
to the overhead of the timing routines themselves.  That overhead 
(timer_overhead shown below) ends up being divided by OPERATION_COUNT
even though the timer routines are not being called OPERATION_COUNT
times.  The values printed now are essentially 
(measured_time / OPERATION_COUNT) since the overhead variable is
never changed from 0 in the MCP750 timing driver.  
It should be clear that the minimum value any calibration 
value should have is timer_overhead.

I think the tmoverhd test should be rewritten like this:

	int timer_overhead, loop_overhead, measured_time;
	volatile int i;

	Timer_initialize();
	timer_overhead = Read_timer();      /* this is non-zero for MCP750 */
 
	Timer_initialize();
	for (i = 0; i < OPERATION_COUNT; i++);
	loop_overhead = Read_timer();

	Timer_initialize();
	for (i = 0; i < OPERATION_COUNT; i++) {
		some_directive_stub(param, param);
	}
	measured_time = Read_timer();

	/*  NOTE:
	 *  call_overhead = (measured_time - loop_overhead) / OPERATION_COUNT;
	 *  calibration = call_overhead + timer_overhead;
	 */

	put_time(
		"some_rtems_directive",
		measured_time,
		OPERATION_COUNT,
		loop_overhead,
		- timer_overhead    
	);

What do you guys think?