[tz_vmm demo]- execution time

Martin Stein martin.stein at ...1...
Thu Nov 3 17:54:41 CET 2016


Hi John,

Am 25.10.2016 um 03:53 schrieb John David:
> Hi Martin,
> 
> Thanks a lot.
> I have tried to measure and print the performance counter value on as
> follows ( i.MX53QSB)
> 
>         /Trace::Timestamp start = Trace::timestamp();
> /
> /         my_funciton();
> /
> /        Trace::Timestamp end = Trace::timestamp();
> 
>         printf("CPU_cyces= %lu\n",(end-start));/
> 
> I have tried with /printf(%zu),/ /printf(%llu)/ and /printf("%"PRIu32)
> /format but the maximum number of digits what I can get is 10. I wonder
> what format can be used if the performance counter value is larger than
> 10 digits.
> To calculate the elapsed time, I multiply the /CPU_cycles  by 1
> nanosecod (ns)  / cycle.  /Is that right?
> 
> Thanks,

As you are on an ARMv7, Timestamp is a uint32_t. So, %u is sufficient
but the value never exceeds ten digits as the maximum uint32_t
(0xffffffff) is 4294967295 decimal. So it seems that your performance
counter is to fast. You can, however, slow it down by counting only
every 64th CPU cycle. This is the kernel patch for that:

--- a/repos/base-hw/src/core/spec/arm_v7/perf_counter.cc
+++ b/repos/base-hw/src/core/spec/arm_v7/perf_counter.cc
@@ -37,6 +37,7 @@ struct Pmcr : Register<32>
                E::set(v, 1);
                P::set(v, 1);
                C::set(v, 1);
+               D::set(v, 1);
                return v;
        }

Your CPU should work with 1GHz so one cycle should be one nanosecond,
right. But consider that with the above patch, one counter step extends
to 64 nanoseconds.

Cheers,
Martin




More information about the users mailing list