SSE4

SSE4 を見る

追加された命令

SSE4で追加された命令を抜粋し、その気持を紐解きたいと思う。
  • SSE4 Vectorizing Compiler and Media Accelerators
ベクトルかコンパイラ用の命令とメディア処理用命令。
Packed DWORD Multiplies PMULLD, PMULDQ New support for four signed or unsigned 32x32 bit multiplications per instruction, as well as signed forms of 32x32->64 multiplication. Broadly useful for improved automated compiler vectorization of data processing written in high level languages (like C and Fortran).
Floating Point Dot Product DPPS, DPPD Improved performance for AOS (Array of Structs)data processing through support for single and double-precision dot products. 3-D content creation, gaming, and support for languages like CG and HLSL.
Packed Blending BLENDPS, BLENDPD, BLENDVPS, BLENDVPD, PBLENDVB, PBLENDDW Blending conditionally copies one field in the source onto the same field in the destination. These new instructions improve the performance of blending operations for most field sizes through packing multiple operations in a single instruction. Broadly useful for automated compiler vectorization of data processing written in high level languages (like C and Fortran), and applications such as image processing, video processing, multimedia, and gaming.
Packed Integer Min and Max PMINSB, PMAXSB, PMINUW, PMAXUW, PMINUD, PMAXUD, PMINDS, PMAXSD Compares packed signed/unsigned byte/word/dword integers in the destination operand and the source operand, and returns the minimum or maximum as per the instruction type for each packed operand in the destination operand. Broadly useful for automated compiler vectorization of data processing written in high level languages (like C and Fortran), and applications such as image processing, video processing, multimedia, and gaming.
Floating Point Round ROUNDPS, ROUNDSS, ROUNDPD, ROUNDSD Efficiently rounds the scalar and packed singleand double- precision operands to integers, with enhanced support for Fortran, JAVA and C99 language requirements. Image processing, graphics, video processing, 2-D/3-D applications, multimedia, and gaming.
Register Insertion/Extraction INSERTPS, PINSRB, PINSRD, PINSRQ, EXTRACTPS, PEXTRB, PEXTRD, PEXTRW, PEXTRQ These new instruction simplify data insertion and extraction between GPR (or memory) and XMM registers. Broadly useful for automated compiler vectorization of data processing written in high level languages (like C and Fortran), and applications such as image processing, video processing, multimedia, and gaming.
Packed Format Conversion PMOVSXBW, PMOVZXBW, PMOVSXBD, PMOVZXBD, PMOVSXBQ, PMOVZXBQ, PMOVSXWD, PMOVZXWD, PMOVSXWQ, PMOVZXWQ, PMOVSXDQ, PMOVZXDQ Converts from a packed integer (from XMM register or memory) to a zero- or sign-extended integer with wider type. Broadly useful for automated compiler vectorization of data processing written in high level languages (like C and Fortran), and applications such as image processing, video processing, multimedia, and gaming.
Packed Test and Set PTEST Faster branching from SIMD decisions to support conditionally vectorized code. Useful for improved automated compiler vectorization of data processing, image and video processing, 3-D content creation, multimedia, and gaming.
Packed Compare for Equal PCMPEQQ, PCMPGTQ Performs SIMD compare for equality of the packed QWORDs in the destination and the source operand. Broadly useful for automated compiler vectorization of data processing written in high level languages (like C and Fortran), and applications such as image processing, video processing, multimedia, and gaming.
Pack DWORD to Unsigned WORD PACKUSDW Converts packed signed DWORDs into packed unsigned WORDs using unsigned saturation to handle overflow condition. This new instruction completes the set of other instructions in this type. Broadly useful for automated compiler vectorization of data processing written in high level languages (like C and Fortran), and applications such as image processing, video processing, multimedia, and gaming.

ショートベクタレジスタの各要素同士の乗算。内積演算。ここらへんはあって当然。
blending演算は有用だと思う。通常のブレンド計算は、ある重み係数を乗じて二つの値を足し合わせることになる。このとき、大抵桁上がりが起きるためにいちいち符号拡張してから足して、もとの型に戻すって事を行う。あ、でもコレは整数計算の場合だ。浮動小数点では関係ないな。整数演算に限っては、(a+b)/2のような平均を求める演算が結構気にかかる。
min/max演算もあって当然と思われる。丸めもね。ここら辺の基本的な演算を今までもってなかったのが意外。
Register insertionはおそらく、スカラ値をベクトル値のどこかに入れる、もしくは出す。だと思われる。この操作もあって当然。というか、SIMD演算は大概データ転送がネックになるため、レジスタ間、メモリ間のデータ移動は色々なバリエーションがあればあるほど良いと思う。シャッフルとかもね。
ptestは何か分からないが、おそらく演算結果をマスクするためのコンディショナル命令ではないかな?ベクトル値のある特定の要素のみを演算対象にしたい場合なんかに有用。分岐消しは最適化のキモですのでなかったのが不思議。比較命令も同様。

  • SSE4 Efficient Accelerated String and Text Processing
文字列比較命令。
Advanced String Operations PCMPESTRI, PCMPESTRM, PCMPISTRI, PCMPISTRM These new instructions provide a rich set of string and text processing capabilities that traditionally required many more opcodes. Improved performance for virus scan, text search,string processing libraries like ZLIB, databases, compilers and state machine-oriented applications.
ショートベクタレジスタ同士の文字列比較命令と思われる。おそらく、オペランドに指定されたレジスタに含まれるバイト列同士の一致を見る。このような、ベクトルを横方向に演算する命令は重要だと思う。DLPっぽく無く利用する命令が増えることで、SIMDの幅が増えると個人的に思う。

  • Overview of Application Targeted Accelerators
特定用途命令。CRC計算命令と、population命令。
Fast CRC (Cyclic Redundancy Check) CRC32 Finds the CRC value using a specific polynomial of a given source operand. Fast and efficient data integrity checks in data transfer protocols for networked storage (e.g., iSCSI, RDMA)
Accelerated searching and pattern recognition of large data sets POPCNT Calculates the number of bits set to 1 in the given operand. Helps to deliver higher performance in applications such as genome mining, handwriting recognition, digital health workloads, fast hamming algorithms, and others.

CRCの計算方法は結構面倒くさく遅くなる。データ通信を行うときに誤りが無いか検出する際にCRCは良く使うので、利用範囲は広いと思われる。説明書きを読むと、分散メモリ型のプロセッサアレイを使い、データ通信するときの誤り検出用のようなことが書いてある。
POPCNTは、population命令と呼ばれるもののようだ。レジスタに存在する1をカウントする命令。Hacker's delightBit Twiddling Hacksなどで計算方法を解説している。このようなbit演算はかなり面白い。CRCに比べて、専用命令になることで大きくstep数が減るかというとそんなことは無い。先のリンクで解説している通り、32bit長ならば高々12命令程度で計測できる。とはいえ、population命令は色々と応用が効きますので、会って困ることはない。
population命令は、bitを数え上げるわけですが、見方によっては1bit長の配列をアキュムレートしているともいえる。SSE4用のレジスタが何bit長だか知りませんが、たとえば8bit長の配列を全て足し合わせる操作に似ている。populationを拡張していくことで、1,2,3,4,5,....長の足し合わせ命令をつけておけば直行性が増しそうです。
最終更新:2008年02月14日 03:08
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。