gpt4 book ai didi

c++ - 如何在 GCC 中禁用/启用预取?

转载 作者:太空狗 更新时间:2023-10-29 21:19:48 34 4
gpt4 key购买 nike

-O3 是否在 GCC 中启用预取?如果是这样,我该如何禁用预取?是否可以选择控制预取的“攻击性”?例如,每次迭代中要预取的数据量。

最佳答案

根据 GCC 的 Data Prefetch Support网站当前可能的选项是:

Existing data prefetch support in GCC includes:

  • A generic prefetch RTL pattern.
  • Target-specific support for several targets.
  • A __builtin_prefetch function that does nothing on targets that do not support prefetch or for which prefetch support has not yet
    been added to GCC.
  • An optimization enabled by -fprefetch-loop-arrays that prefetches arrays used in loops.

然后查看Optimize Options看起来 -fprefetch-loop-arrays 需要明确启用(也就是说,即使使用 -O3 也没有启用)。

If supported by the target machine, generate instructions to prefetch memory to improve the performance of loops that access large arrays.

This option may generate better or worse code; results are highly dependent on the structure of loops within the source code.

Disabled at level -Os.

请注意 GCC's C99 status page声称,它目前没有考虑函数声明器 (C99 6.7.5.3/7) 上下文中数组的 C99 static 关键字。这意味着“大数组”的大小及其真正含义完全由实现控制。

关于c++ - 如何在 GCC 中禁用/启用预取?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26309666/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com