System registers, votes, shuffles and barriers
fixed bit field field the encoding fixes should be
| 63 | 62 | 61 | 60 | 59 | 58 | 57 | 56 | 55 | 54 | 53 | 52 | 51 | 50 | 49 | 48 | 47 | 46 | 45 | 44 | 43 | 42 | 41 | 40 | 39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 |
| 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | [50:48] | mask | |||||||||||||||||
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| mode | mask | index | index | pred.not | pred | Ra | Rd | ||||||||||||||||||||||||
bits 63:48: 1110 1111 0001 0---
Runs execute_SHFL with Form() 0.
| Field | Bits | From |
|---|---|---|
| [50:48] | 50:48 | execute_SHFL |
| mask | 46:34 | execute_SHFL |
| mask | 46:39 | execute_SHFL |
| mode | 31:30 | execute_SHFL |
| mask | 29 | execute_SHFL |
| index | 28 | execute_SHFL |
| index | 24:20 | execute_SHFL |
| pred.not | 19 | the decoder |
| pred | 18:16 | the decoder |
| Ra | 15:8 | RegA() |
| Rd | 7:0 | Dst() |
SHFL: PTX's shfl.sync, the lane at 20 (an immediate with bit 28) and c (the mask) at 34 (an immediate with bit 29) or the register at 39: c's bits 8-12 split the lanes into segments, its bits 0-4 clamp the lane. Mode (30-31) 0 IDX, 1 UP, 2 DOWN, 3 BFLY. A quad's operation is the subgroup's own (QuadShfl), and a fragment's lone lane reads its quad through derivatives (ShflQuadLanes)
if QuadShfl() != 0 then {
let value = SubgroupQuad(R_read(RegA()), if QuadShfl() == 2 then 1 else 0, QuadShflOperand());
PredWrite(UInt(Field(48, 3)), true);
R_write(Dst(), value)
} else if QuadShflLanes() then ShflQuadLanes() else {
let index = if Field(28, 1) == 0b1 then ZeroExtend(Field(20, 5), 32) else R_read(RegB());
let mask = if Field(29, 1) == 0b1 then ZeroExtend(Field(34, 13), 32) else R_read(UInt(Field(39, 8)));
let lane_model = LaneModel();
let lane_full = if lane_model then LoneLane() else SubgroupLane();
let lane = lane_full & 0x0000001f;
let seg = (mask >> 8) & 0x0000001f;
let min_lane = lane & seg;
let max_lane = min_lane | (mask & (not_vec(seg) & 0x0000001f));
let mode = UInt(Field(30, 2));
let source_lane : bits(32) = match mode {
0 => min_lane | (index & not_vec(seg)),
1 => lane - index,
2 => lane + index,
_ => EOR(lane, index)
};
let valid = if mode == 1 then not_bool(UInt(lane - min_lane) < UInt(index))
else not_bool(UInt(max_lane) < UInt(source_lane));
let value = R_read(RegA());
PredWrite(UInt(Field(48, 3)), valid);
/* the lane model's lane alone: its own value, from its lane or one that runs nothing */
if lane_model then R_write(Dst(), value) else {
let host_lane = (lane_full & 0xffffffe0) | (source_lane & 0x0000001f);
let shuffled = SubgroupShuffle(value, host_lane);
R_write(Dst(), if valid then shuffled else value)
}
}
Made from ScarletNX's Sail at 166ad3910f80. The Sail and the encodings' file are ScarletNX's (GPL-3.0-or-later); its encodings are from Eden's maxwell.inc (GPL-2.0-or-later).