所以我在看他们展示了如何
void Histogram ( const float* age, int* const hist, const int n, const float group_width, const int m) {
const float oogw = 1.0f / group_width;
// Populating the histogram.
for( int i = 0; i < n; i++) {
// Calculating the index of the bin age[i] goes to.
const int j = (int) ( age[i] * oogwflh );
// Incrementing the appropriate bin in the histogram.
hist[j]++;
}
}
And loop gets verctorized. With this https://hjlebbink.github.io/x86doc/html/VPCONFLICTD_Q.html instruction.
它与原子有什么不同?期望编译器将来在指令级别(针对不同的实体,例如 POD 结构)提供冲突检测支持是否合理?
AVX512 冲突检测指令检测当单个分散指令多次写入同一存储位置时可能发生的冲突。这是同一指令中不同向量通道之间的冲突。
原子操作可防止当多个逻辑 CPU“同时”对同一地址执行加载/存储时发生的竞争情况。
因此,如果您的代码是矢量化的,即使它运行单线程,您也需要冲突检测指令,而在您的代码并行化并使用多个线程执行之前,不需要原子操作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)