pto.tcmps¶
pto.tcmps is part of the Tile Scalar And Immediate instruction set.
Summary¶
Compare a tile against a scalar and write per-element comparison results.
Mechanism¶
Compare a tile against a scalar and write per-element comparison results. It operates on tile payloads rather than scalar control state, and its legality is constrained by tile shape, layout, valid-region, and target-profile support.
For each element (i, j) in the valid region:
The encoding/type of dst is target-specific: on A2/A3 the predicate tile uses uint8_t with 1 bit per element (packed 8 elements per byte), and on A5 it uses uint32_t with 1 bit per element (packed 32 elements per DWORD).
Syntax¶
Textual spelling is defined by the PTO ISA syntax-and-operands pages.
Synchronous form:
%dst = tcmps %src, %scalar {cmpMode = #pto.cmp<EQ>} : !pto.tile<...> -> !pto.tile<...>
AS Level 1 (SSA)¶
%dst = pto.tcmps %src, %scalar {cmpMode = #pto<cmp xx>} : (!pto.tile<...>, dtype) -> !pto.tile<...>
AS Level 2 (DPS)¶
pto.tcmps ins(%src, %scalar{cmpMode = #pto<cmp xx>}: !pto.tile_buf<...>, dtype) outs(%dst : !pto.tile_buf<...>)
IR Level 1 (SSA)¶
%dst = pto.tcmps %src, %scalar {cmpMode = #pto<cmp xx>} : (!pto.tile<...>, dtype) -> !pto.tile<...>
IR Level 2 (DPS)¶
pto.tcmps ins(%src, %scalar{cmpMode = #pto<cmp xx>}: !pto.tile_buf<...>, dtype) outs(%dst : !pto.tile_buf<...>)
C++ Intrinsic¶
Declared in include/pto/common/pto_instr.hpp and include/pto/common/type.hpp:
template <typename TileDataDst, typename TileDataSrc0, typename T, typename... WaitEvents>
PTO_INST RecordEvent TCMPS(TileDataDst& dst, TileDataSrc0& src0, T src1, CmpMode cmpMode, WaitEvents&... events);
Inputs¶
srcis the source tile.scalaris the scalar value broadcast to all lanes;cmpModeselects comparison predicate.dstnames the destination predicate tile.- The operation iterates over
dst's valid region.
Expected Outputs¶
dst carries the result tile or updated tile payload produced by the operation.
Side Effects¶
No architectural side effects beyond producing the destination tile. Does not implicitly fence unrelated traffic.
Constraints¶
Constraints
-
Common constraints:
- Tile location must be vector (
TileData::Loc == TileType::Vec). - Static valid bounds:
TileData::ValidRow <= TileData::RowsandTileData::ValidCol <= TileData::Cols. - Runtime:
src0anddstmust have the same valid row/col.
- Tile location must be vector (
-
Valid region:
- The op uses
dst.GetValidRow()/dst.GetValidCol()as the iteration domain.
- The op uses
-
Comparison modes:
- Supports
CmpMode::EQ,CmpMode::NE,CmpMode::LT,CmpMode::GT,CmpMode::LE,CmpMode::GE.
- Supports
Exceptions¶
Exceptions
- Illegal operand tuples, unsupported types, invalid layout combinations, or unsupported target-profile modes are rejected by the verifier or by the selected backend instruction set.
- Programs must not rely on behavior outside the documented legal domain of this operation, even if one backend currently accepts it.
Target-Profile Restrictions¶
Target-Profile Restrictions
-
Implementation checks (A2A3):
TileData::DTypemust be one of:int32_t,float,half,uint16_t,int16_t.- Tile layout must be row-major (
TileData::isRowMajor).
-
Implementation checks (A5):
TileData::DTypemust be one of:int32_t,float,half,uint16_t,int16_t.- Tile layout must be row-major (
TileData::isRowMajor).
Examples¶
Auto¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example_auto() {
using SrcT = Tile<TileType::Vec, float, 16, 16>;
using DstT = Tile<TileType::Vec, uint8_t, 16, 32, BLayout::RowMajor, -1, -1>;
SrcT src;
DstT dst(16, 2);
TCMPS(dst, src, 0.0f, CmpMode::GT);
}
Manual¶
#include <pto/pto-inst.hpp>
using namespace pto;
void example_manual() {
using SrcT = Tile<TileType::Vec, float, 16, 16>;
using DstT = Tile<TileType::Vec, uint8_t, 16, 32, BLayout::RowMajor, -1, -1>;
SrcT src;
DstT dst(16, 2);
TASSIGN(src, 0x1000);
TASSIGN(dst, 0x2000);
TCMPS(dst, src, 0.0f, CmpMode::GT);
}
Auto Mode¶
# Auto mode: compiler/runtime-managed placement and scheduling.
%dst = pto.tcmps %src, %scalar {cmpMode = #pto<cmp xx>} : (!pto.tile<...>, dtype) -> !pto.tile<...>
Manual Mode¶
# Manual mode: bind resources explicitly before issuing the instruction.
# Optional for tile operands:
# pto.tassign %arg0, @tile(0x1000)
# pto.tassign %arg1, @tile(0x2000)
%dst = pto.tcmps %src, %scalar {cmpMode = #pto<cmp xx>} : (!pto.tile<...>, dtype) -> !pto.tile<...>
PTO Assembly Form¶
%dst = tcmps %src, %scalar {cmpMode = #pto.cmp<EQ>} : !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.tcmps ins(%src, %scalar{cmpMode = #pto<cmp xx>}: !pto.tile_buf<...>, dtype) outs(%dst : !pto.tile_buf<...>)
Related Ops / Instruction Set Links¶
- Instruction set overview: Tile Scalar And Immediate
- Previous op in instruction set: pto.texpands
- Next op in instruction set: pto.tsels