Expand description
Tensor-extension intrinsics: TensorLoad, TensorLoadB, TensorFMA32, TensorStore, and TensorWait, all encoded as RISC-V CSR writes. Tensor-extension intrinsics for the ET-SoC-1 Minion core.
All tensor instructions on the ET-SoC-1 are encoded as standard RISC-V
csrrw xd, <csr>, xs writes (see PRM Chapter 9). No custom opcode or
target-feature extension is required: riscv64imac suffices because the
operand registers are ordinary integer GPRs (the source value xs is an
integer register; the FP register file is accessed implicitly by the
tensor co-processor hardware, not by the instruction encoding).
§Concurrency model
The tensor co-processor operates independently of the RISC-V hart’s
integer pipeline. Issuing a tensor instruction initiates an asynchronous
operation; the hart must call [tensor_wait] with the appropriate
[TensorEvent] before reading results or reusing the scratchpad. The
ordering guarantees are:
TensorWait(Load0)beforetensor_fma32: scratchpad A is populated.TensorWait(Fma)beforetensor_store: FP register file holds final C.fence rw, rw(viacrate::fence) aftertensor_store: stores are visible to other Minions and the DMA engine before the kernel returns.
§Scratchpad layout
Each Minion has a private 48-line L1 scratchpad (3 072 bytes). Only the
primary hart of the Minion (hart 0, i.e. mhartid & 1 == 0) should issue
tensor load/store/FMA instructions; the companion hart (hart 1) must not
touch the same scratchpad lines concurrently.
Structs§
- Tensor
Error - Tensor co-processor error status, returned by
check_tensor_error.
Enums§
- Tensor
Event - Tensor co-processor synchronisation events for
tensor_wait.
Constants§
- CSR_
TENSOR_ ERROR - TensorError CSR (
tensor_error): latched error flags from the co-processor. (PRM Table 9-1: 0x808, not 0x831) - CSR_
TENSOR_ FMA - TensorFMA CSR (
tensor_fma): selects the FMA variant via xs bits 3:1. (PRM Table 9-7: TensorFMA32 = 3:1 000, TensorFMA16A32 = 001, …) - CSR_
TENSOR_ LOAD - TensorLoad / TensorLoadB CSR (
tensor_load): load from memory to the L1 scratchpad (xs bit 52 = 0) or to the TenB register file (bit 52 = 1). - CSR_
TENSOR_ LOAD_ L2 - TensorLoadL2Scp CSR: loads rows from memory to the shire L2 cache without
consuming any L1 scratchpad lines. Useful for prefetching A strips while
the current k-loop tile executes, so the subsequent
tensor_load(L1 fill) completes from L2 rather than DRAM. - CSR_
TENSOR_ MASK - TensorMask CSR (
tensor_mask): per-row enable bits for the A tile. (PRM Table 9-1: 0x805, not 0x832) - CSR_
TENSOR_ STORE - TensorStore CSR (
tensor_store): store from FP registers (bit 48 = 0) or from the L1 scratchpad (bit 48 = 1 = TensorStoreFromScp) to memory. (PRM Table 9-7: 0x87F, not 0x83E) - CSR_
TENSOR_ WAIT - TensorWait CSR (
tensor_wait): stalls the hart until the requested event.
Functions§
- check_
tensor_ error - Check the tensor co-processor error register and return a typed result.
- fma32_
xs - Build the xs value for a TensorFMA32 instruction.
- set_
tensor_ mask - Write the per-row enable mask for the next TensorFMA.
- tensor_
error - Read the tensor co-processor error status register.
- tensor_
fma32 ⚠ - Initiate an asynchronous TensorFMA32.
- tensor_
load ⚠ - Initiate an asynchronous TensorLoad from memory into the L1 scratchpad.
- tensor_
load_ ⚠b - Initiate an asynchronous TensorLoadB from memory into the TenB register file.
- tensor_
load_ ⚠l2 - Initiate an asynchronous TensorLoadL2Scp from memory into the shire L2 cache.
- tensor_
store ⚠ - Initiate an asynchronous TensorStore from the FP register file to memory.
- tensor_
wait - Stall the hart until the specified tensor co-processor event fires.