Skip to content

asahi: fold horizontal sums of packed bytes - #1548

Merged
DjDeveloperr merged 2 commits into
aurora-wipfrom
perf/closeout-804-byte-sum-trunk
Dec 2, 2026
Merged

DjDeveloperr merged 2 commits into
aurora-wipfrom
perf/closeout-804-byte-sum-trunk

Conversation

@RyanTheTide

Copy link
Copy Markdown

What

Carry the horizontal W8 byte sum from #804 directly on aurora-wip, preserving Dj’s sign-off. This supersedes stacked #1542. Complete reductions keep the load as a packed word and accumulate in two 16-bit lanes. Partial-vector consumers keep the original path.

Tested

Exact head 0de2e7b1b9ba passed AArch64 Vulkan build, 1,960 compiler tests with one skip, 103 focused checks and 44 policy checks. Baseline ICD e20bc7252c2e is tree-identical to aurora-wip c94b25ce4e2f. Same saved 7.3.0-aurora-fleet94 boot on each Mac, with per-arm VK_DRIVER_FILES and MESA_SHADER_CACHE_DISABLE=1. Every process verified 524,288 CPU results and 524,288 padding words.

Mac and case Base pooled median (ns) Head pooled median (ns) Median paired change
Neo G17P, one vector 38,896 38,959 +0.11%
Neo G17P, two vectors 39,521 39,083 −1.26%
Neo G17P, partial-vector control 39,208 39,188 +0.08%
J713 G16G, two vectors, 256-dispatch batch 4,539,438 4,483,229 −2.84%

Neo ran four balanced ABBA/BAAB blocks per mode with ./store-aarch64 1 2, 1 3 and 1 4, 20 GPU timestamps after four warmup dispatches. J713 ran eight balanced blocks of ./store-aarch64 1 3, with 256 dispatches per sample after 24 warmup batches. Two J713 blocks varied slightly above zero (+0.15%, +0.32%). The main shader shrank from 586 to 488 bytes on both Macs. Saved boot, Enforcing, zero failed units and no new kernel entries on both.

Risk

Two-way · Asahi packed W8 sums on AGX3B and AGX3C.

Shader and individual GPU samples
#version 450
#extension GL_EXT_shader_8bit_storage : require
layout(local_size_x = 64) in;
layout(push_constant) uniform Params { int unused; int start; int end; };
layout(set = 0, binding = 1, std430) readonly buffer Input { u8vec4 src[]; };
layout(set = 0, binding = 2, std430) writeonly buffer Output { uint dst[]; };

void main()
{
    uint i = gl_GlobalInvocationID.x;
    int mode = end - start;
    if (mode == 2) {
        uvec4 a = uvec4(src[i]);
        dst[i] = a.x + a.y + a.z + a.w;
    } else if (mode == 3) {
        uvec4 a = uvec4(src[i]);
        uvec4 b = uvec4(src[i ^ 1u]);
        dst[i] = a.x + a.y + a.z + a.w + b.x + b.y + b.z + b.w;
    } else {
        uvec4 a = uvec4(src[i]);
        dst[i] = a.x + a.y + a.z;
    }
}

Neo

