初始化HPM(Hardware performance Monitor),系统初始化时调用。

.option norvc
.global hpm_get_icache_miss_rate
hpm_get_icache_miss_rate:li   x5, 0xffffffffcsrw mcountinhibit, x5csrw mcycle, x0csrw minstret, x0csrw mhpmcounter3, x0csrw mhpmcounter4, x0csrw mhpmcounter5, x0csrw mhpmcounter6, x0csrw mhpmcounter7, x0csrw mhpmcounter8, x0csrw mhpmcounter9, x0csrw mhpmcounter10, x0csrw mhpmcounter11, x0csrw mhpmcounter12, x0csrw mhpmcounter13, x0csrw mhpmcounter14, x0csrw mhpmcounter15, x0csrw mhpmcounter16, x0csrw mhpmcounter17, x0csrw mhpmcounter18, x0csrw mhpmcounter19, x0csrw mhpmcounter20, x0csrw mhpmcounter21, x0csrw mhpmcounter22, x0csrw mhpmcounter23, x0csrw mhpmcounter24, x0csrw mhpmcounter25, x0csrw mhpmcounter26, x0csrw mhpmcounter27, x0csrw mhpmcounter28, x0csrw mhpmcounter29, x0csrw mhpmcounter30, x0csrw mhpmcounter31, x0li   x5, 1csrw mhpmevent3, x5li   x5, 2csrw mhpmevent4, x5li   x5, 3csrw mhpmevent5, x5li   x5, 4csrw mhpmevent6, x5li   x5, 5csrw mhpmevent7, x5li   x5, 6csrw mhpmevent8, x5li   x5, 7csrw mhpmevent9, x5li   x5, 0xbcsrw mhpmevent13, x5li   x5, 0xccsrw mhpmevent14, x5li   x5, 0xdcsrw mhpmevent15, x5li   x5, 0xecsrw mhpmevent16, x5li   x5, 0xfcsrw mhpmevent17, x5li   x5, 0xffffffffcsrw mcounteren, x5li   x5, 0xffffffffcsrw scounteren, x5csrw mcountinhibit, x0ret

在需要检测cache miss的位置,调用读取event寄存器:


DBG("counter3: %lx,counter4: %lx, dcr: 0x%lx, dcrm: 0x%lx dcw: 0x%lx, dcwm: 0x%lx, sto:0x%lx\n", csr_read(mhpmcounter3), csr_read(mhpmcounter4),csr_read(mhpmcounter14),csr_read(mhpmcounter15), csr_read(mhpmcounter16), csr_read(mhpmcounter17),csr_read(mhpmcounter13));

测试,在timer中断中查询当前的事件寄存器状态:

riscv_timer_interrupt line 43, counter3: 18c970e9d8,counter4: 28
riscv_timer_interrupt line 43, counter3: 18c9bb2df2,counter4: 28
riscv_timer_interrupt line 43, counter3: 18ca05720f,counter4: 28
riscv_timer_interrupt line 43, counter3: 18ca4fb62c,counter4: 28
riscv_timer_interrupt line 43, counter3: 18ca99fa49,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cae43e67,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cb2e8277,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cb78c68a,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cbc30a99,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cc0d4eb6,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cc5792cf,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cca1d6ec,counter4: 28
riscv_timer_interrupt line 43, counter3: 18ccec1afc,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cd365f0f,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cd80a31e,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cdcae73b,counter4: 28
riscv_timer_interrupt line 43, counter3: 18ce152b4a,counter4: 28
riscv_timer_interrupt line 43, counter3: 18ce5f6f5d,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cea9b36d,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cef3f78a,counter4: 28
riscv_timer_interrupt line 43, counter3: 18cf3e3b99,counter4: 28

通过访问counter3和counter4寄存器,在RTOS上成功获取到了ICache的miss率(counter3/counter4),但是貌似没有办法得到cache miss时候对用的访问地址。 也就是有没有办法能够获得失中时刻的访问地址。它更是一个程序段行为的统计展示。 为了优化程序可以分程序段分别统计cache miss率,针对miss率高的程序段进行分析。

关于HPM的使用,总结如下:

1、不同事件计数器单位不同,可以从事件描述中看出。例如:time这一计数器所表示的是系统计时器的当前值,或者counter_i表征L1 ICache miss counter时,它的单位就是L1 ICache访问缺失的次数;

2、如上所述,如果counter3设置为CACHE(ICACHE/DCACHE读/DCACHE写)的缺失次数,读该寄存器的返回值得到的时访问CACHE缺失的次数,只需再设置某一寄存器counter_i为CACHE访问次数,用counter3的值除以counter_i的值即可得到CACHE缺失率。

结束!

