3.6.12 ALU命令式
このとき、精度指定が単精度であれば長語内の 2 要素、半精度であれば長語内の 4 要素に対して並列に演算が行われる。 よって、MABあたりでは、半精度であればサイクルあたり 16 要素に並列に演算が行われることになる。 特にスループットが必要とされる一部のオペコードではサイクルあたり 2 長語を処理できる。 ALU命令式の一般化した文法は次の通りである。
code:syntax
<dst_0> [<dst_1>..]は書き込み先PEオペランドである。 ゼロ出力命令と即値命令は読み出し元PEオペランドを取らない。
ゼロ出力命令や即値命令以外について述べる。
これらは 1 入力または 2 入力である。<src_x>は第 1 入力、<src_y>は第 2 入力の読み出し元PEオペランドである。<src_x>と<src_y>は同一でも構わない。 d, f, g, hが浮動小数点数の倍精度・単精度・疑似単精度・半精度、
l, i, sが整数の倍・単・半精度である。
<opecode>によって符号なし演算オプションを受け付けるかどうか、およびどの精度指定を受け付けるかが異なる。
オペコードの一覧を表3.9に示す。
演算種別ごとに実際に指定可能な精度を表3.10に示す。
incの演算種別はintなのでl, i, sのいずれかのみを付けられるということが分かる。 入力のコピーを行うpassaなどの出力は精度指定に影響されないが、後述の生成されるマスクフラグは影響されることに注意する。 「2長語動作」カラムは 2 長語幅での動作をする場合があるかを示している。 これがnoであれば、ALUが出力する 2 長語のLSB側 1 長語は、第 1 入力のLSB側 1 長語がそのまま入る。 yesの場合の動作はそれぞれの命令の項目で解説する。
imm命令についてはuオプションの意味は符号なしとは異なるのでnoとしてある。 yesの場合の符号ありなしでの動作の違いはそれぞれの命令の項目で解説する。
出力の列において第 1 入力オペランドの値をx、第 2 入力オペランドの値をyと表記する。
table:表3.9
オペコード 演算種別 入力数2 長語動作 符号なしオプション 出力
zero untyped 0 yes no all 0 msl untyped 1 no no x of previous PE msr untyped 1 no no x of next PE not int 1 no no bitwise not x lnot int 1 no no 1 if x == 0,0 otherwise rsqrt float 1 no no approx. of x^{−1/2} floor float 1 no no floor(x) ftoi float 1 no yes cast x to integer bfe bfe 1 yes no extended half block float of x bfn bfn 1 yes (half only) no block float of x max both 2 no yes (int only) max(x, y) min both 2 no yes (int only) min(x, y) packbit both 2 no no (x << 1) | (MSB of y) and int 2 no no bitwise x & y or int 2 no no bitwise x | y xor int 2 no no bitwise x xor y bsl int 2 no no circularly x << y bsr int 2 no no circularly x >> y relu float 2 no no y if (MSB of x) == 0, −0 otherwise relu0 float 2 no no same as relu relu1 float 2 no no y if (2nd MSB of x) == 0, −0 otherwise relu2 float 2 no no y if (3rd MSB of x) == 0, −0 otherwise relu3 float 2 no no y if (4th MSB of x) == 0, −0 otherwise lrelud float 2 no no y if x ≥ 0 , y / 2 otherwise lreluo float 2 no no y if x ≥ 0 ,y / 8 otherwise ilrelud float 2 no no y if x ≥ 0, 2y otherwise 表3.10 表3.9に現れる、ALU命令オペコードの演算種別に対し、指定可能な精度の一覧。
noneの場合は精度指定を付けてはいけない。
table:表3.10
演算種別 指定可能な精度
int l,i, s
float d, f, h
both d, f, h, l, i, s
bfn d, f, g, h
bfe h
untyped none
“-”であれば符号なしオプションが存在しないオペコードであることを示す。
“false”であれば符号ありモードの場合であること、
“true”であれば符号なしモードの場合であることを示す。
“both”であれば、符号なしオプションは存在するが、マスクフラグの生成方法には影響しないことを示す。
「フラグが1になる条件」カラムは、出力長語中の各語について、それが満たされるときマスクフラグは 1になり、そうでなければ 0 になることを示す。 マスクフラグは必ずサイクルあたり 4 ビット出力され、精度指定が長語なら 1 語の結果が 4 ビットに、単語なら 2 語の結果がそれぞれ 2 ビットずつに複製されることに注意する。
table:表3.11
オペコード 符号なし フラグが 1 になる条件
passa - output is all 0 (ignore LSB long-word) max/min (int) both xis selected orx==y max/min (float) - xis selected orx==y 以降では各オペランドの詳細を述べる。