1x2	1	base	39208,38834,39000,38875,38625,39583,38667,38875,39041,38584,38708,39042,38958,38875,39041,39042,39375,38542,38875,38875
1x2	2	head	39125,39000,38708,38958,39250,38917,39167,39292,39584,38750,39042,38583,38792,38583,38959,38708,39500,38834,38959,38791
1x2	3	head	39667,39125,38708,38708,39792,39542,40042,39250,39625,39708,39625,38833,39250,38958,39541,39375,39500,39375,39000,39334
1x2	4	base	39958,38916,38708,38625,38333,39375,39375,38833,38500,38500,38708,38541,38292,38125,38625,38708,39500,38292,38916,38292
1x2	5	head	39208,37959,39042,39166,38875,38875,39209,38875,39042,39333,39250,38875,38666,39375,39292,39208,38542,38500,38584,38833
1x2	6	base	39042,38542,38417,38750,38625,38875,38833,38084,39083,38500,38541,39041,38666,38708,39042,39041,38792,38750,38792,38875
1x2	7	base	39375,38750,38583,38250,38833,38750,38875,39083,39083,38500,38416,38458,38875,38250,39167,38750,39000,38458,38458,38250
1x2	8	head	39042,38875,38708,39833,39209,38833,39083,39333,38875,38917,38917,38959,38792,39042,39500,39375,39125,38583,38750,38750
1x2	9	base	39417,39292,39250,39542,39416,39583,39500,39459,40083,38833,39167,38750,39166,40000,40000,39541,39250,39458,39500,39375
1x2	10	head	39125,39000,39041,38833,38709,39000,39167,39792,39125,39000,39500,39375,39333,38666,39042,39250,38958,39000,39083,38959
1x2	11	head	38834,38792,39000,38958,38417,38917,38750,38458,38958,38250,38458,38958,38833,38500,39083,39542,39166,38875,38791,38959
1x2	12	base	39083,38958,39458,38833,38875,39250,38833,39083,39458,39125,39125,38875,39125,39541,38667,39125,38916,39333,38917,38708
1x2	13	head	39166,39125,38917,38875,38709,39250,38916,39167,38833,38792,38750,39250,38959,38959,39208,39084,39208,38667,38792,38833
1x2	14	base	39875,38875,38625,38584,38875,39000,39334,38750,38458,38584,38833,39334,38583,38667,38792,39083,38958,38833,38625,38542
1x2	15	base	39375,38667,39334,39042,39166,39542,39041,39459,39583,39042,39542,38958,38708,38708,39125,39292,39750,39333,39417,39625
1x2	16	head	39250,39041,39417,38834,38667,38750,38917,38958,38666,38917,38500,39250,38666,38500,39250,39000,38833,38958,39250,38750
1x3	1	base	40084,39667,39583,40125,40042,39459,39667,39792,39875,39458,39834,39708,39125,39292,39750,39542,39459,39584,39500,38917
1x3	2	head	39375,39125,38625,38958,38875,38792,39208,39417,39000,39416,38750,38834,39000,38875,39125,39209,38709,38834,39084,39208
1x3	3	head	39375,39042,39042,39292,38708,38792,39417,38750,39833,39083,38875,39000,39167,39541,39250,39000,39125,38917,38916,39792
1x3	4	base	39709,39084,39417,39291,39209,39917,39958,39042,39625,39166,39375,39000,39333,39584,39458,39584,39792,39500,39541,39375
1x3	5	head	39125,39042,38959,38875,38583,39000,39333,39042,39042,39208,39083,39042,39000,38875,39125,38875,39000,39041,39084,39167
1x3	6	base	40208,39375,39500,39125,39375,38792,39000,40000,39583,39042,39250,38959,39291,39291,39875,38958,39334,40167,39292,39042
1x3	7	base	39833,39833,39208,39458,39292,39792,39500,39500,39333,39125,39709,39000,39667,39167,39458,50375,39959,39709,39500,39250
1x3	8	head	39208,38959,39292,39000,38750,39375,39541,39250,38875,38959,39584,39125,38750,38708,39250,39125,39750,39041,39333,38583
1x3	9	base	39250,39083,39750,40542,39500,39750,39917,39750,39667,39666,39291,39417,39208,39917,40000,39708,39583,39083,39375,39167
1x3	10	head	39083,39542,39042,39084,39125,38959,39083,39250,39125,39042,38792,39125,39292,38958,39166,38959,39542,39250,38959,38875
1x3	11	head	39625,38625,38666,38500,39084,39417,39667,39500,39417,39250,38875,39250,39250,39000,39250,39500,39417,39083,39000,38916
1x3	12	base	39458,40208,39959,40416,39833,39708,39917,40041,40000,39292,39542,39792,39292,39958,39791,40083,39792,39917,40083,39542
1x3	13	head	38792,38583,38833,39583,38875,38625,39625,39208,39083,38625,38625,38833,38666,39375,39666,39167,39167,38833,38708,39500
1x3	14	base	39542,39250,39750,39625,39334,39500,39708,39250,39584,39666,39375,39916,39500,39291,39541,40000,39584,39333,39750,39792
1x3	15	base	39708,39084,39500,39375,39625,39291,39458,39459,39417,39708,38833,39500,39625,39625,39584,39209,39375,39333,39375,39000
1x3	16	head	39375,38792,39416,39250,39125,38792,38542,38709,39000,39083,38958,39000,39125,39250,38959,39292,39250,38750,38500,39375
1x4	1	base	39208,39583,39334,39208,39541,39541,39584,39083,39000,38792,38833,39542,39375,39375,39333,39416,39375,38875,38833,39125
1x4	2	head	40458,39292,39208,39667,38916,39791,39208,39167,39417,39333,39584,39417,39083,39125,39666,39333,39833,38833,39042,38875
1x4	3	head	39292,38334,39000,39459,39500,39583,39417,38667,39791,39416,39125,38833,39042,38875,39500,39250,39500,39125,39125,39708
1x4	4	base	39375,38833,39167,39208,38583,38833,39125,39458,39250,38958,39083,39042,39500,39333,39125,39084,39000,38792,38917,39000
1x4	5	head	39292,39250,38875,38750,38708,38708,39458,39042,39000,38709,39292,38917,39416,38417,39167,38542,38959,39000,38458,38917
1x4	6	base	39250,39333,38875,39000,38958,38750,38750,39208,39041,39083,39292,38541,39167,38834,38791,39208,39000,38375,39000,39125
1x4	7	base	39709,39625,39833,39959,39125,39125,39667,40042,39583,39292,39334,39375,39916,39125,39791,39208,39541,39667,39458,39792
1x4	8	head	39209,39000,39541,39000,39333,39250,39334,39250,38833,38917,38833,39084,39292,38958,39375,39375,39541,39042,39542,38666
1x4	9	base	39333,39292,38792,39209,38875,38667,38959,39334,38834,38667,39084,39125,38875,38833,39084,39292,39000,39250,38708,39541
1x4	10	head	38292,39084,38750,39084,38875,38917,39000,39625,39416,39084,39458,38709,38959,39167,39708,39125,38875,38958,39292,38875
1x4	11	head	39750,39125,39042,39250,39083,39167,40042,39459,39542,39292,39417,38834,39125,39167,39375,39542,39167,39500,39375,39125
1x4	12	base	39375,39333,39083,39042,38959,39750,39750,39417,39416,39125,39209,40125,39292,39250,39458,39333,39667,39500,39250,39208
1x4	13	head	39375,39125,39708,40041,39542,38792,39333,38833,39417,39458,39125,39459,39875,39500,40083,39375,38875,38917,38959,39208
1x4	14	base	39041,39584,39208,38792,39167,39166,39583,39541,39334,38791,39208,39292,39333,39125,39292,39584,38958,39583,39125,39333
1x4	15	base	38833,38917,39000,38542,38875,39167,38791,38959,38500,39292,39083,38667,39084,39083,39333,39292,39458,39250,38834,38875
1x4	16	head	39333,38958,38791,39667,39375,38916,39583,39541,39416,38917,39083,39334,39500,38792,39458,39542,39542,38958,38834,39167

