# metal

Typed Apple Metal compute bindings, over the `Foundation`, `Metal`, and `MetalPerformanceShaders` frameworks. `metal::default_device()` returns a `Device`; chain into `new_command_queue()`, `new_buffer(len)`, `new_library_with_data(bytes)`, and `new_compute_pipeline_state(fn)`. Every wrapper has a `Drop` impl that `objc_release`s the underlying object.

The `metal/mps` sub-module adds **MPS bindings**: Apple's pre-tuned matmul, FFT, and softmax. `MPSMatrixMultiplication` does batched gemm:

```cplus
import "metal/metal" as metal;
import "metal/mps" as mps;

guard let result::Result::Ok(dev) = metal::default_device() else { return 1; };
let q  = dev.new_command_queue();
let mm = mps::MatrixMultiplication::new(dev, false, false, M, N, K, 1.0f64, 0.0f64);
mm.encode_to(cmd_buf, lhs, rhs, out);
```

For the CPU fallback path and result-checking reference, see [accelerate](/docs/packages/accelerate).
