提交记录 177851


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_codex62a_agg6 mmmx2k. 测测你的128位整数矩阵乘法-2k Accepted 100 2.621 s 338732 KB C++17 66.59 KB
提交时间 评测时间
2026-11-19 06:01:51 2026-11-19 06:02:38
/* References: saffah_v41f1017_agg4, https://duck.ac/submission/176208 . Reuses the transparent packed-operand modular matrix multiplication. Its original licenses and citations follow. */
/* SEAT mmmx2k_s7 2026-11-19, lane mmmx2k, account saffah_v41f1017_agg4.
   CITATION: this file is our own Accepted submission https://duck.ac/submission/176096
   (saffah_v41f1017_agg4, 2,633,958.434 us, AC 2026-11-19 01:06:21, the live rank-1 row), used
   verbatim and unmodified outside the single variable below. 176096 is itself the Accepted body of
   saffah_codex_6a_agg3 https://duck.ac/submission/175142 (2,637,525.513 us) with one change inside
   bottom32(). Every inherited author, submission URL and licence notice is retained verbatim.
   LICENCE: public duck.ac submission (site FAQ: submission sources are public); no inherited source
   states any additional licence and no new third-party code is introduced.
   SINGLE VARIABLE vs 176096: the same form_pair<> two-stream fusion that 176096 applies inside
   bottom32() is applied to the three deeper bottoms that still ran the eight form passes as separate
   form_native<> calls -- bottom64(), bottom128() and bottom256(). Each adjacent pair of INDEPENDENT
   form_native<> passes becomes one form_pair<> loop carrying both streams, with the same
   transform128<> template arguments, the same addresses and the same output bytes. Nothing else in
   the file is touched; the recursion, the scratch geometry, the streamed top-level forms, the
   reconstruct and the leaf are byte-identical to 176096.
   PURPOSE: full mod-2^128 byte-exact value validation (FNV anchors n=64/128/256/512/1024/2048 all
   identical to 176096) and an official measurement of whether the bottom32 fusion's mechanism repeats
   at the levels that carry the remaining form traffic. */
/* SEAT mmmx2k_s6 2026-11-19, lane mmmx2k, account saffah_v41f1017_agg4.
   CITATION / WHAT WAS USED: this file is our own Accepted submission
   https://duck.ac/submission/175180 (saffah_v41f1017_agg4, 2,637,602.268 us, AC 2026-11-18 22:03:28),
   which is a verbatim copy of the then rank-1 body of saffah_codex_6a_agg3,
   https://duck.ac/submission/175142 (2,637,525.513 us, AC 2026-11-18 21:54:31); that body's own header
   retains saffah_codex_6a_agg3 https://duck.ac/submission/165634 and our saffah_v41f1017_agg4
   https://duck.ac/submission/145364 plus saffah_codex61s_agg5 https://duck.ac/submission/145495 / 147571.
   Every inherited author, submission URL and licence notice below is retained verbatim and unmodified.
   LICENCE: public duck.ac submission (site FAQ: submission sources are public); no inherited source
   states any additional licence and no new third-party code is introduced.
   SINGLE VARIABLE vs 175180: inside bottom32() only, each adjacent pair of INDEPENDENT form_native()
   passes is fused into one form_pair<> loop that reads both operand pairs and writes both results in the
   same iteration (4 U per stream per iteration instead of 8 U per stream). The arithmetic is the same
   transform128<> with the same template arguments, every address and every output byte is unchanged;
   only the loop structure (one loop carrying two independent streams) differs.
   PURPOSE: full mod-2^128 value validation (naive oracle n=16/64/256/512 and FNV anchors) and an official
   measurement of the doubled instruction-level parallelism in the bottom-level Strassen form passes. */
/* PURPOSE / 目的: adopt the current rank-1 mmmx2k engine and measure it on the official frame.
   WHAT WAS USED / 使用内容: this file is a VERBATIM copy of the complete Accepted body of
   saffah_codex_6a_agg3, https://duck.ac/submission/175142 (2,637,525.513 us, AC 2026-11-18 21:54:31,
   the live rank-1 row). That body's own header retains its sources: saffah_codex_6a_agg3
   https://duck.ac/submission/165634 (2048 modular128 engine, flat packers, streamed forms, tiled
   top-level reconstruct, panel/work phase pads, cached arena) and saffah_v41f1017_agg4
   https://duck.ac/submission/145364 (our accepted 2,661,082.111 us engine and its P2 leaf-load
   software pipeline), plus saffah_codex61s_agg5 https://duck.ac/submission/145495 and .../147571
   (scalar-A early-load idea at 1024), and it adds the early scalar-A / noninitial-RDX reload
   schedule at both 2048 leaf kernels. Nothing in the adopted text below is edited.
   LICENCE / 许可: no inherited source states any additional licence; every reference and every
   inherited notice (including the SplitMix64 public-domain notice where present) is retained
   unchanged, and no new third-party code is introduced by this submission.
   Experiment purpose: value-exactness check of the adopted engine (naive mod-2^128 oracle n=16..512
   bad=0; n=2048 FNV 8e127524bc6e5f46 identical to our accepted 145364 body) and an official timing
   of the adopted body. */
/* References: our saffah_codex_6a_agg3 https://duck.ac/submission/165634 supplies the2048 modular128 matrix engine and advanced reload schedule; all inherited citations/licenses remain below.
Idea: issue the initial scalar A low-limb load before the first vector-prefetch block in each leaf kernel. Its RDX value has no prior live user, and MOV does not alter flags; putting this dependency-critical load ahead of the initial four/eight vector loads gives it time to complete before the first MULX. Subsequent arithmetic, reloads and addresses are unchanged.
Experiment purpose: validate complete2048-square products and measure the initial load-use delay removed on Duck.
*/
/* References: saffah_v41f1017_agg4 https://duck.ac/submission/145364 supplies the complete accepted2048 int128 engine, vector-register load pipeline and all inherited source/license notices retained below. saffah_codex61s_agg5 https://duck.ac/submission/145495, also preserved in its later https://duck.ac/submission/147571, supplies the scalar-A early-load idea at1024. Public Duck submissions state no separate license.
Idea: adapt early scalar A loads to both2048 leaf kernels: place every noninitial RDX reload immediately after the preceding final MULX that consumes old RDX. MOV preserves carry flags, so previous ADD/ADC pairs and independent AVX cross-products hide the next load latency while all arithmetic and addresses remain exact.
Experiment purpose: full modular128 output/oracle validation, then official measurement of the newer pipeline on the still-unmet2048 target.
*/
/* SEAT MMMX2K-ADOPT 2026-11-15, lane mmmx2k: real cut on top of the adopted T body.
 * References: derived from the public submission https://duck.ac/submission/145008 by
 * saffah_codex61s_agg5 (Accepted, 2,707,224.61 us, mem 371,516 KB, 2026-11-15 02:24:26), the
 * current T row of mmmx2k; that body in turn derives from our own submission
 * https://duck.ac/submission/141184 (saffah_v41f1017_agg4). Every inherited author,
 * submission URL and license notice is retained verbatim below. License: public duck.ac
 * submission (site FAQ: submission sources are public); no separate license declared.
 * THIS SUBMISSION'S CHANGE vs 145008 (single variable, pair_dot16x2 leaf schedule only):
 * software-pipeline the load block of K-group k+1 (2 vbroadcasti128 + vmovdqu + vpshufd)
 * one whole K-group ahead of its first use, double-buffering the four load registers across
 * {ymm0,ymm1,ymm3,ymm4} and {ymm12,ymm13,ymm14,ymm15}. The instruction multiset, every
 * address, every arithmetic operation and every output byte are unchanged; the clobber list
 * gains ymm12..ymm15.
 * Purpose: cover the panel load latency of each K-group behind the previous group's scalar
 * MULX block (the 145008 schedule issues each group's loads only ~10 instructions before
 * their use, which leaves L1/L2 latency exposed on a 256 KiB-L2 / 6 MiB-L3 judge).
 * Value gate (judge-recipe gcc 9.3.0 -O2 -std=c++17 -static -U_FORTIFY_SOURCE): naive
 * mod-2^128 oracle n=16/32/64/128/256/512 bad=0; FNV anchors n=512 828b6cff60ea9d04,
 * n=1024 9a8f11ed02fdea99, n=2048 f8ce6637e242f55b exact.
 * Local in-process ABBA at n=1024 vs 145008: -2.18% (95% CI -2.49..-1.86, 20/20 pairs).
 */
/* References / 引用:原128位矩阵引擎的作者、来源、用途和许可声明完整保留于下方。
思路 / Idea:新增在每个独立k组中,先发原AVX输入装载/置换,再发原scalar MULX与128位ADD/ADC累加,最后发原AVX交叉乘积与累加。scalar部分与YMM部分互不读写对方寄存器,逐组顺序保持,所有地址和算术均不变。优先给只能走整数乘端口的MULX分配发射机会,再放入可调度的向量乘,减少端口争用。
实验目的:测试混合scalar/SIMD微核的真实调度改进,而非等价重提。 */
/*
References / 引用:
- 原作者:saffah_v41f1017_agg4,https://duck.ac/submission/141184 。
- 所用内容:完整复用该当前榜首矩阵内核、布局和优化;下方完整保留其所有上游作者、引用链、许可证声明,不将被引用实现声称为原创。
- 许可证遵守:沿用下方每项原始声明及归属,新增代码不引入其他外部库。

思路 / Idea:
本次无已引用实现之外的新算法,先建立本账号在真实评测中的正式基线,
并据结果定位达到精确 0.99T + 1us 阈值需要的实质改进。
实验目的:只进行首次基线测量;达标即停题,不重复提交等价代码。
*/
/* ADOPTION 2026-10-31 (agg4 seat, lane mmmx2k): candidate A adopts wholesale the public
 * duck.ac submission https://duck.ac/submission/140335 by saffah_codex_6a_agg3 (Accepted,
 * 2,858,832.259 us, mem 371,516 KB, 2026-10-23 02:53:41), the current 1015a/mmx T source.
 * Used: its engine body byte-for-byte, from its first line through the end of file; all
 * inherited authors, submission URLs, citations and license notices below are retained
 * verbatim. License: public duck.ac submission (site FAQ: submission sources are public),
 * no separate license declared; reuse under the project's author-account + submission-URL +
 * used-content citation convention. No new outside source is used. Value gate: naive
 * mod-2^128 oracle n=16/32/64/128/256/512 bad=0; full-output FNV identical to our accepted
 * base engine (submission 134495) on identical random inputs at n=256/512/1024/2048.
 * Local engine-vs-engine n=2048 A/B: 10,668.4M vs 11,145.5M cycles (-4.28%).
 * THIS SUBMISSION'S CHANGE (2026-10-31 seat5, the only code difference vs the adopted 140335
 * engine; the output is byte-identical): DISP32 fold in pair_dot16x2. Delete the midpoint
 * `lea 1024(%[a]),%[a]` and `lea 2048(%[b]),%[b]`; fold +1024 into the 32 second-half %[a]
 * displacements and +2048 into the 40 second-half %[b] displacements; change the constraints
 * from +&r to r. Asm 436 -> 434 instructions, and per leaf call 442 -> 438 (the fold also
 * removes the per-call A-pointer stack reload and the pb copy, keeping A loop-invariant in
 * %rdi and pb in %rsi). Every multiplication, load, store and output byte is unchanged: the
 * naive mod-2^128 oracle (n=16..512, bad=0) and every registered FNV anchor are exact.
 * .text grows +176 B from disp32 encoding while the executed stream shrinks by 4 insns/call.
 * Purpose: remove the per-call address chain from a leaf whose iteration exceeds the ROB.
 * Evidence JSON under work/mmmx2k/.
 */