J713

1x3	1	base	5.17471e+06,5.19096e+06,5.19342e+06,5.17471e+06,5.19012e+06,5.19e+06,5.17883e+06,5.18858e+06,5.18312e+06,5.19358e+06,5.16946e+06,5.183e+06,5.18479e+06,5.18421e+06,5.17367e+06,5.17646e+06,5.18208e+06,5.18108e+06,5.17742e+06,5.18308e+06
1x3	2	head	4.63462e+06,4.64833e+06,4.64975e+06,4.65158e+06,4.64433e+06,4.64792e+06,4.64854e+06,4.64542e+06,4.645e+06,4.65183e+06,4.64404e+06,4.64788e+06,4.66004e+06,4.64258e+06,4.654e+06,4.64562e+06,4.64821e+06,4.646e+06,4.64475e+06,4.64504e+06
1x3	3	head	4.52821e+06,4.52196e+06,4.52021e+06,4.52158e+06,4.52512e+06,4.52017e+06,4.53762e+06,4.51871e+06,4.52879e+06,4.51371e+06,4.51892e+06,4.51983e+06,4.51938e+06,4.50925e+06,4.52529e+06,4.51133e+06,4.51504e+06,4.5075e+06,4.50992e+06,4.51308e+06
1x3	4	base	4.47062e+06,4.46146e+06,4.47929e+06,4.47688e+06,4.476e+06,4.473e+06,4.45912e+06,4.476e+06,4.47721e+06,4.48692e+06,4.47558e+06,4.48262e+06,4.48096e+06,4.46188e+06,4.47704e+06,4.47121e+06,4.484e+06,4.47942e+06,4.49471e+06,4.45646e+06
1x3	5	head	4.67821e+06,4.66446e+06,4.66925e+06,4.68962e+06,4.67421e+06,4.66717e+06,4.66846e+06,4.66608e+06,4.67771e+06,4.66712e+06,4.67229e+06,4.67962e+06,4.66475e+06,4.66692e+06,4.66933e+06,4.67796e+06,4.67071e+06,4.67012e+06,4.67979e+06,4.66412e+06
1x3	6	base	4.66325e+06,4.65646e+06,4.65504e+06,4.65329e+06,4.64525e+06,4.65321e+06,4.64942e+06,4.65871e+06,4.65517e+06,4.64858e+06,4.65392e+06,4.65492e+06,4.64875e+06,4.64812e+06,4.65321e+06,4.6435e+06,4.63996e+06,4.64738e+06,4.63962e+06,4.63917e+06
1x3	7	base	4.64525e+06,4.64279e+06,4.64267e+06,4.64554e+06,4.64371e+06,4.65729e+06,4.64988e+06,4.65321e+06,4.64708e+06,4.649e+06,4.645e+06,4.64708e+06,4.64658e+06,4.63983e+06,4.65038e+06,4.64604e+06,4.64304e+06,4.64067e+06,4.63879e+06,4.63392e+06
1x3	8	head	4.56575e+06,4.55829e+06,4.56971e+06,4.57488e+06,4.56588e+06,4.56067e+06,4.57179e+06,4.57392e+06,4.56779e+06,4.56779e+06,4.57067e+06,4.56446e+06,4.57012e+06,4.565e+06,4.56304e+06,4.57867e+06,4.56042e+06,4.56925e+06,4.56971e+06,4.56721e+06
1x3	9	base	4.56192e+06,4.59258e+06,4.56858e+06,4.56979e+06,4.57104e+06,4.58242e+06,4.56379e+06,4.57667e+06,4.56467e+06,4.56792e+06,4.57121e+06,4.56638e+06,4.56338e+06,4.55925e+06,4.57288e+06,4.56942e+06,4.575e+06,4.56429e+06,4.56562e+06,4.56525e+06
1x3	10	head	4.49979e+06,4.50317e+06,4.50208e+06,4.50167e+06,4.49917e+06,4.50108e+06,4.50292e+06,4.50079e+06,4.50204e+06,4.50462e+06,4.49775e+06,4.49758e+06,4.49879e+06,4.49692e+06,4.49792e+06,4.5015e+06,4.49908e+06,4.49771e+06,4.50167e+06,4.49746e+06
1x3	11	head	4.36346e+06,4.36029e+06,4.36271e+06,4.36025e+06,4.35946e+06,4.36083e+06,4.36071e+06,4.35812e+06,4.36396e+06,4.35233e+06,4.36083e+06,4.36475e+06,4.35688e+06,4.362e+06,4.36538e+06,4.35783e+06,4.35667e+06,4.36375e+06,4.36388e+06,4.36596e+06
1x3	12	base	4.51592e+06,4.512e+06,4.509e+06,4.51054e+06,4.503e+06,4.51267e+06,4.51575e+06,4.51742e+06,4.51304e+06,4.51604e+06,4.51225e+06,4.51558e+06,4.51321e+06,4.51825e+06,4.50858e+06,4.51475e+06,4.51362e+06,4.51708e+06,4.50854e+06,4.51188e+06
1x3	13	head	4.457e+06,4.47029e+06,4.47762e+06,4.46842e+06,4.47746e+06,4.47879e+06,4.47396e+06,4.48262e+06,4.46021e+06,4.48517e+06,4.46796e+06,4.46933e+06,4.469e+06,4.46808e+06,4.46575e+06,4.46571e+06,4.45692e+06,4.466e+06,4.46612e+06,4.45546e+06
1x3	14	base	4.84096e+06,4.80129e+06,4.78646e+06,4.79279e+06,4.83338e+06,4.78329e+06,4.81971e+06,4.84933e+06,4.79754e+06,4.80146e+06,4.8685e+06,4.82025e+06,4.81025e+06,4.82633e+06,4.81025e+06,4.80688e+06,4.84925e+06,4.83796e+06,4.80638e+06,4.82296e+06
1x3	15	base	4.54129e+06,4.55158e+06,4.54721e+06,4.54238e+06,4.54758e+06,4.558e+06,4.53925e+06,4.543e+06,4.54254e+06,4.54021e+06,4.5565e+06,4.5585e+06,4.55e+06,4.554e+06,4.54558e+06,4.55088e+06,4.54808e+06,4.55175e+06,4.55325e+06,4.55675e+06
1x3	16	head	4.48925e+06,4.49196e+06,4.49229e+06,4.49238e+06,4.49429e+06,4.48962e+06,4.48383e+06,4.49125e+06,4.4895e+06,4.48246e+06,4.49292e+06,4.49317e+06,4.48662e+06,4.48775e+06,4.49692e+06,4.48717e+06,4.48946e+06,4.48792e+06,4.49112e+06,4.49217e+06
1x3	17	base	4.425e+06,4.4435e+06,4.44812e+06,4.45258e+06,4.45321e+06,4.443e+06,4.42671e+06,4.4325e+06,4.4615e+06,4.44442e+06,4.42571e+06,4.44838e+06,4.44038e+06,4.43775e+06,4.44338e+06,4.456e+06,4.447e+06,4.42738e+06,4.44788e+06,4.45283e+06
1x3	18	head	4.40604e+06,4.41821e+06,4.42133e+06,4.42817e+06,4.41762e+06,4.41133e+06,4.40629e+06,4.41021e+06,4.41854e+06,4.43583e+06,4.42512e+06,4.40854e+06,4.42896e+06,4.43304e+06,4.41612e+06,4.42492e+06,4.42775e+06,4.41754e+06,4.42517e+06,4.43238e+06
1x3	19	head	4.5795e+06,4.56104e+06,4.56496e+06,4.57142e+06,4.58742e+06,4.58133e+06,4.58658e+06,4.583e+06,4.58188e+06,4.57921e+06,4.581e+06,4.57833e+06,4.58521e+06,4.5455e+06,4.57288e+06,4.58642e+06,4.58333e+06,4.58221e+06,4.59217e+06,4.57588e+06
1x3	20	base	4.50912e+06,4.50925e+06,4.50679e+06,4.50942e+06,4.50662e+06,4.51496e+06,4.50921e+06,4.50846e+06,4.50796e+06,4.51938e+06,4.51462e+06,4.52229e+06,4.52133e+06,4.52633e+06,4.51496e+06,4.52071e+06,4.50979e+06,4.50988e+06,4.51771e+06,4.51146e+06
1x3	21	head	4.42467e+06,4.44158e+06,4.43908e+06,4.42692e+06,4.42833e+06,4.43946e+06,4.44883e+06,4.43296e+06,4.42583e+06,4.45158e+06,4.43938e+06,4.43262e+06,4.42829e+06,4.44354e+06,4.44208e+06,4.43825e+06,4.46012e+06,4.43946e+06,4.4375e+06,4.43392e+06
1x3	22	base	4.51871e+06,4.51412e+06,4.51579e+06,4.50775e+06,4.52138e+06,4.52167e+06,4.52338e+06,4.50583e+06,4.51604e+06,4.51329e+06,4.51054e+06,4.51354e+06,4.51629e+06,4.52146e+06,4.5215e+06,4.51679e+06,4.51758e+06,4.50967e+06,4.52175e+06,4.51383e+06
1x3	23	base	4.52279e+06,4.51712e+06,4.52483e+06,4.52342e+06,4.51696e+06,4.52796e+06,4.51688e+06,4.53292e+06,4.52492e+06,4.51838e+06,4.51854e+06,4.52712e+06,4.52754e+06,4.52133e+06,4.522e+06,4.52308e+06,4.52454e+06,4.52146e+06,4.51638e+06,4.52454e+06
1x3	24	head	4.61858e+06,4.62479e+06,4.60871e+06,4.62196e+06,4.61017e+06,4.61658e+06,4.61946e+06,4.62283e+06,4.62358e+06,4.62475e+06,4.61104e+06,4.62279e+06,4.62362e+06,4.62479e+06,4.61596e+06,4.62812e+06,4.62717e+06,4.62996e+06,4.615e+06,4.616e+06
1x3	25	base	4.52321e+06,4.52417e+06,4.5035e+06,4.5285e+06,4.51192e+06,4.521e+06,4.51929e+06,4.51575e+06,4.51688e+06,4.51958e+06,4.52504e+06,4.52454e+06,4.51933e+06,4.53962e+06,4.51842e+06,4.51946e+06,4.52567e+06,4.52679e+06,4.52917e+06,4.52388e+06
1x3	26	head	4.41271e+06,4.41371e+06,4.42129e+06,4.39775e+06,4.40771e+06,4.39454e+06,4.42217e+06,4.39929e+06,4.41104e+06,4.41067e+06,4.40846e+06,4.42158e+06,4.40596e+06,4.39654e+06,4.41104e+06,4.40192e+06,4.41458e+06,4.40079e+06,4.40442e+06,4.39788e+06
1x3	27	head	4.42938e+06,4.40671e+06,4.41375e+06,4.40104e+06,4.41725e+06,4.40367e+06,4.40246e+06,4.41183e+06,4.41496e+06,4.40425e+06,4.408e+06,4.42362e+06,4.398e+06,4.41375e+06,4.41192e+06,4.41354e+06,4.41896e+06,4.41962e+06,4.42342e+06,4.42054e+06
1x3	28	base	4.63496e+06,4.62879e+06,4.63646e+06,4.63838e+06,4.62825e+06,4.63817e+06,4.62838e+06,4.63596e+06,4.63258e+06,4.64488e+06,4.63267e+06,4.64304e+06,4.64325e+06,4.63479e+06,4.63421e+06,4.63988e+06,4.63125e+06,4.63554e+06,4.62862e+06,4.63475e+06
1x3	29	head	4.40462e+06,4.40575e+06,4.40725e+06,4.40817e+06,4.40708e+06,4.40225e+06,4.3995e+06,4.40379e+06,4.4125e+06,4.41508e+06,4.40888e+06,4.40488e+06,4.40179e+06,4.40517e+06,4.40758e+06,4.41725e+06,4.40854e+06,4.41358e+06,4.40904e+06,4.40842e+06
1x3	30	base	4.70933e+06,4.71796e+06,4.71583e+06,4.72083e+06,4.70746e+06,4.71592e+06,4.68788e+06,4.72254e+06,4.70717e+06,4.71946e+06,4.70025e+06,4.71812e+06,4.716e+06,4.72621e+06,4.71904e+06,4.70642e+06,4.71592e+06,4.712e+06,4.72462e+06,4.71633e+06
1x3	31	base	4.46612e+06,4.48838e+06,4.474e+06,4.48208e+06,4.49033e+06,4.46242e+06,4.46912e+06,4.48792e+06,4.47312e+06,4.48238e+06,4.46783e+06,4.48138e+06,4.47504e+06,4.47812e+06,4.48683e+06,4.47358e+06,4.47862e+06,4.46888e+06,4.48367e+06,4.47375e+06
1x3	32	head	4.47629e+06,4.45971e+06,4.45896e+06,4.47683e+06,4.45954e+06,4.47288e+06,4.45975e+06,4.46246e+06,4.46225e+06,4.46583e+06,4.46021e+06,4.47158e+06,4.46796e+06,4.46979e+06,4.46058e+06,4.467e+06,4.48046e+06,4.45754e+06,4.47942e+06,4.46962e+06

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)
(cherry picked from commit 54cd94a)
@satchlj

