TGATHERB¶
指令示意图¶
简介¶
使用字节偏移量收集元素。
数学语义¶
对每个元素 在有效区域内:
\[ \mathrm{dst}_{i,j} = *\left(\mathrm{srcBase} + \mathrm{offset}_{i,j}\right) \]
Exact bounds behavior is implementation-defined.
汇编语法¶
PTO-AS 形式:参见 PTO-AS Specification.
同步形式:
%dst = tgatherb %src, %offsets : !pto.tile<...> -> !pto.tile<...>
AS Level 1 (SSA)¶
%dst = pto.tgatherb %src, %offsets : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
AS Level 2 (DPS)¶
pto.tgatherb ins(%src, %offsets : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
AS Level 1(SSA)¶
%dst = pto.tgatherb %src, %offsets : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
AS Level 2(DPS)¶
pto.tgatherb ins(%src, %offsets : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
C++ 内建接口¶
声明于 include/pto/common/pto_instr.hpp:
template <typename TileDataDst, typename TileDataSrc, typename TileDataOffset, typename... WaitEvents>
PTO_INST RecordEvent TGATHERB(TileDataDst &dst, TileDataSrc &src, TileDataOffset &offset, WaitEvents &... events);
约束¶
- 实现检查 (A2A3):
- Destination layout must be row-major (
TileDataDst::isRowMajor). - Destination element size must be
1,2, or4bytes (enforced viastatic_assertin the helper). SrcTileData::DType/DstTileData::DTypemust beint8_toruint8_torint16_toruint16_torint32_toruint32_torhalforbfloat16_torfloat.
- Destination layout must be row-major (
- 实现检查 (A5):
- Destination element size must be
1,2, or4bytes. SrcTileData::DType/DstTileData::DTypemust beint8_toruint8_torint16_toruint16_torint32_toruint32_torhalforbfloat16_torfloat.
- Destination element size must be
- Offset interpretation:
- Offsets are interpreted as
uint32_tvalues (byte offsets) by the implementation. - Offset bounds are not validated by explicit runtime assertions; out-of-range offsets are target-defined.
- Offsets are interpreted as
示例¶
自动(Auto)¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example_auto() {
using SrcT = Tile<TileType::Vec, uint8_t, 1, 256>;
using OffT = Tile<TileType::Vec, uint32_t, 1, 256>;
using DstT = Tile<TileType::Vec, uint8_t, 1, 256>;
SrcT src;
OffT off;
DstT dst;
TGATHERB(dst, src, off);
}
手动(Manual)¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example_manual() {
using SrcT = Tile<TileType::Vec, uint8_t, 1, 256>;
using OffT = Tile<TileType::Vec, uint32_t, 1, 256>;
using DstT = Tile<TileType::Vec, uint8_t, 1, 256>;
SrcT src;
OffT off;
DstT dst;
TASSIGN(src, 0x1000);
TASSIGN(off, 0x2000);
TASSIGN(dst, 0x3000);
TGATHERB(dst, src, off);
}