PTX ISA v9.4

9.7.6.3. Alternate Floating Point Instructions: mul

mul

Multiply two values.

Syntax

ptx
mul{.rnd}{.satfinite}.dtype.atype.ctype  d, a, c;

.dtype  = { .e5m2x4, .e4m3x4 };
.atype  = .ctype = { .e5m2x4, .e4m3x4, .e3m2x4, .e2m3x4, .e2m1x4, .e2m1p4x4, .ue8m0x4 };
.rnd    = { .rn };

Description

Performs multiplication and writes the resulting value into a destination register.

First forms input vectors by extracting four values of the specified type from packed source operands. These extracted input vectors are then multiplied in parallel with an infinite precision. The resulting values are then rounded to the destination type using the rounding mode specified by .rnd.

Operand d must be of type .b32. When .atype is .e2m1x4, operand a must be of type .b16; otherwise operand a must be of type .b32. Similarly, if .ctype is .e2m1x4, operand c must be of type .b16; otherwise it must be of type .b32.

Semantics

ptx
if (isF8x4(atype) || isUE8M0x4(atype)) {
    iA[0] = a[0:7];
    iA[1] = a[8:15];
    iA[2] = a[16:23];
    iA[3] = a[24:31];
} else if (isF6x4(atype)) {
    iA[0] = a[0:5];
    iA[1] = a[8:13];
    iA[2] = a[16:21];
    iA[3] = a[24:29];
} else if (isE2M1P4x4(atype)) {
    iA[0] = a[0:3];
    iA[1] = a[8:11];
    iA[2] = a[16:19];
    iA[3] = a[24:27];
} else if (isE2M1x4(atype)) {
    iA[0] = a[0:3];
    iA[1] = a[4:7];
    iA[2] = a[8:11];
    iA[3] = a[12:15];
}

if (isF8x4(ctype) || isUE8M0x4(ctype)) {
    iC[0] = c[0:7];
    iC[1] = c[8:15];
    iC[2] = c[16:23];
    iC[3] = c[24:31];
} else if (isF6x4(ctype)) {
    iC[0] = c[0:5];
    iC[1] = c[8:13];
    iC[2] = c[16:21];
    iC[3] = c[24:29];
} else if (isE2M1P4x4(ctype)) {
    iC[0] = c[0:3];
    iC[1] = c[8:11];
    iC[2] = c[16:19];
    iC[3] = c[24:27];
} else if (isE2M1x4(ctype)) {
    iC[0] = c[0:3];
    iC[1] = c[4:7];
    iC[2] = c[8:11];
    iC[3] = c[12:15];
}

for (i = 0; i < 4; i++) {
    d[i] = iA[i] * iC[i];
}

Notes

mul with .e5m2x4, .e4m3x4 computes the product of the operands to infinite precision. The product is then rounded to the nearest representation in the destination format.

Rounding modifier:

  • .rn — round to nearest with ties to even

The default value of rounding modifier is .rn. Note that mul instruction with an explicit rounding modifier is treated conservatively by the code optimizer. An mul instruction with no rounding modifier defaults to round-to-nearest-even and may be optimized aggressively by the code optimizer. In particular, mul/add and mul/sub sequences with no rounding modifiers may be optimized to use fused-multiply-add instructions on the target device.

Saturation modifier:

  • .satfinite: If the absolute value of output (ignoring sign) is greater than MAX_NORM of the specified destination format, then the result is sign-preserved MAX_NORM of the destination format. In absence of .satfinite for .e4m3x4 destination format, results beyond the largest representable target format are converted to NaN.

PTX ISA Notes

mul with .e5m2x4, .e4m3x4, .e3m2x4, .e2m3x4, .e2m1x4, .e2m1p4x4, .ue8m0x4 as instruction types introduced in PTX ISA version 9.4.

Target ISA Notes

mul with .e5m2x4, .e4m3x4, .e3m2x4, .e2m3x4, .e2m1x4, .e2m1p4x4, .ue8m0x4 as instruction types is supported on the following architectures:

  • sm_100a
  • sm_103a

Examples

ptx
.reg .b32 rd, ra, rc;

// multiplication of f6x4 with f4x4 to obtain f8x4
mov.b32 ra, {ba0, ba1, ba2, ba3}; // pack four f6 as f6x4
.reg .b16 rc16;
mov.b16 rc16, {bc0, bc1};         // pack four f4 as f4x4 in .b16 operand
mul.rn.e5m2x4.e3m2x4.e2m1x4.satfinite rd, ra, rc16; // SIMD multiplication

// multiplication of ue8m0x4 with f8x4 to obtain f8x4
mov.b32 ra, {ba0, ba1, ba2, ba3}; // pack four ue8m0 values
mov.b32 rc, {bc0, bc1, bc2, bc3}; // pack four f8 as f8x4
mul.rn.e4m3x4.ue8m0x4.e5m2x4 rd, ra, rc; // SIMD multiplication

// multiplication of f6x4 with f6x4 to obtain f8x4
mov.b32 ra, {ba0, ba1, ba2, ba3}; // pack four f6 as f6x4
mov.b32 rc, {bc0, bc1, bc2, bc3}; // pack four f6 as f6x4
mul.rn.e5m2x4.e3m2x4.e2m3x4.satfinite rd, ra, rc; // SIMD multiplication
esc
Type to search across all documentation