中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

选项 -fllc-allocate1

说明

通过分析程序中主要的执行路径,对主路径上的循环进行访存的复用分析,计算排序出 TOP 的热数据,并插入预取指令将数据先分配至 LLC 中,减少 LLC miss。

使用方法

使能 LLC 特性,需开启 -O2 或以上优化等级,同时增加编译选项 -fllc-allocate

其他相关接口:

选项

默认值

说明

-param=mem-access-ratio=[0,100]

20

循环内访存数对指令数的占比。

-param=mem-access-num=unsigned

3

循环内访存数量。

-param=outer-loop-nums=[1,10]

1

允许扩展的外层循环的最大层数。

-param=filter-kernels=[0,1]

1

是否针对循环做路径串联筛选。

-param=branch-prob-threshold=[50,100]

80

高概率执行分支的概率阈值。

-param=prefetch-offset=[1,999999]

1024

预取偏移距离,一般为2的次幂。

-param=issue-topn=unsigned

1

预取指令个数。

-param=force-issue=[0,1]

0

是否执行强制预取,即静态模式。

-param=llc-capacity-per-core=[0,999999]

114

多分支预取下每个核平均分配的 LLC 容量。

结果

测试用例如下:

#define N 100000

long
test (long *a, long *b, long *c, int n)
{
  long sum;
  for (int i = 0; i < n; i++)
    {
      c[i] = a[i] * b[i];
      sum += c[i] - a[i];
    }
  return sum;
}

测试命令:

gcc -O2 -fllc-allocate -S test.c -o test.s
图1 选项未打开
图2 选项打开后

相比选项未打开时,选项打开后,生成的汇编代码指令针对str指令访问的数据在索引上做了1024位的偏移后,提前预取至L3 Cache(鲲鹏920的LLC)中。