内存存储槽
本页中的每个地址、位偏移、opcode 值和字符串都从
libtpu-0.0.40-cp314wheel 中的libtpu.so逐字节读取(BuildID md589edbbe81c5b328a958fe628a9f2207d,未 strip,包含完整 C++ 符号)。.text/.rodata映射满足 VA == file offset。其他 wheel 版本会有所不同。
摘要
内存存储槽是在单个 VLIW 发射字中把计算寄存器写出到片上内存的 bundle 槽,也就是 内存加载槽 的写侧镜像。它不同于片内 DMA:store slot 在一个 bundle 周期内把一个向量寄存器移入 VMEM(或把一个标量寄存器移入 SMEM),而 DMA 通过描述符移动 tier→tier 的块。与加载槽一样,它不携带 tier 选择位;目标 tier 由 (slot, sub-opcode) 决定。
存储槽是一个判别联合,其 sub-opcode 同时选择目标 tier 和寻址模式。每代的 <Bundle><Slot>StoreEncoder::Encode(<msg> const&, absl::Span<uint8_t>) 是规范字节编解码器;在 Pufferfish 以及所有 V5+ 代上,每个字段都通过一次通用位打包器 BitCopy(dst, bit_offset, src, 0, width) 写入。本页所有位位置均为 LSB-first(与 Bundle Model 一致):bit 0 是 byte 0 的最低有效位,字面量 bit_offset 参数就是绝对的、按 LSB 编号的 bundle 位,因此可直接从 encoder 反汇编读出 store-slot 字段图,而无需反向换算移位。store-data 源寄存器总是先写入;随后 sub-opcode 判别符(TensorCore store 中从 proto +0x50 读取,V5e/V6e SparseCore-TEC store 中从 +0x50/+0x58 读取)选择后续的寻址字段。
两个结构事实主导了各代差异。第一,store 槽是 load 槽的读写孪生体:相同的专用 bundle 槽、相同 TensorCoreCodecBase 模板中的成对 Encoder/Decoder、相同的寻址模式分类(base+offset、base-register NoOffset、strided、indexed/scatter),但带有三个仅写侧新增项:sublane/vmask 写使能、SparseCore reduce-add(读-改-写)家族,以及 vector-store fence 排序屏障。第二,各代增量是具体的:bundle 从 41 → 51 → 64 字节;Pufferfish 新增 CMEM-store 和 8 个硬件 vmask 寄存器;Viperfish 将 store-data 字段从 5 → 4 位缩小,同时将 base/offset 从 5 → 6 位扩大,并新增带 reduce-add 的 SparseCore TEC tile-SPMEM store;Ghostlite 将写端口从 1 → 2 翻倍;6acc60406 将 store-fence 移入 misc 槽,并达到包含 atomic SMEM stores 的 34-sub-op SparseCore store 家族。
对重新实现而言,契约是:LloOpcodeIsVectorStore opcode 窗口、各代 store Encoder/Decoder 地址表、PF/VF/GFC 的 BitCopy 绝对位字段图、slot-selects-tier 模型、两个正交的掩码机制(bundle predicate 与 vmask),以及各代差异。
| 槽作用 | 将一个寄存器量的数据移入 VMEM/CMEM/SPMEM(向量)或 SMEM(标量) |
| Tier 选择 | 由 (slot, sub-opcode) 决定(无 tier 位) |
| PXC store encoder | pxc::isa::TensorCoreVectorStoreEncoder::Encode @ 0x1ee3b440(51-B bundle) |
| VXC store encoder | vxc::isa::TensorCoreVectorStoreEncoder::Encode @ 0x1f01ff60(64-B bundle) |
| GFC store encoder | gxc::gfc::isa::TensorCoreVectorStoreEncoder::Encode @ 0x1fa08920(64-B bundle) |
| JF store encoder | jellyfish::isa::EncoderJf::EncodeVectorStoreInstruction @ 0x1e868c40(41-B,单体式) |
| 位原语 | BitCopy(dst, abs_bit, src, 0, width) — abs_bit == 绝对 bundle 位(PF/V5+) |
| Opcode 分类器 | xla::jellyfish::LloOpcodeIsVectorStore @ 0x14024920 → 窗口 {63,64,65,68,69,70} + 460 |
| Store-data 字段 | JF/PF 上为 5-bit,VF/GL/GFC 上为 4-bit;base/offset 在 v5 从 5-bit → 6-bit |
| 写端口 | MaxVectorStoreSlots = JF/PF/VF 上为 1,GL/GFC 上为 2 |
Store 操作列表(LLO Opcodes)
LloOpcode enum 中的 store 家族(内部 k 前缀名称;proto LloOpcodeProto 的 OPCODE_ 前缀名称):
| LloOpcode internal | LloOpcodeProto name | 目标 tier | 槽 |
|---|---|---|---|
kVectorStore | OPCODE_VECTOR_STORE | VMEM | VECTOR_STORE |
kVectorStoreMasked | OPCODE_VECTOR_STORE_MASKED | VMEM(masked) | VECTOR_STORE |
kVectorStoreIndexed | OPCODE_VECTOR_STORE_INDEXED | VMEM(scatter) | VECTOR_STORE |
kVectorStoreIndexedMasked | OPCODE_VECTOR_STORE_INDEXED_MASKED | VMEM(scatter+mask) | VECTOR_STORE |
kVectorStoreSublaneShuffle | OPCODE_VECTOR_STORE_SUBLANE_SHUFFLE | VMEM(shuffled) | VECTOR_STORE |
kVectorStoreEvenOddSublanes | OPCODE_VECTOR_STORE_EVEN_ODD_SUBLANES | VMEM(even/odd) | VECTOR_STORE |
kVectorStoreFence | OPCODE_VECTOR_STORE_FENCE | (排序屏障) | VECTOR_MISC(GFC) |
kVectorCmemStore | OPCODE_VECTOR_CMEM_STORE | CMEM | VECTOR_STORE |
kVectorCmemStorePseudo | OPCODE_VECTOR_CMEM_STORE_PSEUDO | CMEM(pseudo) | VECTOR_STORE |
kBarnaCoreVectorStore | OPCODE_BARNA_CORE_VECTOR_STORE | BarnaCore VMEM | (BCS channel) |
kScalarStore | OPCODE_SCALAR_STORE | SMEM | SCALAR_0/1 |
分类器 xla::jellyfish::LloOpcodeIsVectorStore(@ 0x14024920)逐字节精确:当 (opcode - 63) <= 7 && _bittest(0xE7, opcode - 63) 或 opcode == 460 时返回 true。0xE7 = 0b1110_0111 选择偏移 {0,1,2,5,6,7},即内部 opcodes {63,64,65,68,69,70} 加 460。Scalar-store、CMEM-store 和 BarnaCore-store 由独立谓词分类。
注意 — vector-store fence 不是 store;它是排序屏障。在
6acc60406上,它编码于 VectorMisc 槽(gxc::gfc::isa::TensorCoreVectorMisc0Compact::vector_store_fenceaccessor),而不是 store 槽。bundle packer 的RequiresVectorStoreFence(@0x14020900)由Target::SupportsVectorStoreFence()门控。参见 各代差异。
Store-Slot Encoder/Decoder 地址表
每代都有一个 <Bundle><Slot>StoreEncoder::Encode 和匹配的 <…>StoreDecoder::Decode。decoder 是 encoder 的对称逆 BitExtract。
TensorCore vector-store 槽
| 代 | Namespace | Encode @ | Decode @ |
|---|---|---|---|
| Jellyfish | jellyfish::isa::EncoderJf::EncodeVectorStoreInstruction | 0x1e868c40 | (在 DecoderJf 中成对) |
| Pufferfish | pxc::isa::TensorCoreVectorStore{En,De}coder | 0x1ee3b440 | 0x1ee2dae0 |
| Viperfish | vxc::isa::TensorCoreVectorStore{En,De}coder | 0x1f01ff60 | 0x1f01a560 |
| Ghostlite | gxc::glc::isa::TensorCoreVectorStore{En,De}coder | 0x1f3c3200 | 0x1f3bd780 |
6acc60406 | gxc::gfc::isa::TensorCoreVectorStore{En,De}coder | 0x1fa08920 | 0x1fa02f00 |
Jellyfish 的 TensorCore store 不是独立 codec 类;它是单体式 EncoderJf::EncodeVectorStoreInstruction(VectorStoreInstruction const&, Bundle const&)(@ 0x1e868c40),会内联填充槽位。
SparseCore TEC tile-SPMEM store 槽(仅 V5+)
| 代 | Namespace | Encode @ | Decode @ |
|---|---|---|---|
| Viperfish | vxc::vfc::isa::SparseCoreTecVectorStore{En,De}coder | 0x1e9c2760 | 0x1e9bbf40 |
| Ghostlite | gxc::glc::isa::SparseCoreTecVectorStore{En,De}coder | 0x1eb50ac0 | 0x1eb42300 |
6acc60406 | gxc::gfc::isa::SparseCoreTecVectorStore{En,De}coder | 0x1eccbe20 | 0x1ecbd7a0 |
没有 Jellyfish/Pufferfish SparseCore TEC store;SparseCore TEC sequencer 仅从 Viperfish 开始存在。BarnaCore channel vector-store(仅 Pufferfish)是 pxc::pfc::isa::BarnaCoreChannelVectorStore{En,De}coder(Encode 0x1e8c5640,Decode 0x1e8c4d40)。
Scalar-store 槽(SREG → SMEM)
通过 scalar-slot encoder 路由,而非 vector-store 槽。Jellyfish:ScalarStoreOperands proto,由 EncoderJf::EncodeScalarInstruction(@ 0x1e862060)发出。Pufferfish:TensorCoreScalar1_ScalarStoreSmemAbsolute 经由 ScalarYEncode(@ 0x1c471c60)+ SetImmOrDie(@ 0x1c550660);BarnaCore-sequencer 变体经由 0x1c471fc0/0x1c550e00。Viperfish/Ghostlite:…ScalarAlu_ScalarStoreXToSmemY。6acc60406 新增 …ScalarStoreXToSmemSumDestAndY(atomic add)、…ScalarStoreCircularBuffer 和 SmemFetchAndAdd(通过 EmitFetchAndAddOp @ 0x13a3a300)。
Store 槽在 Bundle 中的位置
store 槽是各代 VLIW bundle 中的一个固定槽;槽顺序是各代 TensorCoreCodecBase<…> 模板参数顺序:
ScalarAlu0 / ScalarAlu1 / [Predicates] / Immediates / VectorScalar /
Dma / VectorAlu0 / VectorAlu1 / [VectorAlu2 / VectorAlu3] /
**VectorStore** / VectorLoad0 / [VectorLoad1] / VectorMisc /
VectorExtended0 / [VectorExtended1] / VectorResult0 / [VectorResult1](Pufferfish 携带 VectorAlu0/1 + VectorStore + VectorLoad + CmemLoad + …。)槽枚举常量对其命名:isa::SLOT_VECTOR_STORE(TC)、isa::SLOT_SCALAR_0/1 和 SLOT_SCALAR_ALU_0/1(scalar stores)、isa::SLOT_VECTOR_MISC(overlay 目标 / store fence)、llvm::TPU::SparseCoreMCSlot::SLOT_VST 和 SLOT_SST(SparseCore vector/scalar store)。Bundle 宽度:Jellyfish/Dragonfish 41 B,Pufferfish 51 B,V5+ TensorCore 64 B;SparseCore SCS 32 B,TEC 64 B。
在 Pufferfish 上,vector_store 槽占据绝对 bundle 位 142..166(见 Pufferfish 51B Bundle),与 119..140 的 vector_load 槽不重叠,因此一个 bundle 中可以同时存在 load 和 store。约束 "SCALAR_STORE_ABSOLUTE not allowed in slot 0." 强制 Jellyfish/Pufferfish 上的 scalar-store absolute 进入 SCALAR_1,绝不进入 SCALAR_0。计数谓词 store_and_misc_slots == module.target().MaxVectorStoreSlots() 将承载 store 的槽数量绑定到各代写端口数。
位字段布局(BitCopy 字段图)
每个 per-slot Encoder 都通过 BitCopy(dst, abs_bit, src, 0, width) 填充槽;store-data 源寄存器先写入,然后 sub-opcode 判别符选择寻址字段。下面的图直接采集自反编译 encoder 中的 BitCopy(a3, …) 调用点;第二个参数是绝对 bundle 位。
Pufferfish (PXC) TensorCoreVectorStore — Encode @ 0x1ee3b440(51-B bundle)
从 encoder 主体逐字节精确读取(BitCopy(a3, 162, …, 5) 等):
| 字段 | abs bit | width | 含义 |
|---|---|---|---|
| source vreg | 162 | 5 | store-data vreg(proto +28);= 31 ⇒ NOOP(kNeverExecute) |
| sub-opcode | 157 | 5 | VmemStore=0 / CmemStore≠0 判别符 |
| base address / Vmem offset | 152 | 5 | VregNumber base |
| offset | 149 | 3 | immediate-offset 槽索引 |
| stride | 147 | 2 | stride 选择 |
| sublane-mask / vmask | 145 | 2 | sublane/vmask 选择 |
| (CMEM full-address words) | 304 / 288 / 272 | 16 | CMEM 16-bit immediate address(仅 CmemStore) |
| (CMEM address regs) | 251 / 246 / 241 | 5 | shared Y-register 选择器 |
PF store 槽区域(abs 142..166)与 Pufferfish 51B Bundle 页面完全一致。Sub-opcode dispatch(proto +0x50):0=Noop,5=NoopAlt,6=CmemStore,7=CmemStoreNoOffset,8=VmemStore,9=VmemStoreNoOffset,0xA-0x11=VmemStoreVmsk0..7,0x12=VmemStoreIndexed,0x13=VmemStoreIndexedNoOffset,0x14-0x1B=VmemStoreIndexedVmsk0..7,0x1C=SetIarLane,0x1D=SetIarSublane,0x1E=SetIarRaw,0x1F=PushV2s。共 32 个 sub-ops。
Viperfish (VXC) TensorCoreVectorStore — Encode @ 0x1f01ff60(64-B bundle)
逐字节精确(BitCopy(a3, 170, …, 4) 等):
| 字段 | abs bit | width | 含义 |
|---|---|---|---|
| source vreg | 170 | 4 | store-data vreg(proto +28) |
| sub-opcode discriminator | 167 | 3 | addr-mode/family |
| secondary opcode / vmsk | 163 | 4 | mask / sub-variant |
| base address / offset | 157 | 6 | VregNumber base |
| stride (Base variants) | 153 | 4 | stride 选择 |
| (Base-variant field) | 151 | 2 | — |
| (trailing field) | 148 | 3 | Vs select / mask |
| address / mask field | 144 | 4 | — |
data-vreg @170 w4 和 base @157 w6 与 Viperfish 64B Bundle 页面完全一致。Sub-opcode dispatch(proto +0x50):0=Noop,5=VectorStore,6=VectorStoreBase,7=VectorStoreMasked,8=VectorStoreBaseMasked,9=VectorStoreShuffled,0xA=VectorStoreShuffledBase,0xB=VectorStoreShuffledMasked,0xC=VectorStoreShuffledBaseMasked,0xD=VectorStoreIndexed0,0xE=VectorStoreIndexed1,0xF=VectorStoreIndexed0Masked,0x10=VectorStoreIndexed1Masked,0x11-0x16=SetLaneIar0/1·SetSublaneIar0/1·SetRawIar0/1,0x17=PushV2s,0x18=SetPrng。共 25 个 sub-ops。
6acc60406 (GFC) TensorCoreVectorStore — Encode @ 0x1fa08920(64-B bundle)
逐字节精确(BitCopy(a3, 169, …, 2) 等):
| 字段 | abs bit | width |
|---|---|---|
| sub-opcode top field | 169 | 2 |
| sub-opcode | 166 | 3 |
| secondary opcode | 162 | 4 |
| base address / offset | 156 | 6 |
| stride / mask | 152 | 4 |
| (Base-variant field) | 150 | 2 |
| (field) | 147 | 3 |
| (field) | 143 | 4 |
Sub-opcode dispatch 与 Viperfish 相同。Ghostlite 的 TensorCoreVectorStoreEncoder(@ 0x1f3c3200)在结构上与 VXC/GFC 相同(相同 sub-op 集、相同模板),仅位偏移随代变化;其字段图未单独 dump — HIGH,基于模板一致性。
6acc60406 (GFC) SparseCoreTecVectorStore — Encode @ 0x1eccbe20(64-B TEC bundle)
逐字节精确(BitCopy(a3, 359, …, 3) 等),store 槽位于高位区域,是最丰富的 store 家族:
| 字段 | abs bit | width |
|---|---|---|
| opcode | 359 | 3(4 alt) |
| normal-predication | 362 | 1 |
| rotate-predication | 363 | 1 |
| base / source | 353 | 6 |
| offset | 347 | 6 |
| stride | 340 | 3 |
| mask | 337 | 3 |
| (field) | 333 | 4 |
Sub-opcode dispatch(proto +0x4c,34 个 case):0=Noop,8=TileSpmemStore,9=TileSpmemStoreCircularBuffer,随后是 reduce-add 矩阵 — TileSpmemStoreAdd{S32,S16,F32,Bf16}、*CircularBufferAdd*、*CircularBufferPostUpdateAdd*、TileSpmemIndexedStore、*IndexedCircularBuffer*、*IndexedAdd{S32,S16,F32,Bf16}*、*IndexedReturnValueAdd*、*IndexedCircularBufferReturnValueAdd{S32,S16,F32,Bf16}*。除上述共享位置外,每个变体内部字段宽度未穷尽 dump(HIGH)。
Jellyfish EncodeVectorStoreInstruction — @ 0x1e868c40(41-B bundle)
逐字节精确 dispatch:先编码 predication(switch 前调用 EncodePredication<VectorStoreInstruction>),然后 switch(*((_DWORD*)a2 + 12)),即 proto +12 处的 sub-opcode:
- family A
{0,6,0x10-0x17}:sublane-mask + stride store(EncodeVectorSublaneMaskEncoding、EncodeVectorStrideEncoding)。 - family B
{1,7,0x18-0x1F}:offset + base + sublane-mask + stride store(EncodeVectorOffsetEncoding、EncodeVectorBaseAddressEncoding,再加上上述两个)。 - family C
{2,3,4}:indexed store(SetIndexedAddressOperands,由v36[3]&1路由)。 case 5:NOOP。default:"Not implemented yet."fatal。
per-field encoder 写入共享 immediate 槽:内部 switch(v12[8]) 的 case 0-3 选择 6 个 immediate 槽中的哪一个保存 5-bit register number,写在 Bundle bytes 31..39。store-data vreg 打包在 byte 22(5-bit)/ byte 13;TTU operand 位于 byte 19/63。41-byte bundle 内的绝对槽基址来自 Bundle byte map(LOW — 此处未钉住)。
寻址模式
四种寻址模式,由 sub-opcode 选择,与加载槽使用相同分类:
- (a) base + immediate-offset(带 offset 的
VmemStore/VectorStore):base 是按粒度缩放的 VMEM 字节偏移;offset 是放入 immediate 槽的立即数。 - (b) base + register-offset(
VmemStoreNoOffset/VectorStoreBase):base 保存在 Vs 寄存器中,没有 immediate-offset 字段。PufferfishPlaceVsRegister<BaseAddress, VmemStore>会把 base 放入 3 个 Vs 槽之一。 - (c) strided:每个 store 都携带 stride 字段。Pufferfish
StrideToSyU32<VmemStore>(@0x1d2970a0)将 stride 编码为 Sreg number 或 U32 immediate(variant<SregNumber, ImmediateValueU32>);目标地址在各 sublane 之间按stride粒度移动。 - (d) indexed / scatter(PXC 的
VmemStoreIndexed/ VXC/GXC 的VectorStoreIndexed0/1/ SC-TEC 的TileSpmemIndexedStore):每 lane 目标地址来自通过SetIar*暂存的 index-address register(IAR);store 将 vector lanes scatter 到逐 lane 地址。VXC/GXC 有两个 index 端口(Indexed0/Indexed1)以支持两个共存 scatter 流;PXC 有一个。
IAR 由专用 store-slot sub-ops 设置:PXC 的 SetIarLane/SetIarSublane/SetIarRaw(cases 0x1C-0x1E);VXC/GXC 的 SetLaneIar0/1/SetSublaneIar0/1/SetRawIar0/1(cases 0x11-0x16)。保护条件 kVectorStoreEvenOddSublanesIar < target.IarsPerTensorCore() 确认 IAR 数量按代变化。
Memory-Tier 目标编码
目标 tier 由单个 VectorStore 槽内的具体 sub-opcode 选择(不是 tier 位):
| 目标 tier | Sub-op family / path |
|---|---|
| VMEM | VmemStore*(PXC 8-0x1B)/ VectorStore*(VXC/GXC 5-0x10) |
| CMEM | CmemStore/CmemStoreNoOffset(PXC cases 6-7;16-bit imm address @304/288/272) |
| SPMEM | TileSpmemStore*(SparseCore TEC 槽) |
| SMEM | ScalarStoreSmemAbsolute/ScalarStoreXToSmemY(SCALAR/SCALAR_ALU 槽,不是 vector-store) |
| BarnaCore VMEM | BarnaCoreChannelVectorStore(Pufferfish PFC channel 槽) |
LLO opcode(kVectorStore vs kVectorCmemStore vs kScalarStore)从 IR 向下携带 tier 选择;各代 lowering 将其映射到匹配槽中的匹配 sub-opcode。这与加载槽使用的 slot-selects-tier 模型相同,基于运行时 MemorySpace Enum;SMEM tier 由 buffer-assignment 不变量 dest_address->memory_space() == MemorySpace::kSmem 断言。CMEM-store sub-ops 仅存在于 Pufferfish;更高代将 CMEM 折入 VMEM 类寻址,或通过 kVectorCmemStorePseudo lowering。
Store 粒度
store 每周期移动一个完整向量寄存器,并由以下机制调制:
- SublaneMask(
sublane_maskproto 字段):逐 sublane 写使能。在 VXC/GXC 上,Masked sub-op 变体增加显式 mask;在 PXC 上,8 个VmemStoreVmsk0..7变体选择 8 个硬件 vector-mask 寄存器之一。 - Even/odd-sublane split(
kVectorStoreEvenOddSublanes):只存储偶数或奇数 sublanes(sublane-stride 2)— VXC/GXC 通过 sublane-stride 字段实现,Jellyfish 通过 family A 的 stride encoder 实现。 - Indexed/scatter(逐 lane):最细粒度;每个 lane 从 IAR 写入独立地址。
- Reduce-add(仅 SparseCore TEC,V5+):
TileSpmemStoreAdd{S32,S16,F32,Bf16}— store-with-accumulate(SPMEM[addr] += vector),加上 circular-buffer post-update 和 return-value 变体。这是唯一会读取目标(读-改-写)的 store 家族。
除 sublane mask 和 stride 外,没有逐元素计数字段;store 总是处理完整 SIMD 宽度。验证字符串 "VectorStore mask length is not equal to target SIMD width." 强制 mask 覆盖准确的 lane/sublane 数量。
Masked / Predicated Store
两个正交的掩码机制:
- Bundle predication — 每个 store 槽都携带 predicate-register 引用(Jellyfish 上经
EncodePredication<VectorStoreInstruction>为 5-bit;V5+ 上为 predication enum)。值 0..14 = predicate register,15 =kAlwaysExecute,31 =kNeverExecute(NOP);false predicate 抑制整个 store。proto 字段是predication(PXC 上为TensorcorePredication,glc/gfc 上为Predication;SparseCore TEC 还额外拆分normal_predication@362 和rotate_predication@363)。 - Vector write-mask(sublane/vmask)— 逐 sublane(或逐 lane)写使能,独立于 bundle predicate。PXC 有 8 个硬件 vmask 寄存器(
Vmsk0..7,sub-opsVmemStoreVmsk0..7和VmemStoreIndexedVmsk0..7)。VXC/GXC 携带显式mask字段(TEC 上为SparsecoreVectorMask)以及 Masked sub-op 变体。
Predicated store = bundle-predicate 门控;masked store = vmask/sublane 写使能。两者可同时应用(例如 predicated VmemStoreVmsk3)。
各代差异
| 属性 | JF (v2) | PF (v4) | VF (v5p) | GL (v6e) | GFC (TPU7x) |
|---|---|---|---|---|---|
| TC bundle width (B) | 41 | 51 | 64 | 64 | 64 |
MaxVectorStoreSlots(写端口) | 1 | 1 | 1 | 2 | 2* |
NumVsSlots(读/base 端口) | 3 | 3 | 4 | 4 | 4* |
| Store-data vreg 字段宽度 | 5 | 5 | 4 | 4 | 4 |
| Base/offset 字段宽度 | 5 | 5 | 6 | 6 | 6 |
CanOverlayInMiscSlot | false | (n/a) | a2==1 | true | true* |
| 硬件 vmask 寄存器 | 仅 sublane | 8(Vmsk0..7) | mask field | mask field | mask field |
| Indexed/scatter 端口 | 1 | 1 | 2(Idx0/1) | 2 | 2 |
| CMEM store sub-ops | no | yes | no | no | no |
| SparseCore TEC tile-SPMEM store | n/a | n/a | yes | yes | yes(+RMW) |
| SPMEM reduce-add(S32/S16/F32/Bf16) | n/a | n/a | yes | yes | yes(34 sub-ops) |
| Scalar-store SMEM atomic add | no | no | no | no | yes(SumDestAndY / FetchAndAdd) |
SupportsVectorStoreFence | false | false | false | false | misc-slot |
已验证的 target overrides:JellyfishTarget::MaxVectorStoreSlots=1(@0x1d4916a0),Pufferfish=1(@0x1d495be0),Viperfish=1(@0x1d49c0a0),Ghostlite=2(@0x1d498ca0)。CanOverlayInMiscSlot:Jellyfish=false(@0x1d491680),Ghostlite=true(@0x1d498c80)。SupportsVectorStoreFence 在 JF/PF/VF/GL 上为 false(@0x1d48f660/0x1d493fa0/0x1d499f00/0x1d497060)。Dragonfish (v3) 共享 Jellyfish codec。
结构差异:
- v2→v4(JF→PF):bundle 41→51 B;新增 CMEM-store sub-ops;新增 8 个显式硬件 vmask 寄存器(
VmemStoreVmsk0..7)。 - v4→v5p(PF→VF):bundle 51→64 B;store-data 字段 5→4 位,同时 base/offset 5→6 位;TC 槽中移除 CMEM-store;新增 sublane-shuffle store;2 个 scatter index 端口;引入 SparseCore TEC tile-SPMEM store 家族(带 reduce-add)。
- v5p→v6e(VF→GL):
MaxVectorStoreSlots1→2(两个 VMEM 写端口);CanOverlayInMiscSlot完全为 true — store 槽可以 overlay misc 槽,共享 vmask(TensorCoreCodecBase中的CheckVectorStoreSlotAndMiscSlotShareVmsk)。 - v6e→TPU7x(GL→GFC):store-fence 移入 VectorMisc compact message;scalar SMEM stores 获得 atomic add(
ScalarStoreXToSmemSumDestAndY、SmemFetchAndAdd);SparseCore TEC store 达到 34 个 sub-ops(完整 reduce-add + circular-buffer + indexed + return-value 矩阵)。
(*) 6acc60406(gfc)store 复用 gxc EncoderBase 模板;标记为 * 的 V5+ 属性值已通过 VF/GL 的 Target overrides 确认,gfc 专有值来自共享模板加已验证的 gfc store-encoder 位图(0x1fa08920)。
Load / Store 槽对称性与非对称性
store 槽是 内存加载槽 的结构镜像:
- 镜像:两者都占用专用 bundle 槽(TC 上
SLOT_VECTOR_STORE/SLOT_VECTOR_LOAD;SparseCore 上SLOT_VST/SLOT_VLD),通过相同 per-genTensorCoreCodecBase模板中的成对 Encoder/Decoder 类解码,并共享寻址模式分类(base+immediate-offset、base+register-offset NoOffset、strided、indexed)。SetIar*sub-ops 位于 store 槽,但其设置的 IAR 可被后续 indexed load 消耗,反之亦然。kVectorLoad和kVectorStore在内部LloOpcodeenum 中相邻(store 窗口从内部 opcode 63 开始)。 - 非对称 1 — 端口数:load 有
NumVsSlots读端口(3/3/4/4),store 有MaxVectorStoreSlots写端口(1/1/1/2)。VMEM 在 Ghostlite 将写端口翻倍前,一直是读宽、写窄。 - 非对称 2 — 写使能:store 槽新增 sublane-mask/vmask 写使能,这是写侧概念,没有 load 对应物。
- 非对称 3 — RMW:只有 store 侧拥有 SparseCore TEC reduce-add(读-改-写)家族。
- 非对称 4 — fence:到同一 VMEM 区域的 store→load 排序由 vector-store fence 保护(
RequiresVectorStoreFence@0x14020900,IsVmemReadPrecededByVmemStoreFence@0x14020820)— store 后的 load 需要 fence;反向则不需要。
尚未钉住的内容
- Jellyfish 41-B bundle 中 store 槽的绝对字节偏移。 V5+
BitCopy偏移是 bundle 绝对位;Jellyfish per-field encoder 路由到共享 immediate 槽(Bundle bytes 31..39),其绝对基址需要完整 Jellyfish Bundle byte map。LOW。 - 34 个 SparseCore-TEC reduce-add 内部字段宽度。 dispatch 和共享位置(359/353/347/340/337/333)已 CONFIRMED;每个 Add/CircularBuffer/ReturnValue 变体的内部宽度未穷尽 dump。HIGH。
- Ghostlite glc store
BitCopy字段图 — 结构上与 vxc/gfc 相同(相同 sub-ops、相同模板),未单独 dump。HIGH。 kScalarStore/kVectorCmemStore/kBarnaCoreVectorStore/kVectorStoreFence的完整 LloOpcode internal→proto 整数(kVectorStore*窗口{63,64,65,68,69,70,460}已 CONFIRMED;其他需要ProtoToLloOpcodeswitch decode)。- 各代
Target::IarsPerTensorCore()数值(门控 indexed-store IAR 数量)。LOW。
交叉引用
- 内存加载槽 — 读侧镜像;共享寻址模式分类、IAR 共享以及上述 load/store 非对称性。
- MemorySpace Enum — store 槽选择 tier 所基于的 17 值运行时 enum,以及 proto↔enum 重映射。
- Bundle Model — 各代 bundle 宽度(41/51/64)以及此槽接入的槽分类。
- Pufferfish 51B Bundle — PXC 上
vector_store槽的绝对 bundle 位(142..166)。 - Viperfish 64B Bundle — VXC/GLC/GFC store 槽所遵循的 V5+ per-slot
Encoder::Encode+BitCopy模型(data-vreg @170,base @157)。 - MC-Emitter — MC 层 store mnemonics 和寄存器编码表。
- Memory Subsystem Overview — store 槽写入的 tier 模型(HBM/VMEM/SMEM/CMEM/SPMEM)。