_mm_mask_roundscale_ph
Classification
AVX-512, Miscellaneous, CPUID Test: AVX512_FP16
Header File
Instruction
VRNDSCALEPH xmm {k}, xmm, imm8
Synopsis
_mm_mask_roundscale_ph(__m128h src, __mmask8 k, __m128h a, int imm8);
Description
Round packed half-precision (16-bit) floating-point elements in "a" to the number of fraction bits specified by "imm8", and store the results in "dst" using writemask "k" (elements are copied from "src" when the corresponding mask bit is not set). [round_imm_note]
Operation
DEFINE RoundScaleFP16(src.fp16, imm8[7:0]) {
m.fp16 := FP16(imm8[7:4]) // number of fraction bits after the binary point to be preserved
tmp.fp16 := POW(FP16(2.0), -m) * ROUND(POW(FP16(2.0), m) * src.fp16, imm8[3:0])
RETURN tmp.fp16
}
FOR i := 0 to 7
IF k[i]
dst.fp16[i] := RoundScaleFP16(a.fp16[i], imm8)
ELSE
dst.fp16[i] := src.fp16[i]
FI
ENDFOR
dest[MAX:128] := 0