How can I measure the average IPC for my application code?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User18151
Level 3
Level 3
First like received First solution authored
Hi all,

How can I measure IPC (Instruction Per Cycle rate) or other useful parameter for my code?

Thank you and best regards,
Christine


#8042000 13272
0 Likes
3 Replies
User18237
Level 5
Level 5
First solution authored First like received
Hi Christine,


Tricore CPU has a performance counter registers to measure such a useful parameters.

Following code shows a example to measure following parameters,

+ CPU Clock Count
+ Instruction Count
+ Program Cache Hit Count
+ Program Cache Miss Count

Details could be found on AURIX user's manual, Please note that the OCDS must be enabled.

5.8.7 CPU Core Debug and Performance Counter Registers

(sample code)

// Configure Performance counter and make start counting// Configure Performance counter and make start counting// CCTRL.CE=1, .M1=1, .M2=1, .M3=1
__mtcr(CPU_CCTRL, (unsigned int)0x00000126);
// Store counter values before executing target code
clkS = __mfcr(0xFC04); /* read CCNT / instS = __mfcr(0xFC08); / read ICNT */ m1S = __mfcr(0xFC0C); m2S = __mfcr(0xFC10);
// Put your target code to be measured here
int count = 1000000; while ((count--) > 0)
{ // Put Your test code here! // ex. test_main(); __asm__ ("ld.w d0,[a11]0x0 \n"); }
// Read counter values after executing target code
clkE = __mfcr(0xFC04); instE = __mfcr(0xFC08); m1E = __mfcr(0xFC0C); m2E = __mfcr(0xFC10);
// calculation for result
ipc = (instE-instS)/(clkE-clkS); pc_hit = (m1E-m1S)/(instE-instS); pc_miss = (m2E-m2S)/(instE-instS);


Best regards
Mr. AURIX™
0 Likes
User17451
Level 2
Level 2
10 replies posted 5 replies posted 5 questions asked
Dear all.

I have interesting this discussion.

I find the topic about IPC - http://www.brendangregg.com/blog/2017-05-04/the-pmcs-of-ec2.html

I'm so much interested in
IPC < 1: likely stall cycle bound, also...
IPC > 1: likely instruction bound. Look to...


These indicator (or idea) can available to AURIX/TriCore ?

thx
0 Likes
NeMa_4793301
Level 6
Level 6
10 likes received 10 solutions authored 5 solutions authored
Yes: see the CPU chapter for details. In addition to CPU cycle count and CPU instruction count, these counters are also available:

4698.attach
0 Likes