This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Event counters take differing number of cycles

We have some code that sets up various event counters and reads them.  We bracket this code with reads of the cycle counter.  We have noticed that depending on what event counter we are configuring, we see widely different cycle counts when running the same piece of code.  Here is some psuedo-code for what we are attempting:

Configure event X to PMU counter 0

read cycle counter

Call test_code

Read cycle counter

Read PMU counter 0

We see by the cycle counter that it takes more cycles to execute our test_code when we configure event 4 than say event 5

Is this to be expected?  What causes this?

This is running on a Cortex-A8 on bare-hardware.

Also, The TRM was unclear about how expensive reading these counters are.  At one point, the TRM says MRC/MCR takes a minimum of 60 cycles, but it isn't clear if that is referring to all or a subset of the instructions.