PTX ISA v9.4

9.7.3.5. Floating Point Instructions: mul

mul

Multiply two values.

Syntax

ptx
mul{.rnd}{.ftz}{.sat}.f32  d, a, b;
mul{.rnd}{.ftz}.f32x2      d, a, b;
mul{.rnd}.f64              d, a, b;

.rnd = { .rn, .rz, .rm, .rp };

Description

Compute the product of two values.

For .f32x2 instruction type, forms input vectors of single precision (.f32) values from source operands. Single precision (.f32) operands are then multiplied in parallel to produce .f32x2 result in destination.

For .f32x2 instruction type, operands d, a and b have .b64 type.

Semantics

ptx
if (type == f32 || type == f64) {
    d = a * b;
} else if (type == f32x2) {
    fA[0] = a[0:31];
    fA[1] = a[32:63];
    fB[0] = b[0:31];
    fB[1] = b[32:63];
    for (i = 0; i < 2; i++) {
        d[i] = fA[i] * fB[i];
    }
}

Notes

For floating-point multiplication, all operands must be the same size.

Rounding modifiers:

  • .rn — mantissa LSB rounds to nearest even
  • .rz — mantissa LSB rounds towards zero
  • .rm — mantissa LSB rounds towards negative infinity
  • .rp — mantissa LSB rounds towards positive infinity

The default value of rounding modifier is .rn. Note that a mul instruction with an explicit rounding modifier is treated conservatively by the code optimizer. A 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.

Subnormal numbers:

  • sm_20+
  • By default, subnormal numbers are supported.
  • mul.ftz.f32, mul.ftz.f32x2 flushes subnormal inputs and results to sign-preserving zero.
  • sm_1x
  • mul.f64 supports subnormal numbers.
  • mul.f32 flushes subnormal inputs and results to sign-preserving zero.

Saturation modifier:

mul.sat.f32 clamps the result to [0.0, 1.0]. NaN results are flushed to +0.0f.

PTX ISA Notes

Introduced in PTX ISA version 1.0.

mul.f32x2 introduced in PTX ISA version 8.6.

Target ISA Notes

mul.f32 supported on all target architectures.

mul.f64 requires sm_13 or higher.

Rounding modifiers have the following target requirements:

  • .rn, .rz
  • available for all targets
  • .rm, .rp
  • for mul.f64, requires sm_13 or higher.
  • for mul.f32, requires sm_20 or higher.

mul.f32x2 requires sm_100 or higher.

Examples

ptx
mul.ftz.f32 circumf,radius,pi  // a single-precision multiply
esc
Type to search across all documentation