A high-performance inference engine for AI models
perf benchmarks ios support (#331)
eugene2dcf728054ef
diff --git a/crates/uzu/build/main.rs b/crates/uzu/build/main.rsindex a09bd59e8..46995f3dc 100644--- a/crates/uzu/build/main.rs+++ b/crates/uzu/build/main.rs@@ -17,6 +17,10 @@ use common::{compiler::Compiler, envs, traitgen::traitgen_all};async fn main() -> anyhow::Result<()> {println!("cargo::rerun-if-changed=.");+ if env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("ios") && env::var("IPHONEOS_DEPLOYMENT_TARGET").is_err() {+ println!("cargo::rustc-env=IPHONEOS_DEPLOYMENT_TARGET=26.0");+ }+if envs::build_always() {println!("cargo::rerun-if-changed=/var/empty/hack_nonexistent_file_to_always_rerun");}diff --git a/crates/uzu/tests/BENCHMARKS_IOS.md b/crates/uzu/tests/BENCHMARKS_IOS.mdnew file mode 100644index 000000000..9c7ea5541--- /dev/null+++ b/crates/uzu/tests/BENCHMARKS_IOS.md@@ -0,0 +1,49 @@+# Running Kernel Benchmarks on iOS++## Prerequisites++- iPhone connected via USB (iOS 26+)+- Rust nightly toolchain: `rustup toolchain install nightly`+- iOS target: `rustup target add aarch64-apple-ios`+- cargo-dinghy: `cargo install cargo-dinghy`+- Device ID: find with `xcrun devicectl list devices`++## Available benchmarks++| Benchmark group | Filter pattern | MXU required |+| ------------------------------------- | ------------------ | ------------ |+| `Metal/Kernel/Matmul/GEMM_MPP` | `GEMM_MPP/` | yes |+| `Metal/Kernel/Matmul/GEMM_MPP_DIRECT` | `GEMM_MPP_DIRECT/` | yes |+| `Metal/Kernel/RMSNorm` | `RMSNorm/` | no |+| `Metal/Kernel/Sampling/Argmax` | `Argmax/` | no |++## Running benchmarks++Run one benchmark group at a time to avoid iOS watchdog killing the app:++```bash+DEVICE=<DEVICE_ID>++# RMSNorm+cargo +nightly dinghy -d "$DEVICE" bench -p uzu --bench kernel -- "RMSNorm/"+```++## Retrieving Criterion reports++Criterion saves HTML reports inside the Dinghy app's sandbox on the device.+To pull them to your local machine:++```bash+xcrun devicectl device copy from \+ --device <DEVICE_ID> \+ --domain-type appDataContainer \+ --domain-identifier org.zoy.kali.Dinghy \+ --source Documents/target/criterion \+ --destination ./criterion-ios+```++Open the report:++```bash+open criterion-ios/report/index.html+```diff --git a/crates/uzu/tests/unit/kernel/bench_entry.rs b/crates/uzu/tests/unit/kernel/bench_entry.rsindex c00d5a135..553a549c7 100644--- a/crates/uzu/tests/unit/kernel/bench_entry.rs+++ b/crates/uzu/tests/unit/kernel/bench_entry.rs@@ -1,5 +1,21 @@#![feature(custom_test_frameworks)]-#![test_runner(criterion::runner)]+#![test_runner(crate::bench_runner)]++fn bench_runner(benches: &[&dyn Fn()]) {+ #[cfg(target_os = "ios")]+ {+ use objc2_foundation::{NSSearchPathDirectory, NSSearchPathDomainMask, NSSearchPathForDirectoriesInDomains};+ let paths = NSSearchPathForDirectoriesInDomains(+ NSSearchPathDirectory(9), // NSDocumentDirectory+ NSSearchPathDomainMask(1), // NSUserDomainMask+ true,+ );+ if let Some(docs) = paths.firstObject() {+ let _ = std::env::set_current_dir(docs.to_string());+ }+ }+ criterion::runner(benches);+}use dsl::{__internal_uzu_bench as uzu_bench, __internal_uzu_ignored as uzu_test};