satchlj commented Dec 2, 2026

Copy link
Copy Markdown
Member

Exact-head M5 Max (J775c, G17C B1, Borealis Vulkan) verification at 0de2e7b1b9ba on aurora-silicon/linux@main ef557c14eb37 (7.3.0-1-57.20261202-ARCH, default command line):

  • Assert-enabled build & host tests (-Dbuildtype=debugoptimized -Db_ndebug=false): 330/330 Meson tests OK; targeted agx_tests (*Swar*:*W8*:*Byte*:*Vision*:*Wave8*) 184/184 PASS, including AGX3VisionOpts.Wave8SwarW8ByteSum and U8x4Hsum.SwarByteSumPositiveAndNegativeCases.
  • Vulkan CTS (exact-head ICD, MESA_SHADER_CACHE_DISABLE=1): dEQP-VK.api.smoke.* 8/8, dEQP-VK.subgroups.basic.compute.* 12/12, dEQP-VK.subgroups.ballot.compute.* 2/2 PASS.
  • gpubench-rt-vk (release exact-head ICD, MESA_SHADER_CACHE_DISABLE=1): raster 2,226.98 fps (crc32=cca69c73), medium 137.4 fps / 337.3 Mray/s (crc32=e91ea686).
  • ABBA llama-bench (Llama-2-7B Q4_0, -fa 1 -p 128,512 -n 32 -r 3, release builds of exact parent c94b25ce4e2f vs exact head 0de2e7b1b9ba, MESA_SHADER_CACHE_DISABLE=1):
    • pp128: 3,022.65 vs 3,027.55 t/s (+0.16%)
    • pp512: 3,528.11 vs 3,530.57 t/s (+0.07%)
    • tg32: 122.48 vs 122.62 t/s (+0.12%)
  • Kernel health: 0 GPU faults, 0 kernel oops/warnings in dmesg.

