【问题标题】:L2 cache lines miss countL2 高速缓存行未命中计数
【发布时间】:2014-02-08 13:34:17
【问题描述】:

我想在运行一个特定程序 A 时计算 L2 缓存未命中的总数。有没有办法在 L2 缓存中找到缓存未命中?

我知道了,Core i7 CPU 的性能计数器事件类型“L2_LINES_OUT”可用于 Counts L2 缓存行被驱逐,但不知道如何使用?

我正在使用 linux 和 Intel i7 IvyBridge 机器。

任何指针或链接都将受到高度赞赏。

【问题讨论】:

  • 为什么这对你很重要?您不能简单地对您的程序进行基准测试吗?
  • @BasileStarynkevitch,我认为这正是他想要做的:)

标签: c linux performance-testing cpu-architecture cpu-cache


【解决方案1】:

根据this summary,可以使用l2_rqsts子事件:

0x01: (name=demand_data_rd_hit) Demand Data Read requests that hit L2 cache
0x03: (name=all_demand_data_rd) Demand Data Read requests
0x04: (name=rfo_hit) RFO requests that hit L2 cache
0x08: (name=rfo_miss) RFO requests that miss L2 cache
0x0c: (name=all_rfo) RFO requests to L2 cache
0x10: (name=code_rd_hit) L2 cache hits when fetching instructions, code reads.
0x20: (name=code_rd_miss) L2 cache misses when fetching instructions
0x30: (name=all_code_rd) L2 code requests
0x40: (name=pf_hit) Requests from the L2 hardware prefetchers that hit L2 cache
0x80: (name=pf_miss) Requests from the L2 hardware prefetchers that miss L2 cache
0xc0: (name=all_pf) Requests from L2 hardware prefetchers 

您可以只使用 -(all_demand_data_rd - demand_data_rd_hit) 来计算需求未命中数

【讨论】:

    【解决方案2】:

    IBM 文档 here 可能会有所帮助。

    它描述了 Ivybridge 上许多不同指标的各种表达式。你想要的似乎是

     *Instruction fetch from L2 cache miss rate*
     100.0 * X_L2_RQSTS_IFETCH_MISS / X_L2_RQSTS_IFETCHES
    

    【讨论】:

    • IFETCH 事件只会计算指令缓存未命中(未命中代码 L1 并查找共享 L2 的那些)
    【解决方案3】:

    搜索PAPI,它是一个工具,你可以用它来读取你想要收集L2缓存未命中的代码段前后的PMU。

    【讨论】:

      猜你喜欢
      • 2017-09-26
      • 1970-01-01
      • 2020-05-19
      • 1970-01-01
      • 2016-10-18
      • 1970-01-01
      • 2015-02-24
      • 2012-11-05
      • 2011-10-08
      相关资源
      最近更新 更多