FAQ: Monitoring Cache Performance on the ADSP-BF70x

Document created by CraigG on Jun 11, 2014
Version 1Show Document
  • View in full screen mode

Question

How do I monitor cache performance on the ADSP-BF70x?

 

===========================================

 

Answer

The performance monitor can count events like cache misses non-intrusively. The following functions can be added to your program and used to start and stop monitoring events of interest.

 

#include <sys/platform.h>

typedef enum {
     /* BF70x cache related events.
     Refer to Programmers Reference for others.
     */
     pf_icache_hit = 0x81,
     pf_icache_miss = 0x82,
     pf_dcache_fill_completed = 0x98,
     pf_dcache_line_replaced = 0x99,
     pf_dcache_hit = 0x9a,
     pf_dcache_miss = 0x9b
} PFMonEvent;

void start_pfmon(PFMonEvent mon0, PFMonEvent mon1) {
     uint32_t ctl = 0;
     if (mon0)
          ctl |= BITM_PFCTL_PWR|
               (3<<BITP_PFCTL_ENA0)|
               ((mon0<<BITP_PFCTL_MON0)&BITM_PFCTL_MON0);
     if (mon1)
          ctl |= BITM_PFCTL_PWR|
               (3<<BITP_PFCTL_ENA1)|
               ((mon1<<BITP_PFCTL_MON1)&BITM_PFCTL_MON1);
     *pPFCTL = 0;
     *pPFCNTR0 = 0;
     *pPFCNTR1 = 0;
     *pPFCTL = ctl;
}

void stop_pfmon(unsigned *count0, unsigned *count1) {
     ssync();  /* flush system activity before stopping counting */
     *pPFCTL = 0;
     if (count0)
     *count0 = *pPFCNTR0;
     if (count1)
     *count1 = *pPFCNTR1;
}

 

These functions can be used to monitor cache activity in your program as follows.

 

unsigned dcache_hits, dcache_misses;
start_pfmon(pf_dcache_hit, pf_dcache_miss);
...
/* code you want to monitor */
...
stop_pfmon(&dcache_hits, &dcache_misses);
printf("dcache hits = %u, dcache misses = %u", dcache_hits, dcache_misses);

Attachments

    Outcomes