Crux is a With library for low-level compute: devices, memory, views, programs, streams, and events.
This repository is initialized as a library scaffold. The pure Session 1 surface from the Crux design is in place:
- shape and stride math
- dtype helpers
- view construction and view transforms
- memory placement helpers
- the initial public API split across
crux.core,crux.view,crux.device,crux.memory,crux.program,crux.stream, andcrux.collective
The pure surface is in place, and the first CPU runtime spike is now
implemented for the basic handle path: default device, heap-backed
memory, arena allocation, borrowed-memory interop, copy/fill
operations, CPU streams, completed events, and a first CPU interpreter
for the current IR subset. The runtime path now validates byte ranges
before dispatch/copy/fill, rejects invalid writable aliases, and uses
memmove-safe byte copies on CPU.
Compiled programs now carry real parameter signatures, named binding
validation, v2 Param and SpecConstant header handling, text-IR
compilation for the current scalar and loop subset, a first IR
validation pass for the current instruction subset, and programmatic
loop execution for the first CPU kernel slice: scalar add, 1D i32
parallel add, scalar reduction, nested 2D text-IR loops with multi-rank
index tuples, row-wise 2D reduction, 2D transpose, text-IR fma,
text-IR neg, text-IR abs, text-IR
mod, text-IR add_sat/sub_sat, text-IR bitwise
and/or/xor/not/shl/shr, text-IR bitcount popcount/clz/ctz, text-IR
exp/log/log2, text-IR sin/cos/tanh, text-IR floor, text-IR
ceil, text-IR round, text-IR sqrt, text-IR rsqrt, text-IR
cast, text-IR compare/select, text-IR min/max/clamp,
proven scalar i64, f32, and f64 add plus pointwise i64, f32,
and f64 add/fma, pointwise u32 xor, pointwise i32 -> f32 cast,
pointwise i32 abs, pointwise i32 mod, pointwise i32 saturating
arithmetic, pointwise i32 bitwise/shift/bitcount ops, pointwise f32
exp/log/log2/sin/cos/tanh/floor/ceil/round/sqrt/rsqrt, and a tiny 2D
matmul-shaped loop nest. The CPU kernel corpus now also has a public
crux.kernels module with canonical ProgramSource builders for map,
in-place map, reduction, transpose, and matmul kernels, plus builder-
backed execution over contiguous, non-contiguous, and broadcast-read
views. Unsupported scalar dtypes in the current
interpreter slice now reject at compile/validation time instead of
surprising the runtime, and text-IR indices are validated as i32/u32
only.
Remaining dtype breadth, collectives, and Metal remain ahead.
lib/crux.w: package root metadatalib/crux/core.w: handles, scalar/data types, shapes, strides, bindingslib/crux/view.w: pure view construction and transformation helperslib/crux/device.w: device API and CPU device implementationlib/crux/memory.w: memory, arena, and placement APIslib/crux/program.w: program compilation APIlib/crux/stream.w: stream, event, and data movement APIslib/crux/collective.w: collective API scaffoldlib/crux/ir.w: IR instruction/program definitions and opcode tablelib/crux/ir_text.w: minimal text IR parser for debug/test inputslib/crux/kernels.w: canonical public CPU-kernelProgramSourcebuilderslib/crux/cpu_interp.w: CPU reference executor for the current IR subsettest/core_test.w: shape, stride, dtype, and placement teststest/view_test.w: view semantics teststest/cpu_interp_test.w: scalar and 1D CPU interpreter execution teststest/kernel_source_test.w: compile/signature regressions for public kernel sourcestest/kernel_cpu_test.w: canonical CPU kernel corpus and execution-baseline teststest/runtime_stub_test.w: CPU runtime smoke and contract teststest/ir_test.w: IR data-model and source-plumbing teststest/ir_text_test.w: minimal text IR parser teststest/view_smoke.w: end-to-end pure view smoke testscripts/test.sh: runs the current file-based test suitedocs/: copied design and implementation notesdocs/crux-milestone-board.md: current milestone board and exit criteria
- The scaffold follows the Crux implementation notes where it matters for current With support. Shape and stride metadata now use fixed arrays plus machine-sized integer types, and runtime handles now follow the opaque-pointer API model.
with.tomlis present for package identity, even though the current compiler remains primarily file-oriented.
with check lib/crux/core.w
./scripts/test.shThe current compiler build in this environment accepts with test
for individual source files but still expects an explicit main
wrapper, so the repo test runner shells out once per test file and
each test source keeps a tiny main that calls the local test_*
functions.