gpt4 book ai didi

c# - "Imprecise faults"和 SIMD

转载 作者:太空狗 更新时间:2023-10-30 01:24:12 26 4
gpt4 key购买 nike

我正在查看 CIL Spec .在附录中,它谈到了“不精确的错误”,这意味着用户可以指定空引用异常等的确切顺序可以放宽。附录讨论了 JITer 可以使用它来提高性能的各种方式。

引起我注意的一个特定小节:

F.5.2 Vectorizing a loop

Vectorizing a loop usually requires knowing two things:

  1. The loop iterations are independent

  2. The number of loop iterations is known.

In a method relaxed for the checks that might fault, part 1 is frequently false, because the possibility of a fault induces a control dependence from each loop iteration to succeeding loop iterations. In a relaxed method, those control dependences can be ignored. In most cases, relaxed methods simplify vectorization by allowing checks to be hoisted out of a loop. Nevertheless, even when such hoisting is not possible, ignoring cross-iteration dependences implied by faults can be crucial to vectorization for “short vector” SIMD hardware such as IA-32 SSE or PowerPC Altivec.

For example, consider this loop:

for (k = 0; k < n; k++) {
x[k] = x[k] + y[k] * s[k].a;
}

where s is an array of references. The checks for null references cannot be hoisted out of the loop, even in a relaxed context. But relaxed does allow “unroll-and-jam” to be applied successfully. The loop can be unrolled by a factor of 4 to create aggregate iterations, and the checks hoisted to the top of each aggregate iteration.

也就是说,这表明如果 JITer 使用这些松弛故障,循环可以自动转向 SIMD 操作。该规范建议您可以使用 System.Runtime.CompilerServices.CompilationRelaxations 枚举来设置这些宽松的错误。但在实际的 C# 中,枚举只有 NoStringInterning 选项,没有任何其他选项。我已经尝试将 System.Runtime.CompilerServices.CompilationRelaxationsAttribute 设置为从 other sources 中提取的一些 int 代码。 , 但生成的 x86 程序集没有差异。

据我所知,官方 Microsoft JIT 并未实现此功能。我知道 Mono 有 Mono.Simd命名空间,所以我猜它也没有实现这一点。

所以我很好奇我是否遗漏了关于该附录(以及第 12.6.4 节“优化”,也谈到了这一点)的一些历史。如果没有一家主要供应商真正实现它,为什么它会出现在标准中? Microsoft 是否有计划在未来致力于此?

最佳答案

So I'm curious if there's some piece of history about that appendix (and section 12.6.4 "Optimization", which talks about this, too) that I'm missing. Why is it in the standard if neither major vendor actually implements it? Are there plans from Microsoft to work on it in the future?

我怀疑这是专门为了提供允许在不破坏实现或要求规范更改的情况下在某个时候实现的选项。

But in actual C# the enum only has the NoStringInterning option without any of the others

这是因为 NoStringInterning 是目前唯一受支持的选项。由于 C# 中的枚举是可扩展的(它只是一种基础整数类型), future 版本的运行时可以轻松扩展以支持其他选项。

注意有suggestions on the VS UserVoice Microsoft 在此领域进行改进的站点。

关于c# - "Imprecise faults"和 SIMD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10034089/

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