Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 70 additions & 11 deletions .github/workflows/pr-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,22 @@ jobs:
echo "sha=${LLVM_SOURCE_SHA}" >> "$GITHUB_OUTPUT"
echo "Resolved latest LLVM ${LLVM_REF} -> ${LLVM_SOURCE_SHA}"

- name: Restore LLVM build cache
id: cache-llvm
- name: Restore complete v2 toolchain cache
id: cache-llvm-v2
uses: actions/cache/restore@v4
with:
path: |
toolchain/src
toolchain/build
toolchain/stamps
toolchain/output/linx_blockisa_llvm_musl
key: llvm-${{ runner.os }}-tileop-required-gate-v2-${{ steps.llvm-source.outputs.sha }}
restore-keys: |
llvm-${{ runner.os }}-tileop-required-gate-v2-

- name: Restore legacy exact-SHA LLVM cache
id: cache-llvm-legacy
if: steps.cache-llvm-v2.outputs.cache-hit != 'true'
uses: actions/cache/restore@v4
with:
path: |
Expand Down Expand Up @@ -105,26 +119,71 @@ jobs:
echo "Toolchain SHA: $(git -C toolchain rev-parse HEAD)"
echo "LLVM SHA: $(git -C toolchain/src/llvm-project rev-parse HEAD)"

- name: Build latest toolchain
- name: Restore, incrementally update, or build toolchain
working-directory: toolchain
env:
V2_CACHE_HIT: ${{ steps.cache-llvm-v2.outputs.cache-hit }}
V2_CACHE_MATCHED_KEY: ${{ steps.cache-llvm-v2.outputs.cache-matched-key }}
LEGACY_CACHE_HIT: ${{ steps.cache-llvm-legacy.outputs.cache-hit }}
EXACT_V2_KEY: llvm-${{ runner.os }}-tileop-required-gate-v2-${{ steps.llvm-source.outputs.sha }}
ENABLE_CCACHE: on
THREADS: '4'
run: |
set -euo pipefail
export PATH="/usr/lib/ccache:$PATH"
make WITH_TARGET=linx64v5-linux-musl

if [ "${V2_CACHE_HIT}" = "true" ]; then
echo "Exact complete toolchain cache hit: ${EXACT_V2_KEY}"
echo "Skipping toolchain build."
exit 0
fi

if [ "${LEGACY_CACHE_HIT}" = "true" ] && \
[ -x output/linx_blockisa_llvm_musl/bin/clang ]; then
echo "Reusing the legacy exact-SHA LLVM cache."
mkdir -p stamps
touch stamps/check-write-permission
touch stamps/build-llvm-musl
elif [[ "${V2_CACHE_MATCHED_KEY}" == llvm-${{ runner.os }}-tileop-required-gate-v2-* ]] && \
[ -f build/build-llvm-musl/CMakeCache.txt ]; then
echo "Updating the nearest v2 LLVM build tree incrementally."
if cmake -S src/llvm-project/llvm -B build/build-llvm-musl && \
cmake --build build/build-llvm-musl --parallel "${THREADS}" && \
cmake --install build/build-llvm-musl; then
cd output/linx_blockisa_llvm_musl/bin
ln -s -f clang linx64v5-linux-musl-clang
ln -s -f clang++ linx64v5-linux-musl-clang++
cd ../../..
mkdir -p stamps
touch stamps/build-llvm-musl
else
echo "Incremental LLVM update failed; falling back to a clean build."
rm -rf build/build-llvm-musl output/linx_blockisa_llvm_musl stamps
fi
else
echo "No reusable LLVM build tree found; performing a clean build."
rm -f stamps/build-llvm-musl
fi

if ! make WITH_TARGET=linx64v5-linux-musl; then
echo "Cached/incremental toolchain completion failed; retrying once cleanly."
rm -rf \
build/build-llvm-musl \
output/linx_blockisa_llvm_musl \
stamps
make WITH_TARGET=linx64v5-linux-musl
fi

- name: Save LLVM build cache
if: steps.cache-llvm.outputs.cache-hit != 'true'
if: steps.cache-llvm-v2.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
toolchain/build/build-llvm-musl
toolchain/stamps/build-llvm-musl
toolchain/output/linx_blockisa_llvm_musl/bin
toolchain/output/linx_blockisa_llvm_musl/lib
toolchain/output/linx_blockisa_llvm_musl/include
key: llvm-${{ steps.llvm-source.outputs.sha }}-${{ runner.os }}-tileop-required-gate-v1
toolchain/src
toolchain/build
toolchain/stamps
toolchain/output/linx_blockisa_llvm_musl
key: llvm-${{ runner.os }}-tileop-required-gate-v2-${{ steps.llvm-source.outputs.sha }}