Note: standalone synthetic W8 byte-sum microbenchmark was not run on this machine; verification covers compiler tests, Vulkan CTS, ray-tracing scene, and LLM no-regression on G17C B1.

@RyanTheTide

Copy link
Copy Markdown
Author

The exact #1548 head 0de2e7b1b9ba applies cleanly to aurora-wip at c3adfe792ec0 after #1549, with an unchanged patch. The assert-enabled host compiler suite on the local integration tree passed 1,961 tests with one skip and zero failures. The SWAR byte-sum cases and #1549's inclusive-ballot regression test passed together. The PR head is unchanged.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes needed: the new byte-sum fold crashes the compiler on valid shaders when the same sum also adds one component of a vector value.

agx_nir_fold_w8_byte_sum() in src/asahi/compiler/agx_compile.c walks the iadd tree with stack[sp++] = ...src[i].src.ssa and rebuilds the sum from extras[]. It keeps each leaf's SSA def but drops src.swizzle[0], so a leaf such as w.y comes back as the whole vector w and the rebuilt sum becomes a vector iadd.

Failing compute shader (src is u8vec4[], words is uvec4[]):

uvec4 a = uvec4(src[i]);
uvec4 w = words[i];
dst[i] = w.x + w.y + w.z + w.w + a.x + a.y + a.z + a.w;