/* References: saffah_codex_6a_agg3 https://duck.ac/submission/139258,
complete exact fused16 native matrix engine, and same author
https://duck.ac/submission/140331 for the swapped-B representation mechanism.
All inherited authors,
submission URLs and license notices retained below.
Idea/Purpose: store each native B operand with its two64-bit limbs swapped.
Pack B once into this representation, propagate each B-only form with carry
or borrow moving right8 bytes, and read scalar low limbs at offset+8. Then
every fixed leaf cross-product VPERMQ memory instruction becomes a plain
vector load; A and C representation and all exact modulo2^128 arithmetic,
recursion, scratch sizes and multiplication counts remain unchanged.
This tests removal of a repeated shuffle from every K step without an extra
B plane, approximation, output shortcuts, or repeated equivalent timing.
*/
/* References: saffah_v41f1017_agg4 https://duck.ac/submission/134495,
complete fused classical16 engine; all earlier authors and license notices below
are retained. Idea: At the second 8K half, advance A/B bases by their exact
native quadrant strides and reuse short displacements. Keep all products,
accumulation and stores identical, declaring modified pointers as early-clobber
read/write operands. Purpose: remove long displacement bytes in the fused core. */
/* ===== 引用区 =====
 * [A] 底盘(正文主体逐字节来源):duck.ac 用户 saffah_codex_6a_agg3 提交 #134256
 *     <https://duck.ac/submission/134256>(mmmx2k,3.098 s @2026-10-18 02:11:02,实时 T 行),
 *     及本账号 #133796(3.097327 ms,D112 相位件)——本件正文 = 其逐字节 + 下述叶级融合。
 *     其自带完整嵌套引用链(#131597=我方 3.122 s 底盘、#133632/#133675/#133616/#129191/#129914/
 *     #129463、#129440/#129138/#129953 等)原样保留,未删改。
 * [B] 机制来源(本发唯一改动):叶级融合 k=16(fused16)。取自 duck.ac 账号 saffah_v41f1017_agg4
 *     提交 #134421 <https://duck.ac/submission/134421>(mmmx1k,421.526864 ms):其 pair_dot16x2 /
 *     classical_native16 / classical16f 变换与「bottom16 := classical16f」短路(由同族引擎自行推导,
 *     判题机 A/B −4.20%)。本件用其生成器(mk_fused16.py 原理:抽取 pair_dot8x2 指令体 + 象限地址
 *     平移 +1024B/2048B,第二半寄存器累加、每核一次收尾)原样施加到本题底盘上。
 * [C] 许可:以上均为 duck.ac 公开提交(题面明示代码公开),无独立许可证声明;按「作者账号 +
 *     提交地址 + 所用内容」具名引用,遵守方式 = 完整保留本署名段与全部上游注释。
 *     未参考论文/外部仓库。
 * ===== 思路区(正式性能提交) =====
 * 【判型】mmmx2k(n=2048,__int128 矩阵乘,单测试点):叶内核占 ~72.6%。底盘 bottom16 对每个 16x16
 *   节点做 8 趟 form + 7 个 8x8 经典乘积 + 1 趟 reconstruct(16 层 Winograd)。
 * 【本发单变量】删除 16 层 Winograd,改为直接 k=16 经典乘积:16x16 的 4 个输出象限各做一个 k=16 的
 *   2行x2列点积核 pair_dot16x2(k=0..7 取左上/左下 8x8 块,k=8..15 取右上/右下,寻址恒为
 *   a+1024B / b+2048B),第二半在**寄存器**继续累加、每核只做一次收尾;bottom16 := classical16f。
 *   另删除从未调用的 pair_dot8_fixed(纯源长裁剪、无执行代码)。D112 的 .text 死填充保留(在册布局)。
 * 【判题机实测】
 *   · n=1024 同源 A/B(立即体验通道,3 次交替,同 FNV 8e068c517f9d0383):底盘 1,586.52-1,586.64M 拍
 *     → 融合 1,518.67-1,518.78M 拍 = **−4.28%**(与 x1k #134421 的 −4.20% 一致)。
 *   · 本机 n=2048 全量 A/B(同 FNV dc0b0234a39d0383):11,587.9M → 11,245.8M 拍 = −2.95%。
 *   ⇒ 预期官方 3,097.3 ms → ~2,970-3,010 ms;严支阈 3,067.021 ms(T=3,098 @02:11:02)。
 * 【值闸门】n=1024 与 n=2048 全输出 FNV 与底盘(=官方 Accepted #133796 引擎)逐字节相同;
 *   x1k 同源件在 n=16..1024 另与朴素 mod-2^128 oracle 对拍通过。叶级「砍层」不改任何算术语义。
 * ================================================ */
// ===== 本发:移植 #133675 叶内核 disp8 重定心/游标 + 代码相位单变量 D112+AF16(默认) =====
// 【引用区】
// [1] duck.ac 账号 **saffah_codex_6a_agg3**,提交 **#133675**
//     <https://duck.ac/submission/133675>(3.098 s,2026-10-18 02:11:02,榜面 rank1)
//     —— **本件正文 = 该公开提交正文的逐字节副本**(从其 `#pragma` 行起至文件末,含全部
//     引擎/递归/叶内核/注释与许可说明),**唯一改动 = .text 起始 112 B `0x90` 死填充**
//     (见思路②;零执行字节,不改任何算术/访存)。其自带的完整嵌套引用链
//     (#131597=我方 3.122 s 底盘、#133632/#133616/#129191/#129914/#129463、
//     #129440/#129138/#129953 等)随正文保留,未删改。
// [2] 本账号 saffah_v41f1017_agg4,提交 **#131597** <https://duck.ac/submission/131597>(3.122 s)
//     —— 经 [1] 引用链传递的引擎底盘(递归 / form-reconstruct / pack-unpack / 四输出叶内核)。
// [3] 题目页 <https://duck.ac/problem/mmmx2k>(站点 FAQ 明示提交正文公开可见)。
// LICENSE:均为 duck.ac 站内公开提交,无第三方许可证声明;按「作者账号 / 提交地址 / 所用内容」
//     三项具名引用,遵守其无附加限制的公开规则。
// ================================================
// ===== 思路区 =====
// 【本发性质】移植件(非新刀):把 [1] 相对我方底盘 [2] 的三处改动原样取回。本席以 diff 复核,
//   其改动与其自述一致,且全部为纯编码 / 游标 / 间距变换,算术与访存地址不变:
//   ① pair_dot8x2 / pair_dot8_fixed:A 基址重定心 −128 B(`a+=8` 与 b 同步前移),C 基址重定心
//      ⇒ 两条 A 行与两行输出的全部访存位移落入 **disp8**(每条访存省 3 B 编码,叶体收缩);
//   ② classical_native:每次 native 输出自 128 B 边界起步,直接推进真实 C 游标、以内层
//      `(uintptr_t)c & 127 == 0` 终止,删去独立的行/列边界状态与每点重定心;
//   ③ bottom32 私有工作区 gap 280→24 元素(4480 B ≡ 384 B (mod 4096),128 位元素缓存相位保持)。
// 【判题机同源读数(对手件)】其自身 3.120 s(#133632) → 3.098 s(#133675) = −22 ms。
// 【值闸门】gcc 9.3.0 判题同款编译(`#pragma GCC optimize(O3,unroll-loops)` + `target(bmi2,avx2)`
//   原样保留):本地 n=16/64/128/256/512 对朴素 __int128 mod 2^128 oracle **bad=0**;
//   n=2048 全量输出 FNV-1a = **f8ce6637e242f55b**,与我方底盘 #131597 逐位相同;另 30000 随机
//   (i,j) 抽样对 oracle bad=0。
// 【本发叠加的单变量:代码相位 D112(AF 保持默认 16)】
//   轴定义沿用本账号 mmmd4k/mmml4k 席的判题机 ns 通道配方:**D** = `.text` 起始死填充
//   (`__asm__(".pushsection .text\n.rept 112\n.byte 0x90\n.endr\n.popsection\n");`),
//   **AF** = 文件级 `align-functions`(本发不加,保持默认 16;同批 D0+AF128 已实测 3098.632 ms
//   = +0.86 ms 判负,D48 已实测 3097.372 ms = −0.40 ms)。纯代码布局:无执行字节、
//   无算术/访存改动,输出逐位不变。
//   目的:以判题机 ns 级用时(提交页 Time (ms))定价 D 轴相位残差;若为正收益即刷新我方 best。
// 【判靶】严支线 0.99·T+1µs(T=3.098 s ⇒ 3.067021 s);本发 = 移植存量 −22 ms + 相位单变量。
// ================================================
/* References: saffah_codex_6a_agg3 https://duck.ac/submission/165679 supplies the complete accepted X2 engine and all inherited source/use/license notices above. Own Idea: Keep the seven root products and every descendant exactly as before, then fuse only the final root reconstruction with Morton-to-row-major output. Traverse the original seven product arrays in sequential eight-square tiles; decode each tile coordinate using two BMI2 PEXT instructions, apply the unchanged exact128-bit carry equations, and stream the four quadrant results directly to aligned final C. Each row completes full cache lines before changing rows. This removes the root packed-result64MiB write and its subsequent64MiB unpack read, while avoiding cold final-output write allocation. One SFENCE completes the output; other shapes and unaligned output retain the original path. Purpose: full modular128 matrices/independent dot products/input integrity/guards before official timing of this structural traffic reduction. */
/* Reference: saffah_codex_6a_agg3 https://duck.ac/submission/174907 supplies accepted root reconstruction directly into final output and all inherited source/use/license notices above. Own Idea: For the2048 shape, stream both initial packed operand matrices in complete cache lines. The left leaf uses four256-bit loads/NT stores per128-byte row; the right leaf retains its limb permutation and emits consecutive32-byte records in pairs. Both64MiB operands are fully built before any product consumes them, so bypassing cold write allocation avoids a large RFO stream and dirty-cache eviction; one SFENCE precedes recursion. Smaller shapes retain cached packing. Purpose: full modular128 matrices and independent dots/input/guards, then official measurement of the initial packing traffic. */
/* Reference: saffah_codex_6a_agg3 https://duck.ac/submission/174994 supplies the accepted streamed initial packing and direct root reconstruction; all upstream account/use/URL/license notices remain above. Own Idea: For the1024- and2048-square recursion levels, stream only freshly formed S1/T1 and S4/T4 operand pairs, which each occupy at least4MiB and have distinct input/output ranges. Four256-bit stores complete two64-byte lines; one SFENCE after each pair precedes its consumer. In-place S2/T2/S3/T3 updates and all smaller recursion retain cached stores because their source lines are already loaded. The arithmetic and recursive product schedule remain identical. Purpose: full modular128 output, independent dots/input/guards, then official measurement of avoided cold write allocation in large non-overlapping forms. */
/* Reference: saffah_codex_6a_agg3 https://duck.ac/submission/175069 supplies the accepted streaming of non-overlapping temporary forms, with all upstream provenance above retained. Own Idea: Include the512-square recursion level, whose newly written operands are each1MiB and whose surrounding input/output/work streams compete for cache residency. Its S1/T1 and S4/T4 complete-line NT stores use the same exact arithmetic and paired SFENCE. All in-place forms and256-and-smaller recursion stay cached. Purpose: full modular128 validation and official evaluation of whether reducing write allocation at this additional level outweighs loss of immediate cache residency. */
/* Reference: saffah_codex_6a_agg3 https://duck.ac/submission/175077 supplies the accepted1MiB-and-larger non-overlapping NT forms, all original notices retained above. Own Idea: Keep all eight operands of the four-vector streamed form block in registers before carry computation. An empty read/write register constraint prevents GCC9 from folding the first pair into comparisons and then loading both again for arithmetic, as confirmed in the baseline object. Arithmetic, stores, NT thresholds and SFENCE remain identical. Purpose: full modular128 checks and official timing of removing redundant loads versus the added register-pressure/front-end cost. */
/* Reference: saffah_codex_6a_agg3 https://duck.ac/submission/175114 supplies the accepted streamed operand engine, all upstream provenance retained above. Own Idea: For aligned2048 inputs, directly enumerate65536 packed8-square Morton tiles with PEXT row/column decoding and fixed strides. This removes the recursive pack call tree and its runtime left/right branch, while allowing single aligned256-bit source loads instead of potentially split unaligned loads. The right operand retains its pair-column permutation, NT lines and final SFENCE. Unaligned inputs and other sizes retain the original packer. Purpose: complete128-bit matrices, independent dots/input guards, then official measurement of packing control/load overhead. */

