9.7.1.5. Integer Arithmetic Instructions: clmad
clmad
Perform carryless multiply and add operation.
Syntax
ptx
clmad.mode.u64 d, a, b, c;
.mode = { .hi, .lo };Description
Performs a carryless multiplication of a and b, followed by a carryless addition of c, and writes the result into destination register d.
All operands of clmad are unsigned 64-bit values.
The modifier .mode specifies which part of the carryless product is stored in the destination register:
.lo— Produces lower 64 bits of the product, with addition ofc..hi— Produces higher 64 bits of the product, with addition ofc.
Semantics
ptx
tmp[127:0] = 0; // 128-bit result of carryless multiplication.
for (i = 0; i < 64; i++) {
if ((a & (1 << i)) != 0) {
tmp ^= b << i;
}
}
// Select upper or lower 64 bits depending on the value of .mode.
if (.mode == .lo) {
d = tmp[63..0];
} else {
d = tmp[127..64];
}
d ^= c; // carryless accumulation.PTX ISA Notes
Introduced in PTX ISA version 9.3.
Target ISA Notes
Requires sm_80 or higher.
Examples
ptx
.reg .u64 Rd, Ra, Rb, Rc;
// Carryless multiply-add producing lower 64 bits of result.
clmad.lo.u64 Rd, Ra, Rb, Rc;
// Carryless multiply-add producing higher 64 bits of result.
clmad.hi.u64 Rd, Ra, Rb, Rc;