从内存映射寄存器读取
我正在使用的处理器架构有一个时间标签计数器,我想读出它来进行性能测量。时间标签计数器被内存映射到 地址0x90000008。我使用以下例程读取时间值 标签计数器,但是打印输出的差异始终为零。任何人有想法 我缺少什么?
char* const ADDR = (char *) 0x90000008;
unsigned long cycle_count_val() {
unsigned long res;
asm volatile (
"set ADDR, %%l0 \n\t"
"ld [%%l0], %0 \n\t"
: "=r" (res)
:
: "%l0"
);
return res;
}
....
unsigned long start = cycle_count_val();
execute_benchmark();
unsigned long end = cycle_count_val();
printf("Benchmark performance(in clock cycles) = %ld \r\n", end-start);
非常感谢您的帮助, 菲尔
The processor architecture I am working with has a time tag counter that I wanna read out to make performance measurements. The time tag counter is memory mapped to the
address 0x90000008. I used the following routine to read the value from the time
tage counter, however the difference in the print out is always zero. Anyone an idea
what I am missing?
char* const ADDR = (char *) 0x90000008;
unsigned long cycle_count_val() {
unsigned long res;
asm volatile (
"set ADDR, %%l0 \n\t"
"ld [%%l0], %0 \n\t"
: "=r" (res)
:
: "%l0"
);
return res;
}
....
unsigned long start = cycle_count_val();
execute_benchmark();
unsigned long end = cycle_count_val();
printf("Benchmark performance(in clock cycles) = %ld \r\n", end-start);
Many thanks for your help,
Phil
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你不需要求助于汇编 - 为什么你不能直接阅读:
I don't think you need to resort to assember - why can't you just read from: