.SUFFIXES:
.DELETE_ON_ERROR:
.ONESHELL:
.PHONY: help build test test-fast test-quick test-cuda test-viz coverage coverage-ci coverage-check coverage-clean clean-coverage bench bench-ptx bench-gemm bench-gemm-compare lint fmt clean all
test:
cargo test -p trueno-gpu --all-features -- --nocapture
test-fast:
@echo "โก Running fast tests for trueno-gpu (target: <2 min)..."
@if command -v cargo-nextest >/dev/null 2>&1; then \
PROPTEST_CASES=50 RUST_TEST_THREADS=$$(nproc) cargo nextest run \
-p trueno-gpu \
--status-level skip \
--failure-output immediate; \
else \
PROPTEST_CASES=50 cargo test -p trueno-gpu; \
fi
test-quick: test-fast
@echo "โ
Quick tests completed!"
test-cuda:
@echo "๐ฅ๏ธ Running CUDA tests (requires NVIDIA driver)..."
cargo test -p trueno-gpu --features cuda -- --nocapture
test-viz:
@echo "๐จ Running visual tests..."
cargo test -p trueno-gpu --features viz -- --nocapture
test-stress:
@echo "๐ฅ Running stress tests..."
cargo test -p trueno-gpu --features stress-test -- stress --nocapture
COV_EXCLUDE := --ignore-filename-regex='(driver/memory\.rs|driver/module\.rs|driver/stream\.rs|wasm\.rs|testing/gpu_renderer\.rs)'
coverage:
@echo "๐ Running coverage analysis for trueno-gpu (target: <2 min, 95%+)..."
@which cargo-llvm-cov > /dev/null 2>&1 || (echo "๐ฆ Installing cargo-llvm-cov..." && cargo install cargo-llvm-cov --locked)
@mkdir -p target/coverage
@echo "๐งช Running lib tests with instrumentation (PROPTEST_CASES=5)..."
@echo " Using cargo test (1 profraw per binary) NOT nextest (1 profraw per test)"
@env PROPTEST_CASES=5 cargo llvm-cov --no-report --lib -p trueno-gpu $(COV_EXCLUDE) \
-- --skip matmul_parallel --skip matmul_3level --skip matmul_blocking \
--skip test_all_batch --skip slow --skip heavy
@echo "๐ Generating coverage reports..."
@cargo llvm-cov report --html --output-dir target/coverage/html $(COV_EXCLUDE)
@cargo llvm-cov report --lcov --output-path target/coverage/lcov.info $(COV_EXCLUDE)
@echo ""
@cargo llvm-cov report --summary-only $(COV_EXCLUDE)
@echo ""
@echo "๐ก HTML: target/coverage/html/index.html"
coverage-ci:
@echo "=== Code Coverage for CI/CD (โฅ95% required) ==="
@cargo llvm-cov clean --workspace
@test -f ~/.cargo/config.toml && mv ~/.cargo/config.toml ~/.cargo/config.toml.cov-backup || true
@ @env PROPTEST_CASES=100 cargo llvm-cov --no-report --ignore-filename-regex '(benches/|demos/|examples/|tests/|pkg/|test_output/|docs/|driver/memory\.rs|driver/module\.rs|driver/stream\.rs|wasm\.rs)' nextest --no-tests=warn -p trueno-gpu --all-features
@cargo llvm-cov report --lcov --output-path lcov.info
@test -f ~/.cargo/config.toml.cov-backup && mv ~/.cargo/config.toml.cov-backup ~/.cargo/config.toml || true
@echo "โ Coverage report generated: lcov.info"
coverage-check:
@echo "๐ Enforcing 95% coverage threshold for trueno-gpu..."
@test -f ~/.cargo/config.toml && mv ~/.cargo/config.toml ~/.cargo/config.toml.cov-backup || true
@cargo llvm-cov -p trueno-gpu --all-features --ignore-filename-regex '(benches/|demos/|examples/|tests/|pkg/|test_output/|docs/)' --lcov --output-path lcov.info > /dev/null 2>&1
@test -f ~/.cargo/config.toml.cov-backup && mv ~/.cargo/config.toml.cov-backup ~/.cargo/config.toml || true
@COVERAGE=$$(cargo llvm-cov report --summary-only 2>/dev/null | grep "TOTAL" | awk '{print $$NF}' | sed 's/%//'); \
echo "trueno-gpu coverage: $${COVERAGE}%"; \
if [ $$(echo "$$COVERAGE < 95" | bc -l 2>/dev/null || echo 1) -eq 1 ]; then \
echo "โ FAIL: Coverage below 95% threshold"; \
exit 1; \
else \
echo "โ
Coverage threshold met (โฅ95%)"; \
fi
coverage-clean:
@cargo llvm-cov clean --workspace
@rm -f lcov.info target/coverage/lcov.info
@rm -rf target/llvm-cov target/coverage
@find . -name "*.profraw" -delete
@echo "โ Coverage artifacts cleaned"
clean-coverage: coverage-clean
@echo "โ Fresh coverage ready"
bench:
cargo bench -p trueno-gpu --no-fail-fast
bench-ptx:
@echo "Running PTX generation benchmarks..."
cargo bench -p trueno-gpu --bench ptx_gen --no-fail-fast
bench-gemm:
cargo run --example bench_cublas_vs_ptx --features cuda --release
bench-gemm-compare: bench-gemm
build:
cargo build -p trueno-gpu
build-release:
cargo build -p trueno-gpu --release
build-wasm:
@echo "๐ Building for WASM..."
cargo build -p trueno-gpu --target wasm32-unknown-unknown --features wasm
lint:
@echo "๐ Running clippy for trueno-gpu..."
cargo clippy -p trueno-gpu --all-features -- -D warnings
fmt:
cargo fmt -p trueno-gpu
fmt-check:
cargo fmt -p trueno-gpu -- --check
clean:
cargo clean -p trueno-gpu
rm -f lcov.info
find . -name "*.profraw" -delete
all: lint test-fast
@echo "โ
All checks passed!"
help:
@echo 'trueno-gpu Development Commands:'
@echo ''
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help