首页 > 解决方案 > 从 GEM5 获取物理地址跟踪

问题描述

我一直在尝试提取应用程序访问的物理地址以分析行命中。

在这样做的过程中,由于版本更改,我遵循了这个页面,几乎没有变化。

我将 CacheConfig.py 固定为:

system.monitor2 = CommMonitor()
system.monitor2.trace = MemTraceProbe(trace_file = "CT_mon2.trc.gz")
system.monitor2.slave = system.l2.mem_side

system.membus.slave = system.monitor2.master
system.l2.cpu_side = system.tol2bus.master

并运行代码:

build/X86/gem5.opt --debug-flag=CommMonitor configs/example/se.py --caches --l2cache --l2_size=2MB --mem-type=DDR4_2400_16x4 -c        tests/test-progs/mm/bin/x86/linux/mm --cpu-type=TimingSimpleCPU

mm 是来自简单矩阵乘法的二进制:

// C program to multiply two square matrices. 
#include <stdio.h>
#define N 4 

// This function multiplies mat1[][] and mat2[][], 
// and stores the result in res[][] 
void multiply(int mat1[][N], int mat2[][N], int res[][N])
{
    int i, j, k;
    for (i = 0; i < N; i++)
    {
        for (j = 0; j < N; j++)
        {
            res[i][j] = 0;
            for (k = 0; k < N; k++)
                res[i][j] += mat1[i][k]*mat2[k][j];
        }
    }
}

int main()
{
    int mat1[N][N] = { {1, 1, 1, 1},
                    {2, 2, 2, 2},
                    {3, 3, 3, 3},
                    {4, 4, 4, 4}};

    int mat2[N][N] = { {1, 1, 1, 1},
                    {2, 2, 2, 2},
                    {3, 3, 3, 3},
                    {4, 4, 4, 4}};

    int res[N][N]; // To store result 
    int i, j;
    multiply(mat1, mat2, res);

    printf("Result matrix is \n");
    for (i = 0; i < N; i++)
    {
        for (j = 0; j < N; j++)
        printf("%d ", res[i][j]);
        printf("\n");
    }

    return 0;
}

解码“CT_mon2.trc.gz”后,内存轨迹如下:

5,u,15360,64,256,11500
6,u,183808,64,2,101000
5,u,18816,64,256,187000
6,u,183744,64,2,285000
5,u,18880,64,256,357000
6,u,171072,64,3,438000
6,u,171648,64,3,526000
6,u,172032,64,3,601000
6,u,174528,64,3,689000
5,u,18944,64,256,765000

第三个表示物理地址。

我感到困惑的是“u”部分。从解码阶段开始,任何不是 read(r) 或 write(w) 的都被标记为“u”。

通过调试,命令重复“UpgradeFailResp”和“ReadCleanReq”。

我期待有读写的痕迹,但我不确定这里发生了什么。

谁能告诉我我错过了什么?

甚至更好的获取物理地址的方法将是一个巨大的帮助。

谢谢,jwlee

标签: memory-addressgem5

解决方案


您将看到超出读取和写入的流量的原因与 CommMonitor 的放置有关。在您的系统中,membus 可能是一致性点,因此您将获得由 l2 缓存生成的各种流量,这些流量用于与其他 l2 缓存(如果存在)进行缓存一致性操作。如果您将您的 CommMonitor 移动到一致性点下方,例如在 membus 和您的内存控制器之间,您应该只看到读取和写入流量。


推荐阅读