Lobsters | 📄 原文链接 | 2026-10-29 收录

让 SIMD 代码吃到任意位宽:把向量转置进通道

来源:streamhpc.com — 2026-10-28

📋 概述

图形代码里到处是 vec3/vec4,这类写法通常吃不满 SSE 之后更宽的指令集。Nemi Verploegh 讲的办法是「转置」:不要让一个向量占满一个寄存器,而是让同一次运算的多个向量各占一个通道,于是宽度能从 4 扩到 8 或 16,未来 32 也适用。他用 Clang 的 ext_vector_type 代替 intrinsics 展示,先做「同时算 N 个点积」的基础例子,再用视锥体裁剪作为进阶案例,全部数字来自 Ryzen 7 5800 与 Clang 23.1.0,并给出 Compiler Explorer 链接。

🔑 核心要点

💡 金句

The issue is that this typically doesn't scale beyond the SSE instruction set. In this post I want to share how you can “transpose” those vectors into lanes to scale your math operations beyond just those typical 4 component XMM registers.
← 返回 Lobsters 首页