# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. Personal overrides (e.g. always preferring the Makefile) belong in a git-ignored `CLAUDE.local.md` in the repo root, not here. ## What this is Halide is a compiler embedded in C++ (with Python bindings) for writing high-performance image/array processing pipelines. Users describe pipelines as `Func`/`Var`/`Expr` algebra (front-end), which Halide lowers to an internal `Stmt`/`Expr` IR, applies dozens of scheduling/optimization passes to, then codegens via LLVM for CPU targets (x86, ARM, Hexagon, PowerPC, RISC-V, Wasm) or emits device-C/shading code for GPU backends (CUDA, OpenCL, Metal, D3D12, Vulkan, WebGPU). ## Building CMake (3.28+) is the supported build system; the top-level `Makefile` also works and is preferred by some contributors, but is unsupported for third parties ("use at your own risk", can't build Python bindings or packages). If instructed to use the Makefile, don't forget to verify that any new tests are added to the CMake build too before pushing. Halide needs LLVM 21, 22, or 23 (trunk also works). Easiest way to get one is via a `uv`-managed Python virtual env; activate it before building so CMake can autodetect the LLVM install: ```shell $ uv sync --frozen --group ci-llvm-22 --no-install-workspace $ source .venv/bin/activate ``` Basic build: ```shell $ cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release $ cmake --build build ``` If CMake can't find LLVM (e.g. the venv isn't active in the current shell), pass it explicitly: `-DHalide_LLVM_ROOT=$(halide-llvm --prefix)` (run `halide-llvm` from inside the venv to get the right absolute path). On macOS with Homebrew LLVM, `cmake --preset=macOS -S . -B build` finds it automatically. Other useful presets (see `CMakePresets.json`): `debug`, `release`, `release-vcpkg`, `macOS-fuzz`, `macOS-coverage`, `linux-x64-asan`, `linux-x64-fuzzer`, `valgrind`, `sde`. Key build options (`Halide_feature(...)` in `CMakeLists.txt`): `WITH_TESTS`, `WITH_AUTOSCHEDULERS`, `WITH_PYTHON_BINDINGS`, `WITH_SERIALIZATION`, `WITH_TUTORIALS`, `WITH_UTILS`, `WITH_DOCS`. `Halide_ENABLE_MEMCHECK` enables `ctest -T memcheck` (valgrind) runs. Details: `doc/BuildingHalideWithCMake.md`. Package-consumer docs: `doc/HalideCMakePackage.md`. ## Testing Tests use CTest and live under `test/`, one CTest label per subdirectory (`correctness`, `error`, `warning`, `generator`, `performance`, `runtime`, `fuzz`, `integration`, `autoschedulers/$AS`). See `doc/Testing.md` for the full breakdown of conventions (e.g. `error` tests expect an uncaught non-Halide exception, `warning` tests look for a `Warning:` line, tests print `[SKIP]` when inapplicable to the current target). ```shell $ ctest --test-dir build --output-on-failure # everything $ ctest --test-dir build -L correctness # one label $ ctest --test-dir build -R correctness_bounds # one test by name ``` Test binaries are named `