iTranslated by AI
New Features in AVX10.2
Information about AVX10.2, an instruction set extension to be included in future Intel CPUs, was released recently.
This article provides a brief overview of the new features in AVX10.2.
Static Rounding Specification
In floating-point arithmetic, rounding occurs when the calculation result cannot be accurately represented in floating-point format. Several rounding methods are defined by IEEE 754, and four are available on x86 systems. Rounding methods are usually selected via control registers of the floating-point unit, but starting with AVX-512, it became possible to specify the rounding method within the instruction's machine code.
(Promotion: I also wrote about specifying rounding methods statically in "Binary Hacks Rebooted," so please check it out.)
However, due to machine code encoding constraints, AVX-512 only allowed static rounding specifications for "scalar operations" and "512-bit vector operations"; it was not available for "128-bit/256-bit vector operations." This "machine code encoding constraint" refers to the part "EVEX.L'L and EVEX.RC are the same entity" in the article I wrote previously:
In AVX10.2, the EVEX prefix has been extended, and 256-bit static rounding will become available by utilizing parts that were previously "fixed" in the third byte. Please refer to the specification for detailed encoding methods.
【Added October 10, 2025】 Due to a plan change around spring 2025, AVX10 will now require 512-bit support, and it seems the 256-bit static rounding has been canceled. 【End of addition】
Floating-point Arithmetic Enhancements for AI: FP8 Support, BF16 Enhancements, etc.
FP8
Low-precision numerical types are frequently used in deep learning, such as FP16, BF16 for floating-point numbers, and INT8, INT4 for integers. It seems the Open Compute Project has released a specification for FP8, perhaps because smaller data types are considered useful even for floating-point numbers:
The summary is as follows:
E4M3 (or HF8)
- Sign bit: 1 bit
- Exponent: 4 bits
- Bias is 7
- Lower mantissa: 3 bits
- No infinity is supported to keep the exponent range as wide as possible. NaN exists.
E5M2 (or BF8)
- Sign bit: 1 bit
- Exponent: 5 bits
- Bias is 15
- Lower mantissa: 2 bits
- Infinity and NaN exist.
AVX10.2 supports FP8 dot products, conversion to wider types, and conversion from wider types.
VCVTBIASPH2BF8
VCVTBIASPH2BF8S
VCVTBIASPH2HF8
VCVTBIASPH2HF8S
The VCVTBIAS series instructions convert input FP16 values to FP8 by adding an integer called a bias (positioned to follow below the mantissa) and truncating. Those ending in S return the maximum finite value upon overflow.
The VCVTHF82PH instruction converts E4M3 (HF8) floating-point numbers to FP16.
There do not seem to be instructions for converting E5M2 floating-point numbers to FP16, etc.
VCVTNEPH2BF8
VCVTNEPH2BF8S
VCVTNEPH2HF8
VCVTNEPH2HF8S
VCVTNE2PH2BF8
VCVTNE2PH2BF8S
VCVTNE2PH2HF8
VCVTNE2PH2HF8S
The VCVTNE series instructions convert FP16 input to E5M2 or E4M3 FP8. Round-to-nearest (ties to even) is always used. Those ending in S return the maximum finite value upon overflow.
BF16 Support Enhancement
While Intel CPUs have supported BF16 (bfloat16, brain float16) for some time, previous support was limited to conversion with single precision, dot products (AVX512_BF16), and matrix operations (AMX-BF16).
In fact, these are the only AVX512_BF16 instructions:
VCVTNE2PS2BF16
VCVTNEPS2BF16
VDPBF16PS
In AVX10.2, instructions such as basic arithmetic operations that directly target BF16 will be added.
【Added October 10, 2025】 Regarding BF16, I also wrote an article titled "CPU Support and C Language Usage of bfloat16 (brain float16)," so please take a look. 【End of addition】
Support for IEEE 754-2019 min/max Operations
I previously discussed how there are various types of min/max operations for floating-point numbers in:
I also mentioned that AVX-512DQ supported the minNum/maxNum operations of IEEE 754-2008.
The newly added instructions correspond to the min/max operations of IEEE 754-2019. The instructions are:
VMINMAXNEPBF16
VMINMAX[PH,PS,PD]
VMINMAX[SH,SS,SD]
These seem to support scalar and vector for half-precision (binary16), single-precision (binary32), and double-precision (binary64), as well as vectors for BF16.
It's not quite clear where the "NE" in VMINMAXNEPBF16 comes from.
【Added October 10, 2025】 In the November 2024 version, "NE" and "P" were removed from the mnemonic for BF16 instructions, becoming VMINMAXBF16. 【End of addition】
Since WebAssembly has adopted "min/max operations that propagate input NaNs," Intel seems to be marketing this feature as "making it compatible for WebAssembly application development."
Saturated Conversion
When converting a floating-point number to a fixed-length integer type, what should be done with values that cannot be represented in the destination type? In traditional x86, the behavior was to fill all bits with 1s or return the minimum value of the two's complement representation. However, some programming languages specify other methods, as I wrote in:
I also covered this topic in "Binary Hacks Rebooted" (Promotion).
The newly added instructions convert to integer types using the following rules:
- Truncate the fractional part
- Return 0 for NaN
- For infinity or out-of-range values, return the maximum or minimum representable value
If you want to use a method other than truncation, you can combine it with other instructions.
According to Intel, these were added because they are required by WebAssembly and Rust. While I can see that for WebAssembly, I am not well-versed in Rust, so I cannot judge the validity of that claim.
In the past, they might have said "because it's needed for Java," so mentioning WebAssembly and Rust really highlights the flow of the times.
Zero-extending Partial Vector Copies
When copying 32-bit or 16-bit values stored in a SIMD register to another SIMD register, previously the only options were to copy the entire lower 128 bits, or to copy the 32-bit or 16-bit value while leaving the upper bits as they were (or copying them from another register). Now, an option to zero-clear the upper bits has been added.
VMOVD is for 32-bit values, and VMOVW is for 16-bit values.
While VMOVD and VMOVW have existed as instruction names for some time, they were previously used between a SIMD register and a general-purpose register (or memory), rather than between two SIMD registers.
For 64-bit values, (V)MOVQ has been available since earlier.
FP Scalar Comparison
I previously wrote an article about comparing floating-point numbers:
This time, the floating-point comparison instructions have been enhanced.
Previously, (v)(u)comis[h,s,d] instructions were used for floating-point comparisons. As for the meaning of u, (v)ucomisd is a comparison instruction that does not generate an exception even if a quiet NaN is included in the input. In all cases, the comparison results are stored in the ZF, PF, and CF flags of the EFLAGS register. Written in pseudo-code, it would look like this:
(v)(u)comisd(x, y) {
match compare(x, y) {
UNORDERED: ZF,PF,CF := 0b111;
GREATER_THAN: ZF,PF,CF := 0b000;
LESS_THAN: ZF,PF,CF := 0b001;
EQUAL: ZF,PF,CF := 0b100;
}
OF,AF,SF := 0b000;
}
The conditions for the flags to be set are as follows:
- ZF: Set in case of EQUAL or UNORDERED.
- PF: Set in case of UNORDERED.
- CF: Set in case of LESS_THAN or UNORDERED.
The relationship with conditional jump instructions is as follows:
| Mnemonic | Condition | Correspondence with floating-point comparison results |
|---|---|---|
| JA (above), JNBE (not below or equal) | CF=0 and ZF=0 | GREATER_THAN |
| JAE (above or equal), JNB (not below), JNC (not carry) | CF=0 | EQUAL or GREATER_THAN |
| JB (below), JC (carry), JNAE (not above or equal) | CF=1 | LESS_THAN or UNORDERED |
| JBE (below or equal), JNA (not above) | CF=1 or ZF=1 | EQUAL, LESS_THAN or UNORDERED |
| JE (equal), JZ (zero) | ZF=1 | EQUAL or UNORDERED |
| JG (greater), JNLE (not less or equal) | ZF=0 and SF=OF | LESS_THAN or GREATER_THAN |
| JGE (greater or equal), JNL (not less) | SF=OF | All |
| JL (less), JNGE (not greater or equal) | SF≠OF | None |
| JLE (less or equal), JNG (not greater) | ZF=1 or SF≠OF | EQUAL or UNORDERED |
| JNE (not equal) | ZF=0 | LESS_THAN or GREATER_THAN |
| JO (overflow) | OF=1 | None |
| JP (parity), JPE (parity even) | PF=1 | UNORDERED |
| JPO (parity odd) | PF=0 | EQUAL, LESS_THAN or GREATER_THAN |
| JS (sign) | SF=1 | None |
| Set of floating-point comparison results | Applicable instructions | Alternative method |
|---|---|---|
| EQUAL | ||
| LESS_THAN | Use JA or JNBE with operands reversed | |
| GREATER_THAN | JA, JNBE | |
| UNORDERED | JP, JPE | |
| {EQUAL, LESS_THAN} | Use JAE, JNB, or JNC with operands reversed | |
| {EQUAL, GREATER_THAN} | JAE, JNB, JNC | |
| {EQUAL, UNORDERED} | JE, JZ, JLE, JNG | |
| {LESS_THAN, GREATER_THAN} | JG, JNLE | |
| {LESS_THAN, UNORDERED} | JB, JC, JNAE | |
| {GREATER_THAN, UNORDERED} | Use JB, JC, or JNAE with operands reversed | |
| {EQUAL, LESS_THAN, GREATER_THAN} | JPO | |
| {EQUAL, LESS_THAN, UNORDERED} | JBE, JNA | |
| {EQUAL, GREATER_THAN, UNORDERED} | Use JBE or JNA with operands reversed | |
| {LESS_THAN, GREATER_THAN, UNORDERED} |
Looking at this, it is clear that "there is no single instruction that can execute a conditional jump based on equality (EQUAL) in one shot."
AVX10.2 adds a different set of instructions for floating-point comparisons. These use a different combination of set flags.
VCOMXSD
VCOMXSH
VCOMXSS
VUCOMXSD
VUCOMXSH
VUCOMXSS
The ones with a "U" in the instruction name do not trigger exceptions for quiet NaNs. In pseudo-code, it looks like this:
v(u)comxsd(x, y) {
match compare(x, y) {
UNORDERED: OF,SF,ZF,PF,CF := 0b11011;
GREATER_THAN: OF,SF,ZF,PF,CF := 0b00000;
LESS_THAN: OF,SF,ZF,PF,CF := 0b10001;
EQUAL: OF,SF,ZF,PF,CF := 0b11100;
}
AF := 0;
}
The conditions for the flags to be set are as follows:
- OF: Set in case of EQUAL, LESS_THAN, or UNORDERED.
- SF: Set in case of EQUAL or UNORDERED.
- ZF: Set in case of EQUAL.
- PF: Set in case of UNORDERED.
- CF: Set in case of LESS_THAN or UNORDERED.
The relationship with conditional jump instructions is as follows:
| Mnemonic | Condition | Correspondence with floating-point comparison results |
|---|---|---|
| JA (above), JNBE (not below or equal) | CF=0 and ZF=0 | GREATER_THAN |
| JAE (above or equal), JNB (not below), JNC (not carry) | CF=0 | EQUAL or GREATER_THAN |
| JB (below), JC (carry), JNAE (not above or equal) | CF=1 | LESS_THAN or UNORDERED |
| JBE (below or equal), JNA (not above) | CF=1 or ZF=1 | EQUAL, LESS_THAN or UNORDERED |
| JE (equal), JZ (zero) | ZF=1 | EQUAL |
| JG (greater), JNLE (not less or equal) | ZF=0 and SF=OF | UNORDERED |
| JGE (greater or equal), JNL (not less) | SF=OF | EQUAL or UNORDERED |
| JL (less), JNGE (not greater or equal) | SF≠OF | LESS_THAN |
| JLE (less or equal), JNG (not greater) | ZF=1 or SF≠OF | EQUAL or LESS_THAN |
| JNE (not equal) | ZF=0 | LESS_THAN, GREATER_THAN or UNORDERED |
| JO (overflow) | OF=1 | EQUAL, LESS_THAN or UNORDERED |
| JP (parity), JPE (parity even) | PF=1 | UNORDERED |
| JPO (parity odd) | PF=0 | EQUAL, LESS_THAN or GREATER_THAN |
| JS (sign) | SF=1 | EQUAL or UNORDERED |
| Set of floating-point comparison results | Applicable instructions | Alternative method |
|---|---|---|
| EQUAL | JE, JZ | |
| LESS_THAN | JL, JNGE | |
| GREATER_THAN | JA, JNBE | |
| UNORDERED | JG, JNLE, JP, JPE | |
| {EQUAL, LESS_THAN} | JLE, JNG | |
| {EQUAL, GREATER_THAN} | JAE, JNB, JNC | |
| {EQUAL, UNORDERED} | JGE, JNL, JS | |
| {LESS_THAN, GREATER_THAN} | ||
| {LESS_THAN, UNORDERED} | JB, JC, JNAE | |
| {GREATER_THAN, UNORDERED} | Use JB, JC, or JNAE with operands reversed | |
| {EQUAL, LESS_THAN, GREATER_THAN} | JPO | |
| {EQUAL, LESS_THAN, UNORDERED} | JBE, JNA, JO | |
| {EQUAL, GREATER_THAN, UNORDERED} | Use JBE, JNA, or JO with operands reversed | |
| {LESS_THAN, GREATER_THAN, UNORDERED} |
Consequently, using AVX10.2 makes it possible to concisely determine whether "floating-point numbers are equal."
Media Acceleration
New instructions for dot products of integers and FP16 (VNNI-style instructions) and EVEX versions of the sum of absolute difference instruction are being added:
VDPPHPS
VMPSADBW
VPDPB[SU,UU,SS]D[,S]
VPDPW[SU,US,SS]D[,S]
Summary and Promotion
I have provided a brief overview of the new features in AVX10.2.
I have included some promotions throughout this article; a book called "Binary Hacks Rebooted" will be released soon (at the end of August 2024), and I am one of the authors. Naturally, it doesn't include information on AVX10.2, but it does cover advanced topics on floating-point numbers and SIMD instructions, so anyone interested in this article will likely find it worth owning.
Discussion