Expected: it compiles and stores w.x + w.y + w.z + w.w plus the four bytes. At 0de2e7b the NIR after the pass has 32x4 %30 = iadd %6, %6 through 32x4 %34 = iadd %33, %29.xxxx, and validation fails on the store_agx (src->ssa->num_components == num_components). Base c94b25c compiles it, and the merge with aurora-wip c3adfe7 fails the same way. The compiler also crashes on G15G, G16G and G17P for (v.y + a.x + a.y + a.z + a.w) ^ v.x with a uvec2 v (assert in agx_emit_alu), and on G17S with two u8vec3 loads. G14G and G18G are unchanged.

Fix: keep each leaf as a nir_scalar (def plus component), the way agx_nir_opt_u8x4_hsum() does, and re-add it with nir_channel(). Or skip the tree when any leaf has more than one component. A test case with a uvec4 addend would cover it.

Small: the new code went in between fold_w8_word_unpack()'s comment and that function.

Everything else checked out on pc (x86_64, drm-shim, assert-enabled build):

  • Meson asahi, poly and vulkan suites: 454 pass, 0 fail, 1 skip at base, at head and on the merge with c3adfe7.
  • agx_tests: 1,959 pass at base, 1,960 at head and 1,961 on the merge.
  • GTA V shader-db (12,868 executables per chip): 0 changes and 0 crashes on G17P, G16G, G15G, G17S and G14G.
  • The PR's own shader drops from 57 to 48 instructions on G16G and G17P. M3 (G15G) is AGX3B too, so its code changes as well (67 to 58), but it has no hardware row yet.