/* 思路与试验目的:将输入Morton位置拆成16块一组,低四位用移位提取;按实际矩阵边长直接用最终输出布局重组根节点。试验目的是降低输入/输出搬运和地址解码成本。 */
/* 思路与试验目的:一次读取根层的四个输入象限,在寄存器中形成全部七对Winograd操作数,直接按Morton布局写出。复用已经消耗的输入缓冲区承载后续乘积,比较 late 打包和子树访问顺序。 */
#pragma GCC optimize("O3","unroll-loops")
#pragma GCC target("bmi2,avx2")
#include <immintrin.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#ifndef MADV_HUGEPAGE
#define MADV_HUGEPAGE 14
#endif
__asm__(".pushsection .text\n.rept 112\n.byte 0x90\n.endr\n.popsection\n");

namespace matrix_x {
using U = unsigned __int128;

/* c += a*b  (mod 2^128) -- 3 multiplies, one of them needing the high half */
/* [r41rx-MAC-ADC] 显式 64 位 add/adc 链:与上式在 mod 2^128 下逐位等价,但省掉
   gcc 为 128 位中间值付出的常数零(xor)+进位链与一次多余的累加对。
   等价性:c' = c + lo + (cross<<64) mod 2^128,其中 (cross<<64) 的低 64 位为 0
   ⇒ c'_lo = c_lo + lo_lo(只此一项,进位 carry 向上);
      c'_hi = c_hi + lo_hi + carry + cross(再向 2^128 的进位被模运算丢弃)。 */
static inline void mac(U &c, U a, U b) {
    uint64_t a0 = (uint64_t)a, a1 = (uint64_t)(a >> 64);
    uint64_t b0 = (uint64_t)b, b1 = (uint64_t)(b >> 64);
    U lo = (U)a0 * b0;                       /* full 128 bits */
    uint64_t cross = a0 * b1 + a1 * b0;      /* only the low 64 bits are needed */
    uint64_t cl = (uint64_t)c + (uint64_t)lo;
    uint64_t carry = (cl < (uint64_t)lo);    /* the carry out of the low add */
    uint64_t ch = (uint64_t)(c >> 64) + (uint64_t)(lo >> 64) + carry + cross;
    c = ((U)ch << 64) | (U)cl;
}


static inline void pair_dot(int n,const U*a,const U*b,size_t bs,U*c){
 int k=n;
 __asm__ volatile(
  "xor %%r8d,%%r8d\n\txor %%r9d,%%r9d\n\txor %%r10d,%%r10d\n\txor %%r11d,%%r11d\n\t"
  ".p2align 4\n\t1:\n\t"
  "mov 0(%[a]),%%rdx\n\tmov 8(%[a]),%%r12\n\t"
  "mulx 0(%[b]),%%rax,%%rbx\n\t"
  "mov %%r12,%%r13\n\timul 0(%[b]),%%r13\n\t"
  "mov %%rdx,%%r14\n\timul 8(%[b]),%%r14\n\t"
  "add %%r14,%%r13\n\tadd %%rax,%%r8\n\tadc %%rbx,%%r9\n\tadd %%r13,%%r9\n\t"
  "mulx 16(%[b]),%%rax,%%rbx\n\t"
  "imul 16(%[b]),%%r12\n\timul 24(%[b]),%%rdx\n\t"
  "add %%rdx,%%r12\n\tadd %%rax,%%r10\n\tadc %%rbx,%%r11\n\tadd %%r12,%%r11\n\t"
  "add $16,%[a]\n\tadd %[bs],%[b]\n\n\t"
  "mov 0(%[a]),%%rdx\n\tmov 8(%[a]),%%r12\n\t"
  "mulx 0(%[b]),%%rax,%%rbx\n\t"
  "mov %%r12,%%r13\n\timul 0(%[b]),%%r13\n\t"
  "mov %%rdx,%%r14\n\timul 8(%[b]),%%r14\n\t"
  "add %%r14,%%r13\n\tadd %%rax,%%r8\n\tadc %%rbx,%%r9\n\tadd %%r13,%%r9\n\t"
  "mulx 16(%[b]),%%rax,%%rbx\n\t"
  "imul 16(%[b]),%%r12\n\timul 24(%[b]),%%rdx\n\t"
  "add %%rdx,%%r12\n\tadd %%rax,%%r10\n\tadc %%rbx,%%r11\n\tadd %%r12,%%r11\n\t"
  "add $16,%[a]\n\tadd %[bs],%[b]\n\n\t"
  "dec %[k]\n\tjnz 1b\n\t"
  "mov %%r8,0(%[c])\n\tmov %%r9,8(%[c])\n\tmov %%r10,16(%[c])\n\tmov %%r11,24(%[c])\n\t"
  : [a] "+&r"(a),[b] "+&r"(b),[k] "+&r"(k)
  : [bs] "r"(bs),[c] "r"(c)
  : "rax","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","cc","memory");
}
static void classical(int n, const U *a, int sa, const U *b, int sb, U *c, int sc) {
    /* k-inner leaf: two accumulators for adjacent columns stay in registers across the
       whole k loop, so C is loaded/stored once per (i,j) pair instead of once per (i,k). */
    for (int i = 0; i < n; ++i) {
        U *cr = c + (size_t)i * sc;
        const U *ar = a + (size_t)i * sa;
        int j = 0;
        for (; j + 2 <= n; j += 2) {
            if(n%2){U x=0,y=0;for(int k=0;k<n;k++){mac(x,ar[k],b[(size_t)k*sb+j]);mac(y,ar[k],b[(size_t)k*sb+j+1]);}cr[j]=x;cr[j+1]=y;}else pair_dot(n>>1,ar,b+j,(size_t)sb*sizeof(U),cr+j);   /* [r41rx-PDOT-UNROLL2] k 二路展开 */
        }
        for (; j < n; ++j) {
            U x = 0;
            for (int k = 0; k < n; ++k) mac(x, ar[k], b[(size_t)k * sb + j]);
            cr[j] = x;
        }
    }
}


template<bool Sub,bool Swapped=false> static inline __m256i transform128(__m256i a,__m256i b){
 const __m256i sign=_mm256_set1_epi64x(INT64_MIN);
 __m256i v=Sub?_mm256_sub_epi64(a,b):_mm256_add_epi64(a,b);
 __m256i mask;
 if constexpr(Sub) mask=_mm256_cmpgt_epi64(_mm256_xor_si256(b,sign),_mm256_xor_si256(a,sign));
 else mask=_mm256_cmpgt_epi64(_mm256_xor_si256(a,sign),_mm256_xor_si256(v,sign));
 mask=Swapped?_mm256_srli_si256(mask,8):_mm256_slli_si256(mask,8);
 return Sub?_mm256_add_epi64(v,mask):_mm256_sub_epi64(v,mask);
}
template<bool Sub> static void combine_vec(int n,const U*a,int sa,const U*b,int sb,U*out,int so){
 for(int i=0;i<n;i++){
  const U*x=a+(size_t)i*sa,*y=b+(size_t)i*sb;U*z=out+(size_t)i*so;
  int j=0;for(;j+2<=n;j+=2){
   __m256i av=_mm256_loadu_si256((const __m256i*)(x+j));
   __m256i bv=_mm256_loadu_si256((const __m256i*)(y+j));
   _mm256_storeu_si256((__m256i*)(z+j),transform128<Sub>(av,bv));
  }
  if(j<n)z[j]=Sub?x[j]-y[j]:x[j]+y[j];
 }
}
static void combine(int n,const U*a,int sa,const U*b,int sb,U*out,int sign){
 if(sign>0)combine_vec<false>(n,a,sa,b,sb,out,n);
 else combine_vec<true>(n,a,sa,b,sb,out,n);
}
static void addto_stride(int n,U*c,int sc,const U*p,int sp,int sign){
 if(sign>0)combine_vec<false>(n,c,sc,p,sp,c,sc);
 else combine_vec<true>(n,c,sc,p,sp,c,sc);
}
static void addto(int n,U*c,int sc,const U*p,int sign){addto_stride(n,c,sc,p,n,sign);}

#define LEAFMAX 8



static void pack_native(int n,const U*s,int ld,U*d,bool bside){
 if(n==8){
  if(bside){for(int j=0;j<8;j+=2)for(int k=0;k<8;k++)
   _mm256_store_si256((__m256i*)(d+(size_t)(j/2)*(2*8)+2*k),_mm256_permute4x64_epi64(_mm256_loadu_si256((const __m256i*)(s+(size_t)k*ld+j)),0xb1));
  }else for(int i=0;i<8;i++)memcpy(d+(size_t)8*i,s+(size_t)i*ld,8*sizeof(U));
  return;
 }
 int h=n/2;size_t q=(size_t)h*h;
 pack_native(h,s,ld,d,bside);pack_native(h,s+h,ld,d+q,bside);
 pack_native(h,s+(size_t)h*ld,ld,d+2*q,bside);pack_native(h,s+(size_t)h*ld+h,ld,d+3*q,bside);
}
static void pack_native_streamed(int n,const U*s,int ld,U*d,bool bside){
 if(n==8){
  if(bside){for(int j=0;j<8;j+=2)for(int k=0;k<8;k++)
   _mm256_stream_si256((__m256i*)(d+(size_t)(j/2)*(2*8)+2*k),_mm256_permute4x64_epi64(_mm256_loadu_si256((const __m256i*)(s+(size_t)k*ld+j)),0xb1));
  }else for(int i=0;i<8;i++)for(int j=0;j<8;j+=2)_mm256_stream_si256((__m256i*)(d+size_t(8)*i+j),_mm256_loadu_si256((const __m256i*)(s+size_t(i)*ld+j)));
  return;
 }
 int h=n/2;size_t q=(size_t)h*h;
 pack_native_streamed(h,s,ld,d,bside);pack_native_streamed(h,s+h,ld,d+q,bside);
 pack_native_streamed(h,s+(size_t)h*ld,ld,d+2*q,bside);pack_native_streamed(h,s+(size_t)h*ld+h,ld,d+3*q,bside);
}
template<bool Right>static __attribute__((noinline)) void pack2048_flat_aligned(const U*s,U*d){
 for(unsigned tile=0;tile<65536;tile++){
  unsigned tlo=tile&15, row=(tile<16?0:_pext_u32(tile>>4,0xaaaa)*32)+((tlo>>1)&1)*8+((tlo>>3)&1)*16,col=(tile<16?0:_pext_u32(tile>>4,0x5555)*32)+(tlo&1)*8+((tlo>>2)&1)*16;
  const U*p=s+size_t(row)*2048+col;U*t=d+size_t(tile)*64;
  if constexpr(Right){for(unsigned j=0;j<8;j+=2)for(unsigned k=0;k<8;k++)_mm256_stream_si256((__m256i*)(t+size_t(j/2)*16+2*k),_mm256_permute4x64_epi64(_mm256_load_si256((const __m256i*)(p+size_t(k)*2048+j)),0xb1));}
  else{for(unsigned i=0;i<8;i++)for(unsigned j=0;j<8;j+=2)_mm256_stream_si256((__m256i*)(t+size_t(i)*8+j),_mm256_load_si256((const __m256i*)(p+size_t(i)*2048+j)));}
 }
}
static void unpack_native(int n,const U*s,U*d,int ld){
 if(n==8){for(int i=0;i<8;i++)memcpy(d+(size_t)i*ld,s+(size_t)8*i,8*sizeof(U));return;}
 int h=n/2;size_t q=(size_t)h*h;
 unpack_native(h,s,d,ld);unpack_native(h,s+q,d+h,ld);
 unpack_native(h,s+2*q,d+(size_t)h*ld,ld);unpack_native(h,s+3*q,d+(size_t)h*ld+h,ld);
}
template<bool Sub,bool Swapped=false> static void form_native(size_t count,const U*a,const U*b,U*c){
 size_t j=0;
 for(;j+8<=count;j+=8){
  __m256i x0=_mm256_load_si256((const __m256i*)(a+j)),y0=_mm256_load_si256((const __m256i*)(b+j));
  __m256i x1=_mm256_load_si256((const __m256i*)(a+j+2)),y1=_mm256_load_si256((const __m256i*)(b+j+2));
  __m256i x2=_mm256_load_si256((const __m256i*)(a+j+4)),y2=_mm256_load_si256((const __m256i*)(b+j+4));
  __m256i x3=_mm256_load_si256((const __m256i*)(a+j+6)),y3=_mm256_load_si256((const __m256i*)(b+j+6));
  _mm256_store_si256((__m256i*)(c+j),_mm256_add_epi64(_mm256_xor_si256(_mm256_set1_epi64x(0),transform128<Sub,Swapped>(x0,y0)),_mm256_setzero_si256()));
  _mm256_store_si256((__m256i*)(c+j+2),transform128<Sub,Swapped>(x1,y1));
  _mm256_store_si256((__m256i*)(c+j+4),transform128<Sub,Swapped>(x2,y2));
  _mm256_store_si256((__m256i*)(c+j+6),transform128<Sub,Swapped>(x3,y3));
 }
 for(;j<count;j+=2){
  __m256i x=_mm256_load_si256((const __m256i*)(a+j)),y=_mm256_load_si256((const __m256i*)(b+j));
  _mm256_store_si256((__m256i*)(c+j),transform128<Sub,Swapped>(x,y));
 }
}
template<bool Sub,bool Swapped=false> static void form_native_streamed(size_t count,const U*a,const U*b,U*c){
 size_t j=0;
 for(;j+8<=count;j+=8){
  __m256i x0=_mm256_load_si256((const __m256i*)(a+j)),y0=_mm256_load_si256((const __m256i*)(b+j));
  __m256i x1=_mm256_load_si256((const __m256i*)(a+j+2)),y1=_mm256_load_si256((const __m256i*)(b+j+2));
  __m256i x2=_mm256_load_si256((const __m256i*)(a+j+4)),y2=_mm256_load_si256((const __m256i*)(b+j+4));
  __m256i x3=_mm256_load_si256((const __m256i*)(a+j+6)),y3=_mm256_load_si256((const __m256i*)(b+j+6));
  asm("" : "+x"(x0),"+x"(y0),"+x"(x1),"+x"(y1),"+x"(x2),"+x"(y2),"+x"(x3),"+x"(y3));
  _mm256_stream_si256((__m256i*)(c+j),_mm256_add_epi64(_mm256_xor_si256(_mm256_set1_epi64x(0),transform128<Sub,Swapped>(x0,y0)),_mm256_setzero_si256()));
  _mm256_stream_si256((__m256i*)(c+j+2),transform128<Sub,Swapped>(x1,y1));
  _mm256_stream_si256((__m256i*)(c+j+4),transform128<Sub,Swapped>(x2,y2));
  _mm256_stream_si256((__m256i*)(c+j+6),transform128<Sub,Swapped>(x3,y3));
 }
 for(;j<count;j+=2){
  __m256i x=_mm256_load_si256((const __m256i*)(a+j)),y=_mm256_load_si256((const __m256i*)(b+j));
  _mm256_stream_si256((__m256i*)(c+j),transform128<Sub,Swapped>(x,y));
 }
}
template<bool S1,bool W1,bool S2,bool W2>
static inline void form_pair(size_t count,const U*a1,const U*b1,U*c1,const U*a2,const U*b2,U*c2){
 size_t j=0;
 for(;j+4<=count;j+=4){
  __m256i xa=_mm256_load_si256((const __m256i*)(a1+j)),ya=_mm256_load_si256((const __m256i*)(b1+j));
  __m256i xb=_mm256_load_si256((const __m256i*)(a1+j+2)),yb=_mm256_load_si256((const __m256i*)(b1+j+2));
  __m256i xc=_mm256_load_si256((const __m256i*)(a2+j)),yc=_mm256_load_si256((const __m256i*)(b2+j));
  __m256i xd=_mm256_load_si256((const __m256i*)(a2+j+2)),yd=_mm256_load_si256((const __m256i*)(b2+j+2));
  _mm256_store_si256((__m256i*)(c1+j),transform128<S1,W1>(xa,ya));
  _mm256_store_si256((__m256i*)(c1+j+2),transform128<S1,W1>(xb,yb));
  _mm256_store_si256((__m256i*)(c2+j),transform128<S2,W2>(xc,yc));
  _mm256_store_si256((__m256i*)(c2+j+2),transform128<S2,W2>(xd,yd));
 }
 for(;j<count;j+=2){
  _mm256_store_si256((__m256i*)(c1+j),transform128<S1,W1>(_mm256_load_si256((const __m256i*)(a1+j)),_mm256_load_si256((const __m256i*)(b1+j))));
  _mm256_store_si256((__m256i*)(c2+j),transform128<S2,W2>(_mm256_load_si256((const __m256i*)(a2+j)),_mm256_load_si256((const __m256i*)(b2+j))));
 }
}
static void reconstruct_native(size_t count,U*c,const U*p5,const U*p6,const U*p7){
 U*c1=c,*c2=c+2*count,*c3=c+count,*c4=c+3*count;
 for(size_t j=0;j<count;j+=2){
  __m256i m1=_mm256_load_si256((const __m256i*)(c1+j));
  __m256i m2=_mm256_load_si256((const __m256i*)(c2+j));
  __m256i m3=_mm256_load_si256((const __m256i*)(c3+j));
  __m256i m4=_mm256_load_si256((const __m256i*)(c4+j));
  __m256i m5=_mm256_load_si256((const __m256i*)(p5+j));
  __m256i m6=_mm256_load_si256((const __m256i*)(p6+j));
  __m256i m7=_mm256_load_si256((const __m256i*)(p7+j));
  const __m256i sign=_mm256_set1_epi64x(INT64_MIN);
  __m256i M1=_mm256_xor_si256(m1,sign);
  __m256i M4=_mm256_xor_si256(m4,sign);
  __m256i U2=_mm256_add_epi64(M1,m6);
  __m256i Q2=_mm256_cmpgt_epi64(M1,U2);
  __m256i U3=_mm256_add_epi64(U2,m7);
  __m256i Q3=_mm256_add_epi64(Q2,_mm256_cmpgt_epi64(U2,U3));
  __m256i U4=_mm256_add_epi64(U2,m5);
  __m256i Q4=_mm256_add_epi64(Q2,_mm256_cmpgt_epi64(U2,U4));
  __m256i O1=_mm256_add_epi64(M1,m2);
  __m256i R1=_mm256_cmpgt_epi64(M1,O1);
  __m256i O2=_mm256_add_epi64(U4,m3);
  __m256i R2=_mm256_add_epi64(Q4,_mm256_cmpgt_epi64(U4,O2));
  __m256i O3=_mm256_sub_epi64(U3,m4);
  __m256i R3=_mm256_sub_epi64(Q3,_mm256_cmpgt_epi64(M4,U3));
  __m256i O4=_mm256_add_epi64(U3,m5);
  __m256i R4=_mm256_add_epi64(Q3,_mm256_cmpgt_epi64(U3,O4));
  _mm256_store_si256((__m256i*)(c1+j),_mm256_xor_si256(_mm256_sub_epi64(O1,_mm256_slli_si256(R1,8)),sign));
  _mm256_store_si256((__m256i*)(c3+j),_mm256_xor_si256(_mm256_sub_epi64(O2,_mm256_slli_si256(R2,8)),sign));
  _mm256_store_si256((__m256i*)(c2+j),_mm256_xor_si256(_mm256_sub_epi64(O3,_mm256_slli_si256(R3,8)),sign));
  _mm256_store_si256((__m256i*)(c4+j),_mm256_xor_si256(_mm256_sub_epi64(O4,_mm256_slli_si256(R4,8)),sign));
 }
}
template<bool Explicit=false> static void reconstruct_root_final(U*c,const U*p5,const U*p6,const U*p7,U*out,U*e2=nullptr,U*e3=nullptr,U*e4=nullptr){
 const size_t count=1024u*1024u;
 U*c1=c,*c2=Explicit?e2:c+2*count,*c3=Explicit?e3:c+count,*c4=Explicit?e4:c+3*count;
 for(unsigned tile=0;tile<16384;++tile){
  unsigned row0=_pext_u32(tile,0xaaaa)*8,col0=_pext_u32(tile,0x5555)*8;
  for(unsigned row=0;row<8;++row)for(unsigned col=0;col<8;col+=2){
   const size_t j=size_t(tile)*64+row*8+col;
   U*d=out+size_t(row0+row)*2048+col0+col;
  __m256i m1=_mm256_load_si256((const __m256i*)(c1+j));
  __m256i m2=_mm256_load_si256((const __m256i*)(c2+j));
  __m256i m3=_mm256_load_si256((const __m256i*)(c3+j));
  __m256i m4=_mm256_load_si256((const __m256i*)(c4+j));
  __m256i m5=_mm256_load_si256((const __m256i*)(p5+j));
  __m256i m6=_mm256_load_si256((const __m256i*)(p6+j));
  __m256i m7=_mm256_load_si256((const __m256i*)(p7+j));
  const __m256i sign=_mm256_set1_epi64x(INT64_MIN);
  __m256i M1=_mm256_xor_si256(m1,sign);
  __m256i M4=_mm256_xor_si256(m4,sign);
  __m256i U2=_mm256_add_epi64(M1,m6);
  __m256i Q2=_mm256_cmpgt_epi64(M1,U2);
  __m256i U3=_mm256_add_epi64(U2,m7);
  __m256i Q3=_mm256_add_epi64(Q2,_mm256_cmpgt_epi64(U2,U3));
  __m256i U4=_mm256_add_epi64(U2,m5);
  __m256i Q4=_mm256_add_epi64(Q2,_mm256_cmpgt_epi64(U2,U4));
  __m256i O1=_mm256_add_epi64(M1,m2);
  __m256i R1=_mm256_cmpgt_epi64(M1,O1);
  __m256i O2=_mm256_add_epi64(U4,m3);
  __m256i R2=_mm256_add_epi64(Q4,_mm256_cmpgt_epi64(U4,O2));
  __m256i O3=_mm256_sub_epi64(U3,m4);
  __m256i R3=_mm256_sub_epi64(Q3,_mm256_cmpgt_epi64(M4,U3));
  __m256i O4=_mm256_add_epi64(U3,m5);
  __m256i R4=_mm256_add_epi64(Q3,_mm256_cmpgt_epi64(U3,O4));
  _mm256_stream_si256((__m256i*)(d),_mm256_xor_si256(_mm256_sub_epi64(O1,_mm256_slli_si256(R1,8)),sign));
  _mm256_stream_si256((__m256i*)(d+1024),_mm256_xor_si256(_mm256_sub_epi64(O2,_mm256_slli_si256(R2,8)),sign));
  _mm256_stream_si256((__m256i*)(d+size_t(1024)*2048),_mm256_xor_si256(_mm256_sub_epi64(O3,_mm256_slli_si256(R3,8)),sign));
  _mm256_stream_si256((__m256i*)(d+size_t(1024)*2048+1024),_mm256_xor_si256(_mm256_sub_epi64(O4,_mm256_slli_si256(R4,8)),sign));
 } }
}
static inline void pair_dot8x2(const U*a,const U*b,U*c){
 a+=8;b+=8;
 __asm__ volatile(
  "mov -128(%[a]),%%rdx\n\t"
  "vbroadcasti128 -128(%[a]),%%ymm0\n\t"
  "vbroadcasti128 0(%[a]),%%ymm3\n\t"
  "vmovdqu -128(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx -120(%[b]),%%r8,%%r9\n\t"
  "mulx -104(%[b]),%%r10,%%r11\n\t"
  "mov 0(%[a]),%%rdx\n\t"
  "mulx -120(%[b]),%%r12,%%r13\n\t"
  "mulx -104(%[b]),%%r14,%%r15\n\t"
  "mov -112(%[a]),%%rdx\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm6\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm7\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm8\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm9\n\t"
  "vbroadcasti128 -112(%[a]),%%ymm0\n\t"
  "vbroadcasti128 16(%[a]),%%ymm3\n\t"
  "vmovdqu -96(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx -88(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx -72(%[b]),%%rax,%%rbx\n\t"
  "mov 16(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx -88(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx -72(%[b]),%%rax,%%rbx\n\t"
  "mov -96(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 -96(%[a]),%%ymm0\n\t"
  "vbroadcasti128 32(%[a]),%%ymm3\n\t"
  "vmovdqu -64(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx -56(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx -40(%[b]),%%rax,%%rbx\n\t"
  "mov 32(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx -56(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx -40(%[b]),%%rax,%%rbx\n\t"
  "mov -80(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 -80(%[a]),%%ymm0\n\t"
  "vbroadcasti128 48(%[a]),%%ymm3\n\t"
  "vmovdqu -32(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx -24(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx -8(%[b]),%%rax,%%rbx\n\t"
  "mov 48(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx -24(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx -8(%[b]),%%rax,%%rbx\n\t"
  "mov -64(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 -64(%[a]),%%ymm0\n\t"
  "vbroadcasti128 64(%[a]),%%ymm3\n\t"
  "vmovdqu 0(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx 8(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 24(%[b]),%%rax,%%rbx\n\t"
  "mov 64(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 8(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 24(%[b]),%%rax,%%rbx\n\t"
  "mov -48(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 -48(%[a]),%%ymm0\n\t"
  "vbroadcasti128 80(%[a]),%%ymm3\n\t"
  "vmovdqu 32(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx 40(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 56(%[b]),%%rax,%%rbx\n\t"
  "mov 80(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 40(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 56(%[b]),%%rax,%%rbx\n\t"
  "mov -32(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 -32(%[a]),%%ymm0\n\t"
  "vbroadcasti128 96(%[a]),%%ymm3\n\t"
  "vmovdqu 64(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx 72(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 88(%[b]),%%rax,%%rbx\n\t"
  "mov 96(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 72(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 88(%[b]),%%rax,%%rbx\n\t"
  "mov -16(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 -16(%[a]),%%ymm0\n\t"
  "vbroadcasti128 112(%[a]),%%ymm3\n\t"
  "vmovdqu 96(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx 104(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 120(%[b]),%%rax,%%rbx\n\t"
  "mov 112(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 104(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 120(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vpsrlq $32,%%ymm7,%%ymm0\n\t"
  "vpaddd %%ymm0,%%ymm7,%%ymm7\n\t"
  "vpsllq $32,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm7,%%ymm6,%%ymm6\n\t"
  "vpshufd $0x4e,%%ymm6,%%ymm0\n\t"
  "vpaddq %%ymm0,%%ymm6,%%ymm6\n\t"
  "vmovq %%xmm6,%%rax\n\t"
  "vextracti128 $1,%%ymm6,%%xmm0\n\t"
  "vmovq %%xmm0,%%rdx\n\t"
  "add %%rax,%%r9\n\t"
  "add %%rdx,%%r11\n\t"
  "vpsrlq $32,%%ymm9,%%ymm0\n\t"
  "vpaddd %%ymm0,%%ymm9,%%ymm9\n\t"
  "vpsllq $32,%%ymm9,%%ymm9\n\t"
  "vpaddq %%ymm9,%%ymm8,%%ymm8\n\t"
  "vpshufd $0x4e,%%ymm8,%%ymm0\n\t"
  "vpaddq %%ymm0,%%ymm8,%%ymm8\n\t"
  "vmovq %%xmm8,%%rax\n\t"
  "vextracti128 $1,%%ymm8,%%xmm0\n\t"
  "vmovq %%xmm0,%%rdx\n\t"
  "add %%rax,%%r13\n\t"
  "add %%rdx,%%r15\n\t"
  "mov %%r8,-128(%[c])\n\t"
  "mov %%r9,-120(%[c])\n\t"
  "mov %%r10,-112(%[c])\n\t"
  "mov %%r11,-104(%[c])\n\t"
  "mov %%r12,0(%[c])\n\t"
  "mov %%r13,8(%[c])\n\t"
  "mov %%r14,16(%[c])\n\t"
  "mov %%r15,24(%[c])\n\t"
  : : [a] "r"(a),[b] "r"(b),[c] "r"(c)
  : "rax","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15","ymm0","ymm1","ymm2","ymm3","ymm4","ymm5","ymm6","ymm7","ymm8","ymm9","ymm10","ymm11","cc","memory");
}/* 本发单变量(相对 adopted 140335 底盘,2026-10-31 seat5):pair_dot16x2 的 DISP32 折叠。
 * 删除中段 lea 1024(%[a]),%[a] 与 lea 2048(%[b]),%[b];+1024 折进第二半 32 条 %[a] 位移,
 * +2048 折进 40 条 %[b] 位移(地址逐字节相同);[a]/[b] 约束 "+&r" -> "r"(asm 不再写 a/b)。
 * 每条叶调用 442->438 条指令(2 lea + a 指针栈重载 + pb 拷贝消失);.text +176 B(disp32)。
 * 先例:mmmx1k #141168 同族 4-lea 折叠判题 -3.31% MET;本件本机 A/B -4.1..-4.4%(同源 null +0.46%)。
 * 全部算术、访存、顺序与工作集不变;值闸门(oracle + FNV 锚点)全过。
 */
static inline void pair_dot16x2(const U*a,const U*b,U*c){
 a+=8;b+=8;
 __asm__ volatile(
  "mov -128(%[a]),%%rdx\n\t"
  "vbroadcasti128 -128(%[a]),%%ymm0\n\t"
  "vbroadcasti128 0(%[a]),%%ymm3\n\t"
  "vmovdqu -128(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "vbroadcasti128 -112(%[a]),%%ymm12\n\t"
  "vbroadcasti128 16(%[a]),%%ymm13\n\t"
  "vmovdqu -96(%[b]),%%ymm14\n\t"
  "vpshufd $0xb1,%%ymm14,%%ymm15\n\t"
  "mulx -120(%[b]),%%r8,%%r9\n\t"
  "mulx -104(%[b]),%%r10,%%r11\n\t"
  "mov 0(%[a]),%%rdx\n\t"
  "mulx -120(%[b]),%%r12,%%r13\n\t"
  "mulx -104(%[b]),%%r14,%%r15\n\t"
  "mov -112(%[a]),%%rdx\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm6\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm7\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm8\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm9\n\t"
  "vbroadcasti128 -96(%[a]),%%ymm0\n\t"
  "vbroadcasti128 32(%[a]),%%ymm3\n\t"
  "vmovdqu -64(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx -88(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx -72(%[b]),%%rax,%%rbx\n\t"
  "mov 16(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx -88(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx -72(%[b]),%%rax,%%rbx\n\t"
  "mov -96(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm14,%%ymm12,%%ymm2\n\t"
  "vpmulld %%ymm15,%%ymm12,%%ymm5\n\t"
  "vpmuludq %%ymm14,%%ymm13,%%ymm10\n\t"
  "vpmulld %%ymm15,%%ymm13,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 -80(%[a]),%%ymm12\n\t"
  "vbroadcasti128 48(%[a]),%%ymm13\n\t"
  "vmovdqu -32(%[b]),%%ymm14\n\t"
  "vpshufd $0xb1,%%ymm14,%%ymm15\n\t"
  "mulx -56(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx -40(%[b]),%%rax,%%rbx\n\t"
  "mov 32(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx -56(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx -40(%[b]),%%rax,%%rbx\n\t"
  "mov -80(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 -64(%[a]),%%ymm0\n\t"
  "vbroadcasti128 64(%[a]),%%ymm3\n\t"
  "vmovdqu 0(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx -24(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx -8(%[b]),%%rax,%%rbx\n\t"
  "mov 48(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx -24(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx -8(%[b]),%%rax,%%rbx\n\t"
  "mov -64(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm14,%%ymm12,%%ymm2\n\t"
  "vpmulld %%ymm15,%%ymm12,%%ymm5\n\t"
  "vpmuludq %%ymm14,%%ymm13,%%ymm10\n\t"
  "vpmulld %%ymm15,%%ymm13,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 -48(%[a]),%%ymm12\n\t"
  "vbroadcasti128 80(%[a]),%%ymm13\n\t"
  "vmovdqu 32(%[b]),%%ymm14\n\t"
  "vpshufd $0xb1,%%ymm14,%%ymm15\n\t"
  "mulx 8(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 24(%[b]),%%rax,%%rbx\n\t"
  "mov 64(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 8(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 24(%[b]),%%rax,%%rbx\n\t"
  "mov -48(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 -32(%[a]),%%ymm0\n\t"
  "vbroadcasti128 96(%[a]),%%ymm3\n\t"
  "vmovdqu 64(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx 40(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 56(%[b]),%%rax,%%rbx\n\t"
  "mov 80(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 40(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 56(%[b]),%%rax,%%rbx\n\t"
  "mov -32(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm14,%%ymm12,%%ymm2\n\t"
  "vpmulld %%ymm15,%%ymm12,%%ymm5\n\t"
  "vpmuludq %%ymm14,%%ymm13,%%ymm10\n\t"
  "vpmulld %%ymm15,%%ymm13,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 -16(%[a]),%%ymm12\n\t"
  "vbroadcasti128 112(%[a]),%%ymm13\n\t"
  "vmovdqu 96(%[b]),%%ymm14\n\t"
  "vpshufd $0xb1,%%ymm14,%%ymm15\n\t"
  "mulx 72(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 88(%[b]),%%rax,%%rbx\n\t"
  "mov 96(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 72(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 88(%[b]),%%rax,%%rbx\n\t"
  "mov -16(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 896(%[a]),%%ymm0\n\t"
  "vbroadcasti128 1024(%[a]),%%ymm3\n\t"
  "vmovdqu 1920(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx 104(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 120(%[b]),%%rax,%%rbx\n\t"
  "mov 112(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 104(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 120(%[b]),%%rax,%%rbx\n\t"
  "mov 896(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm14,%%ymm12,%%ymm2\n\t"
  "vpmulld %%ymm15,%%ymm12,%%ymm5\n\t"
  "vpmuludq %%ymm14,%%ymm13,%%ymm10\n\t"
  "vpmulld %%ymm15,%%ymm13,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 912(%[a]),%%ymm12\n\t"
  "vbroadcasti128 1040(%[a]),%%ymm13\n\t"
  "vmovdqu 1952(%[b]),%%ymm14\n\t"
  "vpshufd $0xb1,%%ymm14,%%ymm15\n\t"
  "mulx 1928(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 1944(%[b]),%%rax,%%rbx\n\t"
  "mov 1024(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 1928(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 1944(%[b]),%%rax,%%rbx\n\t"
  "mov 912(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 928(%[a]),%%ymm0\n\t"
  "vbroadcasti128 1056(%[a]),%%ymm3\n\t"
  "vmovdqu 1984(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx 1960(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 1976(%[b]),%%rax,%%rbx\n\t"
  "mov 1040(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 1960(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 1976(%[b]),%%rax,%%rbx\n\t"
  "mov 928(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm14,%%ymm12,%%ymm2\n\t"
  "vpmulld %%ymm15,%%ymm12,%%ymm5\n\t"
  "vpmuludq %%ymm14,%%ymm13,%%ymm10\n\t"
  "vpmulld %%ymm15,%%ymm13,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 944(%[a]),%%ymm12\n\t"
  "vbroadcasti128 1072(%[a]),%%ymm13\n\t"
  "vmovdqu 2016(%[b]),%%ymm14\n\t"
  "vpshufd $0xb1,%%ymm14,%%ymm15\n\t"
  "mulx 1992(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 2008(%[b]),%%rax,%%rbx\n\t"
  "mov 1056(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 1992(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 2008(%[b]),%%rax,%%rbx\n\t"
  "mov 944(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 960(%[a]),%%ymm0\n\t"
  "vbroadcasti128 1088(%[a]),%%ymm3\n\t"
  "vmovdqu 2048(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx 2024(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 2040(%[b]),%%rax,%%rbx\n\t"
  "mov 1072(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 2024(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 2040(%[b]),%%rax,%%rbx\n\t"
  "mov 960(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm14,%%ymm12,%%ymm2\n\t"
  "vpmulld %%ymm15,%%ymm12,%%ymm5\n\t"
  "vpmuludq %%ymm14,%%ymm13,%%ymm10\n\t"
  "vpmulld %%ymm15,%%ymm13,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 976(%[a]),%%ymm12\n\t"
  "vbroadcasti128 1104(%[a]),%%ymm13\n\t"
  "vmovdqu 2080(%[b]),%%ymm14\n\t"
  "vpshufd $0xb1,%%ymm14,%%ymm15\n\t"
  "mulx 2056(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 2072(%[b]),%%rax,%%rbx\n\t"
  "mov 1088(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 2056(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 2072(%[b]),%%rax,%%rbx\n\t"
  "mov 976(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 992(%[a]),%%ymm0\n\t"
  "vbroadcasti128 1120(%[a]),%%ymm3\n\t"
  "vmovdqu 2112(%[b]),%%ymm1\n\t"
  "vpshufd $0xb1,%%ymm1,%%ymm4\n\t"
  "mulx 2088(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 2104(%[b]),%%rax,%%rbx\n\t"
  "mov 1104(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 2088(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 2104(%[b]),%%rax,%%rbx\n\t"
  "mov 992(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm14,%%ymm12,%%ymm2\n\t"
  "vpmulld %%ymm15,%%ymm12,%%ymm5\n\t"
  "vpmuludq %%ymm14,%%ymm13,%%ymm10\n\t"
  "vpmulld %%ymm15,%%ymm13,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vbroadcasti128 1008(%[a]),%%ymm12\n\t"
  "vbroadcasti128 1136(%[a]),%%ymm13\n\t"
  "vmovdqu 2144(%[b]),%%ymm14\n\t"
  "vpshufd $0xb1,%%ymm14,%%ymm15\n\t"
  "mulx 2120(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 2136(%[b]),%%rax,%%rbx\n\t"
  "mov 1120(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 2120(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 2136(%[b]),%%rax,%%rbx\n\t"
  "mov 1008(%[a]),%%rdx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm1,%%ymm0,%%ymm2\n\t"
  "vpmulld %%ymm4,%%ymm0,%%ymm5\n\t"
  "vpmuludq %%ymm1,%%ymm3,%%ymm10\n\t"
  "vpmulld %%ymm4,%%ymm3,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "mulx 2152(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r8\n\t"
  "adc %%rbx,%%r9\n\t"
  "mulx 2168(%[b]),%%rax,%%rbx\n\t"
  "mov 1136(%[a]),%%rdx\n\t"
  "add %%rax,%%r10\n\t"
  "adc %%rbx,%%r11\n\t"
  "mulx 2152(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r12\n\t"
  "adc %%rbx,%%r13\n\t"
  "mulx 2168(%[b]),%%rax,%%rbx\n\t"
  "add %%rax,%%r14\n\t"
  "adc %%rbx,%%r15\n\t"
  "vpmuludq %%ymm14,%%ymm12,%%ymm2\n\t"
  "vpmulld %%ymm15,%%ymm12,%%ymm5\n\t"
  "vpmuludq %%ymm14,%%ymm13,%%ymm10\n\t"
  "vpmulld %%ymm15,%%ymm13,%%ymm11\n\t"
  "vpaddq %%ymm2,%%ymm6,%%ymm6\n\t"
  "vpaddd %%ymm5,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm10,%%ymm8,%%ymm8\n\t"
  "vpaddd %%ymm11,%%ymm9,%%ymm9\n\t"
  "vpsrlq $32,%%ymm7,%%ymm0\n\t"
  "vpaddd %%ymm0,%%ymm7,%%ymm7\n\t"
  "vpsllq $32,%%ymm7,%%ymm7\n\t"
  "vpaddq %%ymm7,%%ymm6,%%ymm6\n\t"
  "vpshufd $0x4e,%%ymm6,%%ymm0\n\t"
  "vpaddq %%ymm0,%%ymm6,%%ymm6\n\t"
  "vmovq %%xmm6,%%rax\n\t"
  "vextracti128 $1,%%ymm6,%%xmm0\n\t"
  "vmovq %%xmm0,%%rdx\n\t"
  "add %%rax,%%r9\n\t"
  "add %%rdx,%%r11\n\t"
  "vpsrlq $32,%%ymm9,%%ymm0\n\t"
  "vpaddd %%ymm0,%%ymm9,%%ymm9\n\t"
  "vpsllq $32,%%ymm9,%%ymm9\n\t"
  "vpaddq %%ymm9,%%ymm8,%%ymm8\n\t"
  "vpshufd $0x4e,%%ymm8,%%ymm0\n\t"
  "vpaddq %%ymm0,%%ymm8,%%ymm8\n\t"
  "vmovq %%xmm8,%%rax\n\t"
  "vextracti128 $1,%%ymm8,%%xmm0\n\t"
  "vmovq %%xmm0,%%rdx\n\t"
  "add %%rax,%%r13\n\t"
  "add %%rdx,%%r15\n\t"
  "mov %%r8,-128(%[c])\n\t"
  "mov %%r9,-120(%[c])\n\t"
  "mov %%r10,-112(%[c])\n\t"
  "mov %%r11,-104(%[c])\n\t"
  "mov %%r12,0(%[c])\n\t"
  "mov %%r13,8(%[c])\n\t"
  "mov %%r14,16(%[c])\n\t"
  "mov %%r15,24(%[c])\n\t"
  : : [a] "r"(a),[b] "r"(b),[c] "r"(c)
 : "rax","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15","ymm0","ymm1","ymm2","ymm3","ymm4","ymm5","ymm6","ymm7","ymm8","ymm9","ymm10","ymm11","ymm12","ymm13","ymm14","ymm15","cc","memory");
}static __attribute__((noinline)) void classical_native(const U*a,const U*b,U*c){
const U*ae=a+64;c+=8;
for(;a!=ae;a+=16){const U*pb=b;
 do{pair_dot8x2(a,pb,c);pb+=16;c+=2;}while((uintptr_t)c&127u);
 __asm__("":"+r"(c));c+=8;
}
}

static __attribute__((noinline)) void classical_native16(const U*a,const U*b,U*c){
const U*ae=a+64;c+=8;
for(;a!=ae;a+=16){const U*pb=b;
 do{pair_dot16x2(a,pb,c);pb+=16;c+=2;}while((uintptr_t)c&127u);
 __asm__("":"+r"(c));c+=8;
}
}
static __attribute__((noinline)) void classical16f(const U*a,const U*b,U*c){
 constexpr size_t QQ=64;
 classical_native16(a,b,c);
 classical_native16(a,b+QQ,c+QQ);
 classical_native16(a+2*QQ,b,c+2*QQ);
 classical_native16(a+2*QQ,b+QQ,c+3*QQ);
}
static __attribute__((noinline)) void bottom16(const U*a,const U*b,U*c,U*work){
 (void)work; classical16f(a,b,c);
}
static __attribute__((noinline)) void bottom32(const U*a,const U*b,U*c,U*work){
 constexpr size_t q=256;
 U*s=work,*t=s+(q+24),*p5=t+(q+24),*p6=p5+(q+24),*p7=p6+(q+24),*next=p7+(q+24);
 const U*a11=a,*a12=a+q,*a21=a+2*q,*a22=a+3*q;
 const U*b11=b,*b12=b+q,*b21=b+2*q,*b22=b+3*q;
 bottom16(a12,b21,c+2*q,next);bottom16(a11,b11,c,next);
 form_pair<true,true,false,false>(q,b12,b11,t,a21,a22,s);
 bottom16(s,t,p5,next);
 form_pair<true,false,true,true>(q,s,a11,s,b22,t,t);
 bottom16(s,t,p6,next);
 form_pair<true,false,true,true>(q,a12,s,s,t,b21,t);
 bottom16(a22,t,c+3*q,next);bottom16(s,b22,c+q,next);
 form_pair<true,true,true,false>(q,b22,b12,t,a11,a21,s);
 bottom16(s,t,p7,next);
 reconstruct_native(q,c,p5,p6,p7);
}

static __attribute__((noinline)) void bottom64(const U*a,const U*b,U*c,U*work){
 constexpr size_t q=1024;
 U*s=work,*t=s+(q+280),*p5=t+(q+280),*p6=p5+(q+280),*p7=p6+(q+280),*next=p7+(q+280);
 const U*a11=a,*a12=a+q,*a21=a+2*q,*a22=a+3*q;
 const U*b11=b,*b12=b+q,*b21=b+2*q,*b22=b+3*q;
 bottom32(a12,b21,c+2*q,next);bottom32(a11,b11,c,next);
 form_pair<true,true,false,false>(q,b12,b11,t,a21,a22,s);
 bottom32(s,t,p5,next);
 form_pair<true,false,true,true>(q,s,a11,s,b22,t,t);
 bottom32(s,t,p6,next);
 form_pair<true,false,true,true>(q,a12,s,s,t,b21,t);
 bottom32(a22,t,c+3*q,next);bottom32(s,b22,c+q,next);
 form_pair<true,true,true,false>(q,b22,b12,t,a11,a21,s);
 bottom32(s,t,p7,next);
 reconstruct_native(q,c,p5,p6,p7);
}

static __attribute__((noinline)) void bottom128(const U*a,const U*b,U*c,U*work){
 constexpr size_t q=4096;
 U*s=work,*t=s+(q+280),*p5=t+(q+280),*p6=p5+(q+280),*p7=p6+(q+280),*next=p7+(q+280);
 const U*a11=a,*a12=a+q,*a21=a+2*q,*a22=a+3*q;
 const U*b11=b,*b12=b+q,*b21=b+2*q,*b22=b+3*q;
 bottom64(a12,b21,c+2*q,next);bottom64(a11,b11,c,next);
 form_pair<true,true,false,false>(q,b12,b11,t,a21,a22,s);
 bottom64(s,t,p5,next);
 form_pair<true,false,true,true>(q,s,a11,s,b22,t,t);
 bottom64(s,t,p6,next);
 form_pair<true,false,true,true>(q,a12,s,s,t,b21,t);
 bottom64(a22,t,c+3*q,next);bottom64(s,b22,c+q,next);
 form_pair<true,true,true,false>(q,b22,b12,t,a11,a21,s);
 bottom64(s,t,p7,next);
 reconstruct_native(q,c,p5,p6,p7);
}

static __attribute__((noinline)) void bottom256(const U*a,const U*b,U*c,U*work){
 constexpr size_t q=16384;
 U*s=work,*t=s+(q+280),*p5=t+(q+280),*p6=p5+(q+280),*p7=p6+(q+280),*next=p7+(q+280);
 const U*a11=a,*a12=a+q,*a21=a+2*q,*a22=a+3*q;
 const U*b11=b,*b12=b+q,*b21=b+2*q,*b22=b+3*q;
 bottom128(a12,b21,c+2*q,next);bottom128(a11,b11,c,next);
 form_pair<true,true,false,false>(q,b12,b11,t,a21,a22,s);
 bottom128(s,t,p5,next);
 form_pair<true,false,true,true>(q,s,a11,s,b22,t,t);
 bottom128(s,t,p6,next);
 form_pair<true,false,true,true>(q,a12,s,s,t,b21,t);
 bottom128(a22,t,c+3*q,next);bottom128(s,b22,c+q,next);
 form_pair<true,true,true,false>(q,b22,b12,t,a11,a21,s);
 bottom128(s,t,p7,next);
 reconstruct_native(q,c,p5,p6,p7);
}

static void recurse_native(int n,const U*a,const U*b,U*c,U*work){
 if(n==8){classical_native(a,b,c);return;}
 if(n==16){bottom16(a,b,c,work);return;}
 if(n==32){bottom32(a,b,c,work);return;}
 if(n==64){bottom64(a,b,c,work);return;}
 if(n==128){bottom128(a,b,c,work);return;}
 if(n==256){bottom256(a,b,c,work);return;}
 int h=n/2;size_t q=(size_t)h*h;
 /* [r78v6_] **变体 T · work 内部分区错相([STRIDE] 续)**:`q = (h)²` U ⇒ 顶层 q*sizeof(U) =
    (1024²)*16 = **2^24 B ⇒ ≡ 0 (mod 4096)** ⇒ s/t/p5/p6/p7/next 六块基址**同样全部同组**。
    各加 QPAD = 256 U 相位错开。**不改任何尺寸/取值/顺序/语义**,只改六块基址相位。 */
 U*s=work,*t=s+(q+280),*p5=t+(q+280),*p6=p5+(q+280),*p7=p6+(q+280),*next=p7+(q+280);
 const U*a11=a,*a12=a+q,*a21=a+2*q,*a22=a+3*q;
 const U*b11=b,*b12=b+q,*b21=b+2*q,*b22=b+3*q;
 recurse_native(h,a12,b21,c+2*q,next);recurse_native(h,a11,b11,c,next);
 if(h>=256){form_native_streamed<true,true>(q,b12,b11,t);form_native_streamed<false>(q,a21,a22,s);_mm_sfence();}else{form_native<true,true>(q,b12,b11,t);form_native<false>(q,a21,a22,s);}
 recurse_native(h,s,t,p5,next);
 form_native<true>(q,s,a11,s);form_native<true,true>(q,b22,t,t);
 recurse_native(h,s,t,p6,next);
 form_native<true>(q,a12,s,s);form_native<true,true>(q,t,b21,t);
 recurse_native(h,a22,t,c+3*q,next);recurse_native(h,s,b22,c+q,next);
 if(h>=256){form_native_streamed<true,true>(q,b22,b12,t);form_native_streamed<true>(q,a11,a21,s);_mm_sfence();}else{form_native<true,true>(q,b22,b12,t);form_native<true>(q,a11,a21,s);}
 recurse_native(h,s,t,p7,next);
 reconstruct_native(q,c,p5,p6,p7);
}

template<bool Right>static __attribute__((noinline)) void root_forms(const U*raw,U*const d[7]){
 constexpr unsigned n=2048,h=n/2;
 for(unsigned tile=0;tile<h*h/64;tile++){
  unsigned rb=_pext_u32(tile,0xaaaaaaaa)*8,cb=_pext_u32(tile,0x55555555)*8;
  for(unsigned z=0;z<32;z++){
   unsigned r=Right?z%8:z/4,j=Right?(z/8)*2:(z%4)*2;
   const U*p=raw+(size_t)(rb+r)*n+cb+j;__m256i v[4];
   for(unsigned k=0;k<4;k++){v[k]=_mm256_load_si256((const __m256i*)(p+(k/2)*h*n+(k%2)*h));if constexpr(Right)v[k]=_mm256_permute4x64_epi64(v[k],0xb1);}
   __m256i a[7];
   if constexpr(Right){a[0]=v[0];a[1]=v[2];a[2]=v[3];a[4]=transform128<true,true>(v[1],v[0]);a[5]=transform128<true,true>(v[3],a[4]);a[6]=transform128<true,true>(v[3],v[1]);a[3]=transform128<true,true>(a[5],v[2]);}
   else{a[0]=v[0];a[1]=v[1];a[3]=v[3];a[4]=transform128<false,false>(v[2],v[3]);a[5]=transform128<true,false>(a[4],v[0]);a[6]=transform128<true,false>(v[0],v[2]);a[2]=transform128<true,false>(v[1],a[5]);}
   for(unsigned k=0;k<7;k++)_mm256_stream_si256((__m256i*)(d[k]+64*tile+2*z),a[k]);
 }}}
static __attribute__((noinline)) void root_views(const U*a,const U*b,U*out,U*arena){
 constexpr size_t n=2048,h=n/2,q=h*h,stride=q+40;U*aa[7],*bb[7],*prod[7];
 for(unsigned k=0;k<7;k++){aa[k]=arena+stride*k;bb[k]=arena+stride*(7+k);}
 root_forms<false>(a,aa);root_forms<true>(b,bb);_mm_sfence();
 auto*extra=arena+14*stride;U*next=extra+stride;
 unsigned done[7]{};
 for(unsigned k=0;k<7;k++){unsigned id=6-k;done[k]=id;prod[id]=!k?extra:((k&1)?aa[done[(k-1)/2]]:bb[done[(k-1)/2]]);
 recurse_native(h,aa[id],bb[id],prod[id],next);}
 reconstruct_root_final<true>(prod[0],prod[4],prod[5],prod[6],out,prod[1],prod[2],prod[3]);
}
static __attribute__((noinline)) void recurse_root_final(const U*a,const U*b,U*c,U*work,U*out){
 const int h=1024;const size_t q=size_t(h)*h;
 /* [r78v6_] **变体 T · work 内部分区错相([STRIDE] 续)**:`q = (h)²` U ⇒ 顶层 q*sizeof(U) =
    (1024²)*16 = **2^24 B ⇒ ≡ 0 (mod 4096)** ⇒ s/t/p5/p6/p7/next 六块基址**同样全部同组**。
    各加 QPAD = 256 U 相位错开。**不改任何尺寸/取值/顺序/语义**,只改六块基址相位。 */
 U*s=work,*t=s+(q+280),*p5=t+(q+280),*p6=p5+(q+280),*p7=p6+(q+280),*next=p7+(q+280);
 const U*a11=a,*a12=a+q,*a21=a+2*q,*a22=a+3*q;
 const U*b11=b,*b12=b+q,*b21=b+2*q,*b22=b+3*q;
 recurse_native(h,a12,b21,c+2*q,next);recurse_native(h,a11,b11,c,next);
 if(h>=256){form_native_streamed<true,true>(q,b12,b11,t);form_native_streamed<false>(q,a21,a22,s);_mm_sfence();}else{form_native<true,true>(q,b12,b11,t);form_native<false>(q,a21,a22,s);}
 recurse_native(h,s,t,p5,next);
 form_native<true>(q,s,a11,s);form_native<true,true>(q,b22,t,t);
 recurse_native(h,s,t,p6,next);
 form_native<true>(q,a12,s,s);form_native<true,true>(q,t,b21,t);
 recurse_native(h,a22,t,c+3*q,next);recurse_native(h,s,b22,c+q,next);
 if(h>=256){form_native_streamed<true,true>(q,b22,b12,t);form_native_streamed<true>(q,a11,a21,s);_mm_sfence();}else{form_native<true,true>(q,b22,b12,t);form_native<true>(q,a11,a21,s);}
 recurse_native(h,s,t,p7,next);
 reconstruct_root_final(c,p5,p6,p7,out);
}
}
void matrix_multiply(int n,const __int128*A,const __int128*B,__int128*C){
 using namespace matrix_x;
 if(n<=8 || (n&(n-1))){classical(n,(const U*)A,n,(const U*)B,n,(U*)C,n);return;}
 size_t z=(size_t)n*n;
 /* [r78v6_] 轴 C · 缓冲生命周期(单变量):原为「每调用 posix_memalign(4096) + 结尾 free」。
    n=2048 ⇒ 335 544 320 B = 81 920 页;判题机每发只调用一次 ⇒ mmap + 整段 munmap 是纯浪费。
    改为一次分配、跨调用缓存;对齐 4096 → 2 MB 并补 MADV_HUGEPAGE(首触 81 920 → ≈160 次)。
    大小/内容/语义一字未变。 */
 static U *s_arena = 0; static size_t s_cap = 0;
 {
  const size_t need = 5*z*sizeof(U) + 4*280*sizeof(U) + 8*280*sizeof(U);   /* [r78v6_] 含 3 处 PAD 相位 */
  if (need > s_cap) { if (s_arena) free(s_arena); s_arena = 0;
    if (posix_memalign((void**)&s_arena, (size_t)2 << 20, need)) abort(); s_cap = need;
    (void)madvise(s_arena, need & ~(size_t)4095, MADV_HUGEPAGE); }
 }
 U*arena=s_arena;
 /* [r78v6_] **变体 S · 面板基址错相([STRIDE] 刀)**:四个面板 pa/pb/pc/work 的原基址相隔
    `z*sizeof(U)` = n²*16 = **2^26 B**(n=2048)⇒ **≡ 0 (mod 4096)** ⇒ pa/pb/pc 上**相同相对
    偏移的访存全部落在同一个 L1 组**;而 `pair_dot8_fixed` 每次读 a(2 行)+b(4 行)、写 c(1 行)
    ⇒ **该组同时活跃 7 条 line / 8 路**(叠加 work 面板则超过)⇒ 满足 [STRIDE] 前提
    「该组路数被填满」。给每个面板基址加 **PAD = 256 U = 4096 B** 错相 ⇒ 四面板落在 4 个**不同**
    的组相位。**不改任何尺寸/取值/顺序/语义**,只改四个面板的**基址相位**(内部几何/象限偏移 q 全不变)。 */
 const size_t PAD = 280;
 U*pa=arena,*pb=pa+(z+PAD),*pc=pb+(z+PAD),*work=pc+(z+PAD);
 if(n==2048 && ((((uintptr_t)A|(uintptr_t)B|(uintptr_t)C)&31)==0)){root_views((const U*)A,(const U*)B,(U*)C,arena);_mm_sfence();}else{if(n==2048){if((((uintptr_t)A|(uintptr_t)B)&31)==0){pack2048_flat_aligned<false>((const U*)A,pa);pack2048_flat_aligned<true>((const U*)B,pb);}else{pack_native_streamed(n,(const U*)A,n,pa,false);pack_native_streamed(n,(const U*)B,n,pb,true);}_mm_sfence();}else{pack_native(n,(const U*)A,n,pa,false);pack_native(n,(const U*)B,n,pb,true);}
 if(n==2048 && ((uintptr_t)C&31)==0){recurse_root_final(pa,pb,pc,work,(U*)C);_mm_sfence();}else{recurse_native(n,pa,pb,pc,work);unpack_native(n,pc,(U*)C,n);}}
 /* [r78v6_] 轴C:缓冲跨调用缓存 ⇒ 此处不再 free(原先这里是一次 320 MB 的整段 munmap)。 */
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #12.621 s330 MB + 812 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2026-11-23 12:28:29 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