14

AVX512CD 命令ファミリは、VPCONFLICT、VPLZCNT、および VPBROADCASTM です。

これらの指示に関するウィキペディアのセクションには、次のように記載されています。

AVX-512 競合検出 (AVX-512CD) の命令は、通常は安全にベクトル化できないループ内の要素の競合のないサブセットを効率的に計算できるように設計されています。

これらの命令がループのベクトル化に役立つことを示す例は何ですか? 回答にスカラー ループとそれに対応するベクトル化されたループが含まれていると助かります。

ありがとう!

4

1 に答える 1

11

CD 命令が役立つ可能性がある 1 つの例は、ヒストグラムです。スカラー コードのヒストグラム処理は、次のような単純なループです。

load bin index
load bin count at index
increment bin count
store updated bin count at index

通常、ベクトル内に同じビン インデックスが複数ある可能性があるため、ヒストグラムをベクトル化することはできません。

load vector of N bin indices
perform gathered load using N bin indices to get N bin counts
increment N bin counts
store N updated bin counts using scattered store

ただし、ベクトル内のインデックスのいずれかが同じ場合、競合が発生し、結果のビンの更新が正しくなくなります。

だから、救助へのCDの指示:

load vector of N bin indices
use CD instruction to test for duplicate indices
set mask for all unique indices
while mask not empty
    perform masked gathered load using <N bin indices to get <N bin counts
    increment <N bin counts
    store <N updated bin counts using masked scattered store
    remove non-masked indices and update mask
end

実際には、この例は非常に非効率的であり、スカラー コードに勝るものはありませんが、CD 命令を使用する価値があると思われる計算集約型の例は他にもあります。通常、これらはデータ要素が非決定論的な方法で更新されるシミュレーションです。1 つの例 ( LAMMPS Molecular Dynamics Simulatorから) は、JeffersのKNL 本で参照されています。

于 2016-10-07T11:39:35.047 に答える