An iadd source can select a single component of a vector SSA
definition. Track both the definition and component when collecting
and rebuilding a byte-sum tree so unrelated vector lanes never enter
the scalar result.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Author

Thanks, Dj. Fixed in f723a281a5941. The fold now carries a NIR scalar, including its component, through the addition tree and reconstructs each extra addend with that component. I also moved the unpack comment back to its function. The new vector-addend case fails on the old compiler and passes here. Exact host results were 1,961 compiler passes with one skip and 146 focused passes. The AArch64 Vulkan ICD built and the change applies cleanly to the current target.

The exact J713 and J615 drivers verified 524,288 outputs and as many padding words per process. J713 improved the original two-vector case by 2.45% paired. The new vector-addend case was −0.13% paired on J713. The first J615 vector-addend pass was noisy (+4.55% paired, +0.20% pooled). In a 12-block interleaved repeat with two identical baseline copies, J615 was +0.16% paired versus baseline and −0.21% versus its identical copy. Both saved boots were unchanged and the kernel journals were empty.

I’ve requested re-review on the exact head.

@RyanTheTide
RyanTheTide dismissed DjDeveloperr’s stale review December 2, 2026 18:35

Fixed the vector-addend compiler crash in f723a28. The regression test and J615/J713 checks pass on the new head. Re-review requested.

@satchlj

satchlj commented Dec 2, 2026

Copy link
Copy Markdown
Member

Exact-head M5 Max (J775c, G17C B1, Borealis Vulkan) re-verification at updated head f723a281a594 on aurora-silicon/linux@main ef557c14eb37 (7.3.0-1-57.20261202-ARCH, default command line):

  • Assert-enabled build & host tests (-Dbuildtype=debugoptimized -Db_ndebug=false): 330/330 Meson tests OK; targeted agx_tests (*Swar*:*W8*:*Byte*:*Vision*:*Wave8*) 185/185 PASS.
  • Vulkan CTS (exact-head ICD, MESA_SHADER_CACHE_DISABLE=1): dEQP-VK.api.smoke.* 8/8, dEQP-VK.subgroups.basic.compute.* 12/12, dEQP-VK.subgroups.ballot.compute.* 2/2 PASS.
  • gpubench-rt-vk (release exact-head ICD, MESA_SHADER_CACHE_DISABLE=1): raster 2,280.71 fps (crc32=cca69c73), medium 137.3 fps / 336.9 Mray/s (crc32=e91ea686).
  • ABBA llama-bench (Llama-2-7B Q4_0, -fa 1 -p 128,512 -n 32 -r 3, release builds of exact base c94b25ce4e2f vs exact head f723a281a594, MESA_SHADER_CACHE_DISABLE=1):
    • pp128: 3,026.52 vs 3,029.94 t/s (+0.11%)
    • pp512: 3,529.33 vs 3,528.23 t/s (-0.03%)
    • tg32: 122.49 vs 122.30 t/s (-0.15%)
  • Kernel health: 0 GPU faults, 0 kernel oops/warnings in dmesg.