- name: Run TileOP contract checks
working-directory: toolchain/src/Linx-TileOP-API
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ check:
bash -n test/tileop_api/compile.all test/tileop_api/run_negatives.sh \
test/tileop_api/verify_pto0583_asm.sh \
test/tileop_api/verify_target_cxx_frontend.sh
git diff --check
@if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then \
git diff --check; \
fi

install:
@echo "Installing $(LIBNAME) to Clang toolchain at $(INSTALL_DIR)"
Expand Down
25 changes: 12 additions & 13 deletions include/jcore/template_asm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ inline void TMOV(Tile &dst, const Tile &src) {
const size_t valid_row = src.GetValidRow();
asm volatile(
"BSTART.TLSU TMOV, %D[DataType]\n"
"B.DATR NORM, DTYPE_NONE, Zero\n"
"B.DIM %[ValidCol], 0, ->lb0\n"
"B.DIM %[ValidRow], 0, ->lb1\n"
"B.IOT %[Src], mask=1111, last, ->%[Dst]<%Z[TileSize]>\n"
Expand Down Expand Up @@ -6708,7 +6707,7 @@ void TCMP(tile_shape_out &dst, tile_shape_in &src0, tile_shape_in &src1) {
if constexpr (Mode == CmpMode::EQ) {
asm volatile(
"BSTART.TEPL 13, %D[TCode]\n"
"B.DATR Zero, cmode0\n"
"B.DATR Zero, EQ\n"
"B.DIM %[VCOL], 0, ->lb0\n"
"B.DIM %[VROW], 0, ->lb1\n"
"B.DIM zero, %c[Cols], ->lb2\n"
Expand All @@ -6726,7 +6725,7 @@ void TCMP(tile_shape_out &dst, tile_shape_in &src0, tile_shape_in &src1) {
} else if constexpr (Mode == CmpMode::NE) {
asm volatile(
"BSTART.TEPL 13, %D[TCode]\n"
"B.DATR Zero, cmode1\n"
"B.DATR Zero, NE\n"
"B.DIM %[VCOL], 0, ->lb0\n"
"B.DIM %[VROW], 0, ->lb1\n"
"B.DIM zero, %c[Cols], ->lb2\n"
Expand All @@ -6744,7 +6743,7 @@ void TCMP(tile_shape_out &dst, tile_shape_in &src0, tile_shape_in &src1) {
} else if constexpr (Mode == CmpMode::LT) {
asm volatile(
"BSTART.TEPL 13, %D[TCode]\n"
"B.DATR Zero, cmode2\n"
"B.DATR Zero, LT\n"
"B.DIM %[VCOL], 0, ->lb0\n"
"B.DIM %[VROW], 0, ->lb1\n"
"B.DIM zero, %c[Cols], ->lb2\n"
Expand All @@ -6762,7 +6761,7 @@ void TCMP(tile_shape_out &dst, tile_shape_in &src0, tile_shape_in &src1) {
} else if constexpr (Mode == CmpMode::GT) {
asm volatile(
"BSTART.TEPL 13, %D[TCode]\n"
"B.DATR Zero, cmode3\n"
"B.DATR Zero, GT\n"
"B.DIM %[VCOL], 0, ->lb0\n"
"B.DIM %[VROW], 0, ->lb1\n"
"B.DIM zero, %c[Cols], ->lb2\n"
Expand All @@ -6780,7 +6779,7 @@ void TCMP(tile_shape_out &dst, tile_shape_in &src0, tile_shape_in &src1) {
} else if constexpr (Mode == CmpMode::LE) {
asm volatile(
"BSTART.TEPL 13, %D[TCode]\n"
"B.DATR Zero, cmode4\n"
"B.DATR Zero, LE\n"
"B.DIM %[VCOL], 0, ->lb0\n"
"B.DIM %[VROW], 0, ->lb1\n"
"B.DIM zero, %c[Cols], ->lb2\n"
Expand All @@ -6798,7 +6797,7 @@ void TCMP(tile_shape_out &dst, tile_shape_in &src0, tile_shape_in &src1) {
} else if constexpr (Mode == CmpMode::GE) {
asm volatile(
"BSTART.TEPL 13, %D[TCode]\n"
"B.DATR Zero, cmode5\n"
"B.DATR Zero, GE\n"
"B.DIM %[VCOL], 0, ->lb0\n"
"B.DIM %[VROW], 0, ->lb1\n"
"B.DIM zero, %c[Cols], ->lb2\n"
Expand Down Expand Up @@ -7387,7 +7386,7 @@ void TCMPS(tile_shape_out &dst, tile_shape_in &src,
if constexpr (Mode == CmpMode::EQ) {
asm volatile(
"BSTART.TEPL 45, %D[TCode]\n"
"B.DATR Zero, cmode0\n"
"B.DATR Zero, EQ\n"
"B.DIM %[VCOL], 0, ->lb0\n"
"B.DIM %[VROW], 0, ->lb1\n"
"B.DIM zero, %c[Cols], ->lb2\n"
Expand All @@ -7406,7 +7405,7 @@ void TCMPS(tile_shape_out &dst, tile_shape_in &src,
} else if constexpr (Mode == CmpMode::NE) {
asm volatile(
"BSTART.TEPL 45, %D[TCode]\n"
"B.DATR Zero, cmode1\n"
"B.DATR Zero, NE\n"
"B.DIM %[VCOL], 0, ->lb0\n"
"B.DIM %[VROW], 0, ->lb1\n"
"B.DIM zero, %c[Cols], ->lb2\n"
Expand All @@ -7425,7 +7424,7 @@ void TCMPS(tile_shape_out &dst, tile_shape_in &src,
} else if constexpr (Mode == CmpMode::LT) {
asm volatile(
"BSTART.TEPL 45, %D[TCode]\n"
"B.DATR Zero, cmode2\n"
"B.DATR Zero, LT\n"
"B.DIM %[VCOL], 0, ->lb0\n"
"B.DIM %[VROW], 0, ->lb1\n"
"B.DIM zero, %c[Cols], ->lb2\n"
Expand All @@ -7444,7 +7443,7 @@ void TCMPS(tile_shape_out &dst, tile_shape_in &src,
} else if constexpr (Mode == CmpMode::GT) {
asm volatile(
"BSTART.TEPL 45, %D[TCode]\n"
"B.DATR Zero, cmode3\n"
"B.DATR Zero, GT\n"
"B.DIM %[VCOL], 0, ->lb0\n"
"B.DIM %[VROW], 0, ->lb1\n"
"B.DIM zero, %c[Cols], ->lb2\n"
Expand All @@ -7463,7 +7462,7 @@ void TCMPS(tile_shape_out &dst, tile_shape_in &src,
} else if constexpr (Mode == CmpMode::LE) {
asm volatile(
"BSTART.TEPL 45, %D[TCode]\n"
"B.DATR Zero, cmode4\n"
"B.DATR Zero, LE\n"
"B.DIM %[VCOL], 0, ->lb0\n"
"B.DIM %[VROW], 0, ->lb1\n"
"B.DIM zero, %c[Cols], ->lb2\n"
Expand All @@ -7482,7 +7481,7 @@ void TCMPS(tile_shape_out &dst, tile_shape_in &src,
} else if constexpr (Mode == CmpMode::GE) {
asm volatile(
"BSTART.TEPL 45, %D[TCode]\n"
"B.DATR Zero, cmode5\n"
"B.DATR Zero, GE\n"
"B.DIM %[VCOL], 0, ->lb0\n"
"B.DIM %[VROW], 0, ->lb1\n"
"B.DIM zero, %c[Cols], ->lb2\n"
Expand Down
4 changes: 2 additions & 2 deletions test/common/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ CXX = $(COMPILER_DIR)/clang++
LINK = $(COMPILER_DIR)/clang++
DUMP = $(COMPILER_DIR)/llvm-objdump
COPY = $(COMPILER_DIR)/llvm-objcopy
CC_O = --target=$(LINX_TARGET) -c -fenable-matrix -O2
CC_O = --target=$(LINX_TARGET) -c -mlxbc -fenable-matrix -O2
CC_VER ?= -std=c++20
CC_LINK += --target=$(LINX_TARGET)
CC_LINK += --target=$(LINX_TARGET) -mlxbc
ifneq ($(strip $(LINX_SYSROOT)),)
CC_O += --sysroot=$(LINX_SYSROOT) -nostdinc++ \
-isystem $(LINX_SYSROOT)/include/c++/v1
Expand Down
37 changes: 3 additions & 34 deletions test/tileop_api/compile.all
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
set -euo pipefail

# Compile every active Linx fixture without assuming that each translation
# unit is an executable. Link only the explicit hosted smoke subset, whose
# sources contain main(), and validate the exact PTO identity in every ELF.
# unit is an executable.

MODE=${1:-all}
PLAT=${PLAT:-linx}
Expand All @@ -28,11 +27,6 @@ ACTIVE_FIXTURES=(
RangeSubview RangeAssemble SharedRange
)

# These fixtures have intentionally minimal hosted mains. They exercise scalar,
# TLSU, and CUBE linkage without pulling unrelated host reference/iostream code
# into the target smoke.
LINK_SMOKES=(DynamicShape DynamicTlsuStride GroupMatmul)

# Pre-v0.58 wrapper designs remain available to cpu_sim only and are not part
# of Linx target reachability: MatMacc, MatMul_e4m3, MatMul, test_MatMacc,
# test_MatMul, TCI, TCmp, TCopy, TReshape, TExpandCol, TExpandRow,
Expand All @@ -59,33 +53,8 @@ run_objects() {
test "$failed" -eq 0
}

verify_pto_identity() {
local elf=$1
python3 ./verify_pto_identity.py "$elf" || return 1
}

run_link_smokes() {
local root elf passed=0 failed=0 testcase
root=$(git rev-parse --show-toplevel)
for testcase in "${LINK_SMOKES[@]}"; do
"$MAKE_CMD" --no-print-directory --silent clean
elf="$root/output/tileop_api/elf/tileop_api_${testcase}_${PLAT}.elf"
if "$MAKE_CMD" --no-print-directory --silent TESTCASE="$testcase" &&
verify_pto_identity "$elf"; then
echo "PASS link+PTO identity: $testcase"
passed=$((passed + 1))
else
echo "FAIL link+PTO identity: $testcase" >&2
failed=$((failed + 1))
fi
done
echo "Link smoke: $passed passed, $failed failed"
test "$failed" -eq 0
}

case "$MODE" in
objects) run_objects ;;
link-smoke) run_link_smokes ;;
all) run_objects; run_link_smokes ;;
*) echo "usage: $0 [objects|link-smoke|all]" >&2; exit 2 ;;
all) run_objects ;;
*) echo "usage: $0 [objects|all]" >&2; exit 2 ;;
esac
4 changes: 2 additions & 2 deletions test/tileop_api/run_negatives.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ LINX_TARGET=${LINX_TARGET:-linx64-unknown-linux-musl}
CXX="$TC_DIR/clang++"
OUT=$(mktemp -d "${TMPDIR:-/tmp}/tileop-negatives.XXXXXX")
trap 'rm -rf "$OUT"' EXIT
FLAGS=(--target="$LINX_TARGET" -c -fenable-matrix -O2 -std=c++20 -D__linx
FLAGS=(--target="$LINX_TARGET" -c -mlxbc -fenable-matrix -O2 -std=c++20 -D__linx
-DENABLE_TENSOR_INSTR -I../../include)
if [[ -n "${LINX_SYSROOT:-}" ]]; then
FLAGS+=(--sysroot="$LINX_SYSROOT" -nostdinc++
-isystem "$LINX_SYSROOT/include/c++/v1")
fi
CASES="dtype maxabs_no_max rowmax_shape groupmax_shape lone_shared_a local_transpose old_rowmajor mismatched_m_layout local_k shared_cube_layout gemv_rows mixed_numeric_class unsigned_prequant bad_d_valid_shape bad_acc_dtype bad_bias_dtype bad_mx_scale_dtype bad_mx_scale_shape missing_mx_scale_a missing_mx_scale_b extra_mx_scale_a extra_mx_scale_b bad_transpose_d group_shape group_k group_n group_dynamic"
TS_CASES="dtype_full dtype_part layout_full layout_part mask0 mask16 mask3 size_small size_large"
TS_CASES="dtype_full dtype_part layout_full layout_part mask0 mask16 mask3 size_large"
RANGE_CASES="subview_dest assemble_source"
PASS=0; FAIL=0

Expand Down
Loading
Loading