C906 RISCV HPM(PMU)使用方法相关推荐

  1. 什么是RISC-V生态系统?

    RISC-V最基本的形式是一种基于简化指令集计算机(RISC)设计原理的开放标准指令集体系结构(ISA).RISC-V是一个开放的规范和平台:它不是开源处理器.RISC-V生态系统的所有其他方面都建立 ...

  2. 计算机是如何进行计算的?(二)

    1.写在前面 我们上一节介绍了正数的加法.减法.乘法.除法,这节博客我们来介绍下浮点数的加法.减法.乘法.除法. 2.浮点运算 除了有符号和无符号的整数外,编程语言还支持小数,在数学中被称作实数.科学 ...

  3. 图像检索(二)--综述(2016年之前)

    转自:https://blog.csdn.net/l7H9JA4/article/details/80569458 前言 基于内容的图像检索任务(CBIR)长期以来一直是计算机视觉领域重要的研究课题, ...

  4. 国内芯片厂家种类(更新中)

    有时候找芯片类别不知道找哪一家,先在这里分一下大类,具体要找厂家询问,这里只列官网有的.方便自己和他人找芯片. 极海半导体 https://geehy.com/MCU (APM32(ARM),低功能蓝 ...

  5. 你了解CPU吗?(五)

    1.写在前面 前面我们已经介绍了CPU的一些基础的信息,以及如何构建一个数据通路,以及如何构建CPU的流水线,以及CPU流水线会带来那些问题,但是在历史的长河里面,CPU做到这些还远远不够,还需要更快 ...

  6. 论文笔记:SIFT Meets CNN: A Decade Survey of Instance Retrieval

    一.基本信息 标题:SIFT Meets CNN: A Decade Survey of Instance Retrieval 时间:2017 出版源:IEEE Transactions on Pat ...

  7. 获取OpenHarmony源码:从DevEco Marketplace获取(1)

    引言 OpenHarmony源码的获取方式有三种:从gitee.GitHub等基于git的代码托管平台获取:从华为的DevEco Marketplace网站获取:从镜像站点获取. 本文介绍如何用从华为 ...

  8. wch-link替代st-link(实际支持大部分arm核芯片)

    从Keil MDK转到STM32CubeIDE平台,笔者遇到了很多问题,但都一一解决了,gcc+eclipse的组合是真的好用. 下面介绍一种廉价的调试方案,目前芯片涨价导致各种调试工具也涨价了(比如 ...

  9. 在 Oracle Enterprise Linux 和 iSCSI 上构建您自己的 Oracle RAC 11g 集群

    作者:Jeffrey Hunter 了解如何以低于 2,700 美元的费用在 Oracle Enterprise Linux 上安装并配置 Oracle RAC 11g 第 2 版开发集群. 本指南中 ...

最新文章

  1. 【Linux基础】crontab定时命令详解
  2. 第六章 图像识别与卷积神经网络
  3. 内齿轮泵行业调研报告 - 市场现状分析与发展前景预测
  4. win11扩展任务栏没东西怎么办 windows11扩展任务栏没东西的解决方法
  5. 【优化算法】海鸥优化算法(SOA)【含Matlab源码 1099期】
  6. 春晚魔术,醉翁之意不在酒
  7. hp计算机u盘启动,惠普台式机u盘启动(免费分享惠普电脑u盘启动步骤)
  8. java调用opencc进行中文简体繁体转换
  9. html基础教学ppt,HTML5基础培训ppt课件
  10. 算机类学术论文 28个常见出版社一般写法(参考文献用)
  11. 【Python】P2191 小Z的情书
  12. 张桂梅PK清华副教授:不要站在高楼上,傲慢地指着大山
  13. 解读Verizon 2018数据泄漏调查报告:窃取身份仍是黑客最有效的攻击手段
  14. java web 小学期实训小节
  15. 百度飞桨七日深度学习手势识别
  16. [英语阅读]意环保者塑“老贝”冰雕督促环保
  17. SAP中利用SE16N事务的小计功能实现输出清单的加工实例
  18. 安卓端录像并将视频分享给微信好友
  19. NR5G基础概念扫盲
  20. Trade strategy交易策略

热门文章

  1. linux里find用法,Linux中find命令基本使用方法
  2. Linux的清除指令,linux清除指令
  3. c++库函数to_string()和stoi()
  4. 中计播客 | 今日头条对战百度
  5. 各种内容转载以及PS
  6. vue实现弹窗多表格
  7. 用”钉钉“做班级直播(快速操作指南)
  8. drawstring 文本居中_c#-Graphics.DrawString()的中心文本输出
  9. java monitor 用法_[作业解析]并发中的Monitor及在Java中的运用如notify(),synchronized等用法...
  10. iDevice取证的一大突破