@RyanTheTide

Copy link
Copy Markdown
Author

The assert-enabled host Asahi, Poly and Vulkan Meson suites at exact head f723a281a5941 finished with 451 passes, one skip and zero failures. The new scalar-component regression also passed in the full compiler test.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is right at f723a281. The vector-addend crash is gone, and I found no other addend shape that breaks the fold. This is a comment, not an approval: the first commit here is under my account, so a reviewer with no commits in this PR still needs to approve.

I checked the merge of this head into aurora-wip c3adfe79 (tree 711b8afc) on pc, using an x86-64 assert-enabled build with drm-shim:

  • Earlier failures: the three failing shaders from my earlier review and the PR's own shader now compile and pass NIR validation on G13X, G14G, G15G, G16G, G17P, G17S and G18G.
  • Other addend shapes: these also compile cleanly on every chip:
    • built-in vectors and push-constant uvec4 lanes as addends
    • an inner sum that has a second use
    • the same vector lane added twice
    • two sums in one block, one with a u8vec4 load and one with two u8vec3 loads
    • 32 strided u8vec4 loads, the per-lane limit: all 32 pack, and G16G goes from 389 to 232 instructions
    • 33 loads, which bail out as intended
  • Bit-exact results: I evaluated the final NIR of every shape on base and on the merge, with 1,000 random and edge inputs per chip, including all bytes 0xFF and all zero. The stored values were identical in all 72 shape and chip pairs. A deliberately broken mask does get caught.
  • Local CI on the merge:
    • Meson asahi, poly and vulkan suites: 454 pass, 0 fail, 1 skip (hk-g17p-cross-queue, exit 77). Base gives the same result.
    • agx_tests: 1,962 pass and 1 skip, against 1,960 on base. The new Wave8SwarW8ByteSumWithVectorAddends test passes.
  • GTA V shader-db, base against merge: 0 changed executables on G14G, G15G, G16G, G17P, G17S and G18G. I ran both the combined GTA V Fossilize DB and the Steam DB, up to 26,437 executables per chip.
  • Hardware at this head: the J775c (G17C) row above, plus the J713 (G16G) and J615 (G15G) results in your comment.

Not blocking: on G17S, u8vec3 sums come out a few instructions longer than on base, because AGX3C's own W8 load already widens each byte to a word.

  • vec3leaf goes from 21 to 24 instructions, and the two-sum shape from 31 to 33.
  • u8vec4 sums are unchanged there, because agx_nir_opt_u8x4_hsum() takes them first.
  • Nothing in GTA V hits this. If a real M5 shader ever does, skipping 3-byte loads on AGX3C would avoid it.

Still needed before merge: an approval from a reviewer with no commits in this PR.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at f723a281, following our review in #1548 (review): the fix is correct on G13X through G18G, the final NIR matches base, local CI on the merge with aurora-wip is clean, and there is no shader-db change on G14G to G18G. We are running one J714s row at this exact head before merge.

@DjDeveloperr

Copy link
Copy Markdown

PASS J714s (M5 Pro, T6050/G17S B1, stock 7.3.0-m5-pr67) mesa#1548 head f723a28 merged onto aurora-wip 725f2ab (merge 03f6d18630c7, tree c611688f9e4c): store-aarch64 byte-sum 4x ABBA/BAAB (64/64 procs verified 524288 outputs + 524288 sentinels, MESA_SHADER_CACHE_DISABLE=1) mode=2 10708->10729.5ns (+0.48%), mode=3 1x 11792->11792ns (-0.26%), mode=4 10834->10792ns (-0.57%), mode=3 256-batch 1545187.5->1545125ns (-0.00%); G17S AGX3C main shader size 416->416B (agx_nir_opt_u8x4_hsum already handles M5 AGX3C with 0 regression, 46 instrs/13 GPRs/0 spills); 0 GPU faults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants