9.7.1.13. Integer Arithmetic Instructions: min
min
Find the minimum of two values.
Syntax
min.type1 d, a, b;
min{.relu}.type2 d, a, b;
.type1 = { .u16, .u32, .u64,
.u16x2, .u8x4, .s16, .s64 };
.type2 = { .s16x2, .s32, .s8x4 };Description
Store the minimum of a and b in d.
For .u16x2, .s16x2 instruction types, forms input vectors by half word values from source operands. Half-word operands are then processed in parallel to produce .u16x2, .s16x2 result in destination.
For .u8x4, .s8x4 instruction types, input vectors are formed with quarter-word values from source operands. Quarter-word operands are then processed in parallel to store .u8x4, .s8x4 result in destination.
Operands d, a and b have the same type as the instruction type. For instruction types .u16x2, .s16x2, .u8x4, .s8x4, operands d, a and b have type .b32.
Semantics
if (type == u16x2 || type == s16x2) {
iA[0] = a[0:15];
iA[1] = a[16:31];
iB[0] = b[0:15];
iB[1] = b[16:31];
for (i = 0; i < 2; i++) {
d[i] = (iA[i] < iB[i]) ? iA[i] : iB[i];
}
} else if (type == u8x4 || type == s8x4) {
iA[0] = a[0:7];
iA[1] = a[8:15];
iA[2] = a[16:23];
iA[3] = a[24:31];
iB[0] = b[0:7];
iB[1] = b[8:15];
iB[2] = b[16:23];
iB[3] = b[24:31];
for (i = 0; i < 4; i++) {
d[i] = (iA[i] < iB[i]) ? iA[i] : iB[i];
}
} else {
d = (a < b) ? a : b; // Integer (signed and unsigned)
}Notes
Signed and unsigned differ.
Saturation modifier:
min.relu.{s8x4, s16x2, s32}clamps the result to 0 if negative.
PTX ISA Notes
Introduced in PTX ISA version 1.0.
min.u16x2, min{.relu}.s16x2 and min.relu.s32 introduced in PTX ISA version 8.0.
min.u8x4, min{.relu}.s8x4 introduced in PTX ISA version 9.2.
Target ISA Notes
Supported on all target architectures.
min.u16x2, min{.relu}.s16x2 and min.relu.s32 require sm_90 or higher.
min.u8x4, min{.relu}.s8x4 are supported on following family-specific architectures:
sm_107for higher in the same familysm_120for higher in the same family
Examples
min.s32 r0,a,b;
@p min.u16 h,i,j;
min.s16x2.relu u,v,w;
min.u8x4 p, q, r;