hi,
I am trying to use the Data Watch and Trace natively on RPI3 without debugger to count Cycle but got a core dump. here the code to compile and run on a RPI3. . My objective is to count cycle to do accurate benchmarking.
I have a core dumped on line *DEMCR = *DEMCR | 0x01000000;
What is the issue here ?
Thanks for any help. Regards
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h> volatile uint32_t count = 0;
// addresses of registers
volatile uint32_t *DWT_CONTROL = (uint32_t *)0xE0001000;
volatile uint32_t *DWT_CYCCNT = (uint32_t *)0xE0001004;
volatile uint32_t *DEMCR = (uint32_t *)0xE000EDFC;
int main () { // enable the use DWT
printf("Init \n");
*DEMCR = *DEMCR | 0x01000000;
printf(" never here ? \n");
// Reset cycle counter *DWT_CYCCNT = 0; // enable cycle counter
*DWT_CONTROL = *DWT_CONTROL | 1 ;
// some code here
// number of cycles stored in count variable
count = *DWT_CYCCNT;
printf("count = %d \n",count);
return 0; }
The output is : Init Segmentation fault (core dumped)
Hi Jason, thanks for the answer.
yes, i am using a RPI3 on Ubuntu mate. My app is a C library doing maths intend to run on different platforms (intel and ARM). On Intel, i am using __rdtsc and i was thinking to use DWT for ARM. I tried on a RPI3 thinking it would be the same by error (Thanks Jason to point out) but i will also need to bench old ARM 7-6 etc.... I am looking for a Cycle count Stat embedded in the library code with the smallest dependencies so i am not looking for additional tools. I will look to the similar Cortex-A53 DWT function. Do you know an equivalence DWT on Cortex-A53 ?. Do you think to a more general solution than DWT to count cycle in the ARM world ? Thanks for any advices. Best regards
Hi, as Jason suggested. i just checked the Cortex-A53 Spec and did not find DWT for Cycle Count. I am thinking it's not in ARMv8-A !
1) What would be the Generic Cycle Count Approach/Strategy for ARM ?
2) or what would be the list of Generic Cycle Count Approach depending on the ARM versions ?
As explained i am looking for an easy Cycle Count Counter i could Read from the code when required in C syntax.
Regards
Hi,
I recommend to start with the Cortex-A53 Technical Reference Manual PMU section: https://developer.arm.com/docs/ddi0500/g/performance-monitor-unit
Then start with this article: https://developer.arm.com/products/system-design/cycle-models/knowledge-articles/system-performance-analysis-and-the-arm-performance-monitor-unit
It was for Cycle Models but also applies to the R Pi 3.
The code for the article is attached at the bottom of this link: https://community.arm.com/soc/b/blog/posts/system-performance-analysis-and-the-arm-performance-monitor-unit-pmu
You can download and study the code to read the cycle count.
Another useful article is: https://developer.arm.com/products/system-design/cycle-models/knowledge-articles/using-the-arm-performance-monitor-unit-linux-driver
Thanks,
Jason
Hi Jason, Thanks for the help. I will give it a try based on your work on PMU with Linux Kernel in the coming days and let you know on a RPI3. In the mean time, i ran into the evaluation of the PMU versus DWT for cycle count on some ARM familly/architecture HW. It appears that PMU is now days mostly in used (PMUv3) while DWT is now too old. So the method develop in your blog should be the best choice. thanks
Here the matrix computed from the ARM doc. Three column are related to the strategy for cycle count (PMU,DWT or other). The column H/W implementation should be fill with boards name or product name. I tried to aggregate quickly the PMU versions or insert notations to give indications (when found). It's a first quick run and I am happy to received comments or to update the matrix. Feel free to send comments.