Repository navigation
asahi: fold horizontal sums of packed bytes - #1542
RyanTheTide wants to merge 1 commit into
Conversation
Add agx_nir_fold_w8_byte_sum() for AGX3B and AGX3C (!emit_agx3d): when an iadd reduction tree in a block sums all 3 or 4 u2u32 lanes of one or more packed R8_UINT device loads (with >=2 loads or at least one vec4 load), keep each load as a single packed 32-bit word (via AGX_NIR_MEMORY_PACKED_COUNT_SHIFT) and accumulate up to 32 words in two 16-bit SWAR lanes (max 32 * 510 = 16320 <= 65535, zero cross-lane carry) before one final (s & 0xffff) + (s >> 16) reduction. Preserves exact mod-2^32 semantics while cutting per-byte unpack ALU and improving load batching. Signed-off-by: Diljit Singh <hey@djdev.me> (cherry picked from commit 179980b) (cherry picked from commit 8bf65d33f3f9be031e4bb442423e31ff5da29bc6)
|
Tested exact head
Scope note: this row covers the native AArch64 assert-enabled compiler/unit test suite (including |
|
J713 (M4 Air, G16G B0) saved fleet94 on exact The byte-store parent has a measured J713 reverse-store slowdown. I’m testing this byte-sum change directly on aurora-wip and will link the replacement here. |
What
Carry the horizontal W8 byte sum from #804 with Dj’s sign-off. Retain the load as a packed word for a full-vector sum and accumulate the byte totals in two 16-bit lanes before folding them together. The pass leaves partial-vector consumers intact.
Tested
Exact head
54cd94a79dedaon byte-store parente135858eb62b4: AArch64 Vulkan build, 1,960 host compiler passes with one skip and 66 focused tests. Neo J700 G17P used saved7.3.0-aurora-fleet94. Each process verified 524,288 CPU reference outputs and 524,288 padding words.Isolated via per-arm
VK_DRIVER_FILESandMESA_SHADER_CACHE_DISABLE=1. Commands./store-aarch64 1 2,./store-aarch64 1 3and./store-aarch64 1 4. Four alternating ABBA/BAAB blocks per shape, 20 GPU timestamps per process after four warmups.The two-vector case improved in all four blocks. NIR switched the complete reductions to packed loads and kept the partial-vector load as before. The emitted shader shrank from 586 to 488 bytes. Neo stayed on the same saved boot with Enforcing, zero failed units and no kernel entries.
Risk
Two-way · AGX3B and AGX3C shaders that sum packed W8 vectors.
Shader and individual GPU samples
Exact-head run