# rust.help - Full Compiler, GPGPU, and Safe Language Subset Reference > Complete Markdown rendering of PathScale EKOPathRS, ENZO GPGPU, `sc++`, `Ro`, `Rython`, and `Rortran` user guides, plus direct JSON endpoints for all `no_std` Rust guides and tutorials. - Compact index: https://rust.help/llms.txt - Guides JSON index (182 articles): https://rust.help/data/guides-index.json - Tutorials JSON index (90 lessons): https://rust.help/data/tutorials-index.json --- ## EKOPathRS (PURE-RUST CPU COMPILER) - Web URL: https://rust.help/ekopathrs - Raw JSON: https://rust.help/data/specs/ekopathrs.json A pure-Rust resident CPU compiler server (`ekod`) and instant socket client (`ekors`): zero LLVM, millisecond function-level rebuilds, native ARM64 and x86-64 SIMD/matrix codegen, and plain-English loop reports. ### Why Developers Use EKOPathRS - **Instant function-level rebuilds:** Warm resident server recompiles only changed functions instead of whole crate graphs. - **No 100 GB `target/` piles:** Replaces duplicated crate spam with clean object files that enable near-instant incremental rebuilds. - **Tuned for real server & workstation CPUs:** Emits native ARM64 (`NEON`, `SVE/SVE2`, Apple M4 `SME/SME2`) and `x86-64` (`AVX2`, `AVX-512`) machine code. - **Plain-English loop reports:** Explains why a CPU loop did not vectorize, tile, or fuse instead of failing silently. ```sh # 1. Start the resident compiler once (stays warm in memory): ekod --daemon --socket /tmp/eko.sock # 2. Compile Rust straight to native CPU machine code (zero LLVM): export EKOD_SOCKET=/tmp/eko.sock ekors compile compute.rs --target aarch64 dir=./out # 3. Ask what vectorized on CPU and what declined: ekors report loops ekors report reasons ``` Start `ekod` once and query `ekors` over a Unix socket with zero cold-start overhead. ### Supported CPU Targets - **Per-core hardware profiles:** Separate measured scheduling, cache-blocking, and vector/matrix pipe models per CPU family. - **Zero LLVM or Cranelift:** 100% owned instruction selection, register allocation, list scheduling, and Mach-O / ELF emission. | Architecture | Supported CPU Profiles | Vector & Matrix ISA | | --- | --- | --- | | `aarch64` (Apple Silicon) | `apple-m4` (P-core & E-core profiles) | 128-bit `NEON`, `FP16`/`BF16`/`I8MM`, `SME` & `SME2` matrix tiles | | `aarch64` (Cloud Server) | AWS `graviton2`, `graviton3`, `graviton4`, `graviton5` (`neoverse-n1`..`v3`), `armv8-a` | `NEON`, `DotProd`, `BF16`, `I8MM`, scalable `SVE` & `SVE2` | | `x86_64` (Server & Desktop) | Linux ELF & SysV `x86-64` (including Ice Lake-SP server profiles) | `SSE`..`SSE4.2`, `FMA`, `BMI1/2`, `AVX2`, `AVX-512` (`F/BW/DQ/VL/IFMA/VBMI/VNNI`) | ### CPU Performance - **Rust aliasing reaches CPU codegen:** `&` and `&mut` prove non-aliasing end-to-end so loops vectorize without unsafe pointer hints. - **Real CPU clock benchmarking:** `search --by both` times candidate loop schedules on your host CPU to beat static guesses. - **Cache-blocked GEMM & loop nests:** Performs loop interchange, L1/L2 cache tiling, fusion, unrolling, and streaming prefetch. - **Bounds checks hoisted:** Proving slice lengths up front strips per-element checks out of tight inner CPU loops. ```rust pub fn axpy_cpu(y: &mut [f64], x: &[f64], alpha: f64) { assert_eq!(y.len(), x.len()); for i in 0..y.len() { y[i] = alpha.mul_add(x[i], y[i]); } } ``` Safe Rust slices: `&mut [f64]` and `&[f64]` cannot alias, and `assert_eq!` hoists bounds checks out of the vector loop. ### Security & Code Safety - **Verified transformations:** Every loop and machine pass is checked so aggressive CPU rewrites never silently miscompile. - **Refusals are answers:** Declined passes leave your code untouched and report the exact line and reason. - **Replayable pass recipes:** Every compiled function records the exact sequence of passes chosen so regressions are traceable. - **Hardware timing & spill hygiene:** Supports ARM64 `DIT` constant-time execution and stack-spill scrubbing on sensitive code. ```sh # Group declined CPU loop optimizations by root cause: ekors report reasons # Inspect every loop decision on one hot function: ekors report loops axpy_cpu # Benchmark legal CPU schedules on hardware and pick the fastest: ekors search axpy_cpu --by both ``` Stop reading `objdump` to guess why a loop slowed down after a refactor. ### Daily CLI & External Crates - **Zero-compiler client:** `ekors` links no compiler libraries; it sends one socket command, prints the answer, and exits. - **Automatic incremental:** Content digests skip unchanged files automatically without any `--changed` flag. - **Cargo `.rmeta` support:** Register external `.rmeta` crates and proc-macro `.dylib`s with `set inputs`. | Command | What It Does | | --- | --- | | `compile ...` | Compiles `.rs` files or directories straight to native CPU objects. | | `search [fn] [--by model|clock|both]` | Finds the fastest verified CPU schedule by model, clock, or both. | | `transform [fn] [name]` | Applies one named optimization (or all candidates) and checks equivalence. | | `report [fn]` | Reads `units`, `loops`, `triage`, `refusals`, `reasons`, `stats`, or `mem`. | | `set inputs ...` | Registers `--edition` and `--extern=name=/path/lib*.rmeta` (or `.dylib`). | | `reset` / `shutdown` | Clears session state or stops the `ekod` daemon cleanly. | ```sh ekors set inputs --edition=2021 \ --extern=serde=/path/to/deps/libserde-HASH.rmeta \ --extern=serde_derive=/path/to/deps/libserde_derive-HASH.dylib ekors compile src/lib.rs --target aarch64 dir=./out ``` ### What EKOPathRS Isn't - **No LLVM anywhere:** Zero LLVM C++ libraries or passes exist anywhere in the compiler. - **Not a one-shot CLI batch wrapper:** Driven cleanly through a warm `ekod` daemon via `ekors`, not 1,600 legacy CLI flags. - **No 100 GB `target/` piles:** Clean object files replace duplicated `.rlib` and `target/debug/incremental` spam for near-instant incremental rebuilds. - **Not a `RUSTC_WRAPPER` shim:** Compiles functions directly instead of pretending to be `rustc` over crate-sized codegen units. - **Not a silent black box:** When an optimization declines, it tells you why instead of guessing. --- ## ENZO GPGPU (DIRECT-TO-HARDWARE GPGPU & AI ACCELERATORS) - Web URL: https://rust.help/enzo - Raw JSON: https://rust.help/data/specs/enzo.json Add attributes to plain loops and compile straight to native GPU and AI accelerator machine code (NVIDIA SASS, Apple Native GPU, AMD CDNA, Intel Gaudi, AWS Trainium2) with zero bytecode and zero middleware. ### Why Developers Use ENZO - **Direct to silicon:** Emits raw hardware binaries (`NVIDIA SASS`, `Apple9` AGX, `AMD CDNA`, `Gaudi2/3`) with no bytecode and no vendor SDKs. - **One pure codebase:** Write ordinary functions and slices instead of maintaining separate GPU shader files. - **Stock `rustc` compatible:** PathScale ENZO turns attributes into zero-cost no-ops on standard Cargo builds. - **Honest float math:** Choose bit-exact `reproducible`, `deterministic`, or `relaxed` reductions. ```rust use enzo::prelude::*; #[kernel(fp(deterministic))] pub fn l2_normalise_rows(rows: &mut [f32], width: usize) { #[parallel(groups(auto))] for r in 0..(rows.len() / width) { let row = &mut rows[r * width..(r + 1) * width]; let mut sum = 0.0f32; #[parallel(lanes(32), reduction(+: sum))] for &v in row.iter() { sum += v * v; } let inv = 1.0 / sum.sqrt().max(1e-12); #[parallel(lanes(32))] for v in row.iter_mut() { *v *= inv; } } } ``` Compiled directly to native GPU/accelerator machine instructions and CPU vector lanes with zero intermediate bytecode. ### Supported GPU & Accelerator Targets - **Zero PTX, SPIR-V, or vendor shader compilers:** Every target below is encoded directly to native machine words. - **CPU fallback always built:** Every `#[kernel]` also compiles a native ARM64 / x86-64 host version. | Hardware Family | Supported Silicon | Direct Output Format | | --- | --- | --- | | NVIDIA Datacenter & Ada | Ada (`sm_89`: L4 / RTX 4090), Hopper (`sm_90a`: H100 / H200), Blackwell (`sm_100a` / `sm_103a`: B200 / GB200 / B300) | Raw native `SASS` cubin | | Apple Native GPU | `Apple9` / `G16` (M4 family) | Direct native AGX machine code | | AMD Instinct CDNA | CDNA2 (`gfx90a`: MI250), CDNA3 (`gfx942`: MI300X), CDNA4 (`gfx950`: MI350) | Native AMDGPU ELF machine code | | Intel Gaudi | `Gaudi2` & `Gaudi3` (`Doron1`) | Direct VLIW `TPC` bundles & `MME` matrix descriptors | | AWS Trainium | `Trainium2` (`trn2` NeuronCore) | Direct `f32` tile instruction stream / `NEFF` | | Many-Core CPU | ARM64 (`M4` / `Graviton 2..5`) & `x86-64` | Native `NEON`, `SVE/SVE2`, `SME/SME2`, `AVX2`, `AVX-512` | ### Performance & GPU Residency - **No driver JIT stalls:** Ships native device machine code directly to our `no_std` Rust GPU runtime (`envyrs`), ready to launch immediately. - **Direct hardware dispatch (`envyrs`):** Allocates, tracks residency, and launches kernels directly over IOKit (`AGX`), NVIDIA RM/QMD, and AMD/Gaudi queues with zero vendor SDK bloat. - **On-chip SRAM staging:** `cache(centroids)` stages hot slices directly into fast group-shared SRAM. - **Upload once:** `enzo::Resident` pins tensors on the accelerator across hundreds of steps (zero-copy on unified RAM). - **Smart size guards:** `when(len >= 64)` keeps tiny batches on the CPU when launch overhead costs more. ```rust #[device] fn sq_dist(a: &[f32], b: &[f32]) -> f32 { a.iter().zip(b).map(|(x, y)| (x - y) * (x - y)).sum() } #[kernel(fp(deterministic))] pub fn distances( #[readonly] features: &[f32], #[readonly] centroids: &[f32], #[out] dists: &mut [f32], n: usize, k: usize, dim: usize, ) { #[parallel(groups(auto))] for i in 0..n { let point = &features[i * dim..(i + 1) * dim]; #[parallel(lanes(auto), cache(centroids))] for c in 0..k { dists[i * k + c] = sq_dist(point, ¢roids[c * dim..(c + 1) * dim]); } } } pub fn run_steps(features_host: &[f32], centroids: &mut [f32], n: usize, k: usize, dim: usize) { let features = enzo::Resident::read_only(features_host); let mut dists = enzo::Device::<[f32]>::zeroed(n * k); for _ in 0..60 { distances(&features, centroids, dists.as_host(), n, k, dim); } } ``` `features` stays resident across all 60 launches; `#[out]` skips uploading uninitialized `dists` bytes. ### Security & Code Safety - **Proven parallel legality:** Loops parallelize only when proven independent, reduced, or `atomic(...)`. - **Unsafe facts require `unsafe`:** Unchecked programmer assertions require an explicit `unsafe` wrapper. - **Must-consume linear types:** `#[enzo::linear]` catches forgotten `let lease = ...;` drops that `#[must_use]` misses. - **Constant-time crypto:** `#[enzo::constant_time]` rejects branches and table lookups on `#[enzo::secret]` data. ```rust #[enzo::linear] pub struct DmaLease { slot: u32 } #[enzo::consumes] pub fn release_dma(lease: DmaLease) { /* hardware teardown */ } #[enzo::constant_time] pub fn ct_select(#[enzo::secret] bit: u8, #[enzo::secret] a: u64, #[enzo::secret] b: u64) -> u64 { let mask = 0u64.wrapping_sub(bit as u64); (a & mask) | (b & !mask) } ``` Secret stack spills are scrubbed before return and guarded by hardware data-independent timing (`DIT`). ### One Vocabulary Across 5 Languages - **Direct hardware codegen everywhere:** Identical ENZO semantics across Rust, `sc++`, `Ro`, `Rython`, and `Rortran`. - **Inert on stock toolchains:** Every host compiler (`rustc`, `clang++`, `go`, `python3`, `gfortran`) builds the same source cleanly. | Capability | Rust | sc++ (C++23) | Ro (Go 1.22) | Rython (Py 3.12) | Rortran (F2018) | | --- | --- | --- | --- | --- | --- | | Kernel | `#[kernel]` | `[[enzo::kernel]]` | `//enzo:kernel` | `@enzo.kernel` | `!$enzo kernel` | | Parallel loop | `#[parallel]` | `[[enzo::parallel]]` | `//enzo:parallel` | `enzo.parallel` | `!$enzo parallel` | | Read-only input | `#[readonly]` | `[[enzo::readonly]]` | `/*enzo:readonly*/` | `enzo.ReadOnly` | `!$enzo readonly` | | Linear type | `#[enzo::linear]` | `[[enzo::linear]]` | `//enzo:linear` | `@enzo.linear` | `!$enzo linear` | | Constant-time | `#[enzo::constant_time]` | `[[enzo::constant_time]]` | `//enzo:constant_time` | `@enzo.constant_time` | `!$enzo constant_time` | ### What ENZO Isn't - **Not a wrapper over vendor GPU SDKs:** Zero bytecode, zero intermediate shader text, and zero vendor compiler middleware. - **Not `-ffast-math` roulette:** Default `fp(reproducible)` refuses any schedule that alters sequential float bits. - **Not general heap code on GPUs:** `#[kernel]` forbids `Vec::push`, `Box`, `String`, `dyn` calls, recursion, and `panic!`. - **Not blind pragma parallelism:** Conflicting writes without `atomic` or `reduction` fail at compile time instead of racing. --- ## sc++ (STRICT ISO C++23) - Web URL: https://rust.help/scpp - Raw JSON: https://rust.help/data/specs/scpp.json Rust `no_std` safety on ARM64 and x86-64 plus direct-to-hardware `[[enzo::kernel]]` GPU/accelerator codegen (`NVIDIA SASS`, `Apple9` AGX, `AMD CDNA`, `Gaudi`) inside valid ISO C++23. > **Read First: Strict C++ Subset, Not a Full C++ Compiler** > **Why?** We built `sc++` so you can keep using your favorite C++ syntax and tools while getting all the safety and performance benefits of Rust and ENZO GPGPU today. > **Limitation:** Candidly, we are **NOT** a full C++ compiler. `sc++` is a strict safe subset of ISO C++23. We do **NOT** support, and will **NOT** support, the full C++ language specification. > **If you want safe and extremely fast code, continue reading.** ### Why Developers Use sc++ - **Direct-to-GPU & CPU SIMD:** `[[enzo::kernel]]` compiles C++ `for` loops straight to `NVIDIA SASS`, Apple Native GPU, `AMD CDNA`, and CPU `SVE` / `AVX-512`. - **Real immutable borrows:** `const T&` cannot be mutated or reallocated behind your back (`vec.push(vec[0])` fails). - **Dead-on-move values:** `sc::move(x)` kills `x` at compile time, ending C++ moved-from zombie bugs. - **Zero header & template rot:** Uses C++20 `module` imports and checked `concept` generics with zero `#include` soup. ```cpp export module compute.demo; import sc.core; [[enzo::kernel(fp(reproducible))]] export auto saxpy( sc::Slice& y, [[enzo::readonly]] const sc::Slice& x, f32 alpha ) -> void { [[enzo::parallel(lanes(vla))]] for (usize i = 0; i < y.len(); ++i) { y[i] = alpha * x[i] + y[i]; } } export auto append_head(sc::Vec xs) -> sc::Vec { const auto first = xs[0]; // Copy scalar first; `xs.push(xs[0])` is rejected! xs.push(first); return sc::move(xs); // True move: touching `xs` below fails to compile. } ``` Valid ISO C++23 compiled straight to native CPU, Apple Native GPU, and NVIDIA SASS, while still passing `clang++ -std=c++23`. ### Performance - **No bytecode or GPU middleware:** Emits raw hardware instructions directly with stronger `noalias` proofs than C++. - **Zero-alloc `co_await`:** Packs async call chains into one flat state-machine struct instead of per-frame heap allocations. - **Zero hidden atomic copies:** `sc::Arc` moves as a plain pointer; atomic increments only happen on explicit `.clone()`. - **Zero exception tables:** `sc::Result` and `sc::match` compile to flat jump tables with zero unwinding bloat. ```cpp auto sum_parallel(nagoya::Pool& pool) -> sc::Task { const auto total = sc::Arc>::make(0); auto worker = total.clone(); co_await nagoya::par_for(pool, 0u, 1000u, [out = sc::move(worker)](usize i) -> void { out.get().fetch_add(i, sc::Ordering::Relaxed); }); co_return total.get().load(sc::Ordering::Acquire); } ``` Allocates `[strong, weak, Atomic]` in one block and checks lambda thread safety at compile time. ### Security & Code Safety - **Explicit `this` receivers:** Every method states `this const S&`, `this S&`, or consuming `this S`. - **Automatic lifetime checks:** Infers returned reference lifetimes across functions with zero custom syntax. - **Must-consume `[[enzo::linear]]`:** Prevents forgotten handles from dropping silently at `}`. - **Constant-time crypto:** `[[enzo::constant_time]]` bans secret branches/indexing and scrubs stack spills. ```cpp export struct Packet { u32 id; sc::Vec payload; auto first_byte(this const Packet& self) -> sc::Option { if (self.payload.is_empty()) { return sc::None; } return sc::Some(self.payload[0]); } auto push_byte(this Packet& self, u8 b) -> void { self.payload.push(b); } }; [[enzo::constant_time]] auto ct_select([[enzo::secret]] u8 bit, [[enzo::secret]] u64 a, [[enzo::secret]] u64 b) -> u64 { const auto mask = static_cast(0u) - static_cast(bit); return (a & mask) | (b & ~mask); } ``` Raw MMIO pointers and C FFI are quarantined inside explicit `[[sc::unsafe]]` blocks. ### Concurrency, Wait-Free SPSC & Reactive State - **No `shared_ptr` data races:** `sc::Arc` yields `const T&` only, requiring `Mutex` or `Atomic` to mutate. - **Compile-time SPSC proof:** Splits into non-copyable `(Producer, Consumer)` handles so two threads can never race `.write()`. - **Glitch-free `Signal`:** 8-byte generational handles inside one `ReactiveGraph` replace leaky observer callbacks. ```cpp auto stream_orders(nagoya::Pool& pool) -> sc::Consumer { auto [tx, rx] = sc::spsc::channel(); pool.submit([tx = sc::move(tx)]() mutable -> void { if (auto grant = tx.grant_one(); grant.is_some()) { auto slot = sc::move(grant).unwrap(); slot.write(Order{ .id = 7, .qty = 500 }); sc::move(slot).commit(); } }); return sc::move(rx); } ``` ### What sc++ Isn't - **Not a compiler for legacy C++98/17 spaghetti:** `#include` headers, `#define` macros, raw `T*` declarators, and C casts are rejected. - **Not OOP or exception-based:** Class inheritance, virtual diamond hierarchies, `try`/`catch` exceptions, and `RTTI` do not exist. - **Not overload / ADL soup:** Function overloading, default arguments, implicit integer widening, and SFINAE templates are banned. - **Not a custom C++ fork:** Every valid `sc++` file stays 100% legal ISO C++23 for `clang++` tooling and FFI checks. --- ## Ro (ZERO-GC GO 1.22) - Web URL: https://rust.help/ro - Raw JSON: https://rust.help/data/specs/ro.json Write clean Go 1.22 syntax and compile straight to zero-GC `no_std` ARM64/x86-64 code and direct-to-hardware `//enzo:` accelerators (`NVIDIA SASS`, Apple Native GPU, `AMD CDNA`, `Gaudi`). > **Read First: Strict Go Subset, Not a Full Go Compiler** > **Why?** We built `Ro` so you can keep using your favorite Go syntax and tools (`gofmt`, `gopls`, `go test`) while getting all the zero-GC safety and performance benefits of Rust and ENZO GPGPU today. > **Limitation:** Candidly, we are **NOT** a full Go compiler. `Ro` is a strict safe subset of Go 1.22. We do **NOT** support, and will **NOT** support, the full Go language specification or GC runtime. > **If you want safe and extremely fast code, continue reading.** ### Why Developers Use Ro - **Direct-to-GPU & SIMD in Go:** `//enzo:kernel` compiles Go `for` loops straight to `NVIDIA SASS`, Apple Native GPU, `AMD CDNA`, and CPU `SVE` / `AVX-512`. - **Zero garbage collector:** `&x` creates a stack borrow instead of escaping onto a GC heap. - **No `append` slice corruption:** Separate `ro.Vec[T]`, `ro.Slice[T]`, and `ro.MutSlice[T]` prevent shared-capacity overwrites. - **Standard Go tooling:** `gofmt`, `gopls`, and `go test` still run untouched on every `.go` file. ```go package compute import "ro" //enzo:kernel fp(reproducible) func Saxpy(y ro.MutSlice[float32], /*enzo:readonly*/ x ro.Slice[float32], alpha float32) { //enzo:parallel lanes(vla) for i := uintptr(0); i < y.Len(); i++ { y.Set(i, alpha*x.Index(i)+y.Index(i)) } } func AppendHead(xs ro.Vec[float32]) ro.Vec[float32] { first := xs.Index(0) xs.Push(first) return xs // True move with zero GC write barriers. } ``` Stock `go build` treats `//enzo:` as a standard pragma comment; Ro compiles straight to bare-metal CPU, Apple Native GPU, and NVIDIA SASS. ### Performance - **Zero Go runtime or GPU middleware:** No garbage collector, write barriers, bytecode, or 2 MB runtime scheduler. - **Unboxed `//ro:enum` unions:** Sealed Go interfaces unbox onto the stack with flat jump-table `type switch` dispatch. - **Zero-overhead C FFI:** Calls C functions at native ABI speed inside `ro.Unsafe` without Go's slow `cgo` trampoline. - **Deterministic cleanup:** Heap allocations (`ro.Vec`, `ro.Box`) free immediately at `}` block exit. ```go func Dispatch(pkt Packet) ro.Result[ro.Vec[uint8], uint32] { head := FirstByte(ro.Borrow(&pkt)) var tag uint8 = 0 switch v := head.(type) { case ro.Some[ro.Ref[uint8]]: tag = v.Val.CopyVal() case ro.None[ro.Ref[uint8]]: tag = 0 } (&pkt).Payload.Push(tag) // Valid: `head` borrow ended above. return ro.Ok[ro.Vec[uint8], uint32]{Val: pkt.Payload} } ``` `Option` and `Result` occupy stack registers with zero interface heap boxing. ### Security & Code Safety - **`nil` pointers banned:** `ro.Ref[T]` and `*T` are guaranteed non-null borrows; optionality uses `ro.Option[T]`. - **No zero-value struct bugs:** Omitting struct fields in a literal is a compile error instead of silent zeroing. - **No GC secret copies:** Secrets never get copied across heap pages by a moving garbage collector. - **Linear & constant-time checks:** `//enzo:linear` enforces explicit teardown and `//enzo:constant_time` stops timing leaks. ```go //enzo:linear type KeySlot struct { Id uint64 } //enzo:consumes func ZeroizeAndClose(slot KeySlot) uint64 { return slot.Id } //enzo:constant_time func CtSelect(/*enzo:secret*/ bit uint8, /*enzo:secret*/ a uint64, /*enzo:secret*/ b uint64) uint64 { mask := uint64(0) - uint64(bit) return (a & mask) | (b & ^mask) } ``` Letting `KeySlot` go out of scope or branching on `bit` inside `CtSelect` fails compilation. ### Concurrency & Wait-Free SPSC - **No `go func()` data races:** Closures passed to `nagoya` worker pools are checked for thread safety at compile time. - **No `chan T` mutex bottleneck:** Go's `chan T` locks `runtime.hchan` on every send; Ro's `spsc.Channel` is lock-free. - **Single-writer proof:** `spsc.Producer` cannot be copied across workers, enabling zero-copy `GrantOne()` writes. ```go func StreamOrders(pool *nagoya.Pool) spsc.Consumer[Order] { pair := spsc.Channel[Order, 1024]() tx := pair.Tx rx := pair.Rx nagoya.Submit(pool, func() { switch g := tx.GrantOne().(type) { case ro.Some[spsc.GrantMut[Order]]: slot := g.Val slot.Write(Order{Id: 7, Qty: 500}) slot.Commit() case ro.None[spsc.GrantMut[Order]]: } }) return rx } ``` ### What Ro Isn't - **Not a compiler for GC-heavy Go standard libraries:** `net/http`, reflection, and runtime-dependent packages are excluded. - **No goroutines, `chan`, or `defer`:** `go`, `chan`, function-scoped `defer`, and `panic`/`recover` are banned outright. - **No built-in `[]T`, `append`, `map`, or `nil`:** Replaced by borrow-checked `ro.Vec[T]`, `ro.Slice[T]`, and `ro.Option[T]`. - **No dynamic interface boxing:** Unannotated Go `interface` types act strictly as compile-time generic trait bounds. --- ## Rython (NATIVE NO_STD PYTHON 3.12) - Web URL: https://rust.help/rython - Raw JSON: https://rust.help/data/specs/rython.json Write strict Python 3.12 and compile straight to zero-GC, zero-GIL ARM64/x86-64 code and direct-to-hardware `@enzo.kernel` accelerators (`NVIDIA SASS`, Apple Native GPU, `AMD CDNA`, `Gaudi`). > **Read First: Strict Python Subset, Not a Full Python Compiler** > **Why?** We built `Rython` so you can keep using your favorite Python syntax and tools (`python3`, `pytest`, `ruff`) while getting all the zero-GIL safety and performance benefits of Rust and ENZO GPGPU today. > **Limitation:** Candidly, we are **NOT** a full Python compiler. `Rython` is a strict statically typed subset of Python 3.12. We do **NOT** support, and will **NOT** support, the full dynamic Python language specification. > **If you want safe and extremely fast code, continue reading.** ### Why Developers Use Rython - **Direct-to-GPU & SIMD in Python:** `@enzo.kernel` compiles Python `for` loops straight to `NVIDIA SASS`, Apple Native GPU, `AMD CDNA`, and CPU `SVE` / `AVX-512`. - **Zero `PyObject*` boxing:** Fixed-width numbers and `@struct` classes live unboxed in registers and on the stack. - **Zero GIL & zero GC:** Multi-core threads run at full native speed with deterministic cleanup at `DEDENT`. - **Runs in stock `python3`:** Prototype and run `pytest` in CPython, then compile the exact same `.py` file directly to hardware. ```python import enzo from rython_core import f32, u32, Slice, Vec, Ref, Mut, struct @enzo.kernel(fp="reproducible") def saxpy(y: Mut[Slice[f32]], x: enzo.ReadOnly[Ref[Slice[f32]]], alpha: f32) -> None: for i in enzo.parallel(range(0, y.len()), lanes="vla"): y[i] = alpha * x[i] + y[i] @struct class SensorFrame: seq: u32 samples: Vec[f32] ``` Valid Python 3.12 that executes in `python3` and compiles straight to native CPU, Apple Native GPU, and NVIDIA SASS. ### Performance - **No interpreter, bytecode, or GPU middleware:** Zero `libpython`, zero refcounting, and direct hardware code emission. - **Inline stack structs:** `@struct` classes pack fields contiguously with zero `__dict__` hash tables or object headers. - **Zero-alloc `async def`:** Flattens `async`/`await` chains into one state-machine struct across all CPU cores. - **Fast jump-table `match`:** Python 3.12 `match` / `case` compiles directly to flat integer jump tables. | Tool | Runtime & Memory | Limitation Rython Solves | | --- | --- | --- | | CPython 3.12 | Boxed `PyObject*` + GC + GIL | 10x-100x boxing overhead and shared mutable aliasing. | | `Cython` / `mypyc` | `libpython` C-API refcounting | Still requires the Python runtime and `PyObject*` headers. | | `Codon` | Stop-the-world GC (LLVM) | Mandatory garbage collector; zero borrow or thread-safety proofs. | | `Mojo` | Custom `fn` / `var` / `inout` | Breaks Python syntax (`python3` cannot run it). | | `Rython` | Unboxed stack + Direct GPU/CPU | 100% valid Python 3.12, zero GC, Rust safety + Apple GPU / NVIDIA SASS. | ### Security & Code Safety - **No silent aliasing bugs:** `b = a` moves ownership (`a` is dead); `ref(x)` and `mut(x)` make borrows explicit. - **True block scoping:** Typed variables inside `if` or `for` blocks drop at `DEDENT` instead of leaking until `return`. - **Must-consume `@enzo.linear`:** Guarantees capability receipts and hardware leases cannot drop unhandled. - **Constant-time crypto:** `@enzo.constant_time` replaces variable-time Python `int` leaks with verified fixed-width ops. ```python def dispatch(pkt: MutVal[Packet]) -> Result[Vec[u8], u32]: head: Option[Ref[u8]] = ref(pkt).first_byte() tag: MutVal[u8] = 0 match head: case Some(b): tag = b.deref() case NoneVal(): tag = 0 mut(pkt).push_byte(tag) # Safe: `head` borrow ended above. return Ok(pkt.into_payload()) @enzo.constant_time def ct_select(bit: enzo.Secret[u8], a: enzo.Secret[u64], b: enzo.Secret[u64]) -> u64: mask: u64 = u64(0) - u64(bit) return (a & mask) | (b & ~mask) ``` Mutating `pkt` while `head` is live or reading `pkt` after `into_payload()` fails at compile time. ### Multi-Core Async & Wait-Free SPSC - **True multi-core `nagoya` pools:** Run work-stealing parallel loops across every core with zero `pickle` overhead. - **Move-only `Arc[T]`:** Shared cross-thread state requires `Mutex` or `Atomic` and clones explicitly. - **Lock-free `spsc.channel`:** Replaces mutex-locked `queue.Queue` with zero-copy `(Producer, Consumer)` ring grants. ```python async def sum_parallel(pool: Mut[nagoya.Pool]) -> usize: total: Arc[AtomicUsize] = Arc.make(AtomicUsize.new(0)) worker: Arc[AtomicUsize] = total.clone() def add_item(i: usize) -> None: worker.get().fetch_add(i, Ordering.Relaxed) await nagoya.par_for(pool, 0, 1000, add_item) return total.get().load(Ordering.Acquire) ``` ### What Rython Isn't - **Not a dynamic Python compiler:** Untyped functions, bare `int`/`list`/`dict`, `eval`, and `getattr` are rejected. - **No exceptions:** `try`, `except`, `finally`, and `raise` are banned in favor of `Result[T, E]` and `Option[T]`. - **No class inheritance or monkey-patching:** `@struct` data and `Protocol` traits replace OOP hierarchies and `__dict__`. - **No `*args`, `**kwargs`, or `@overload`:** Every function has one fixed, statically typed signature. --- ## Rortran (SAFE FORTRAN 2018) - Web URL: https://rust.help/rortran - Raw JSON: https://rust.help/data/specs/rortran.json Free-form Fortran 2018 with compile-time `intent` alias proofs on ARM64/x86-64 and direct-to-hardware `!$enzo` accelerators (`NVIDIA SASS`, Apple Native GPU, `AMD CDNA`, `Gaudi`). > **Read First: Strict Fortran Subset, Not a Full Fortran Compiler** > **Why?** We built `Rortran` so you can keep using your favorite Fortran syntax and tools (`gfortran`, `flang`) while getting all the safety and performance benefits of Rust and ENZO GPGPU today. > **Limitation:** Candidly, we are **NOT** a full Fortran compiler. `Rortran` is a strict safe subset of free-form Fortran 2018. We do **NOT** support, and will **NOT** support, the full Fortran language specification or legacy F77 features. > **If you want safe and extremely fast code, continue reading.** ### Why Developers Use Rortran - **Direct-to-GPU & SIMD:** `!$enzo` compiles `do` loops straight to `NVIDIA SASS`, Apple Native GPU, `AMD CDNA`, and CPU `SVE` / `AVX-512`. - **Aliasing proved, never guessed:** `call saxpy(x, x, a)` is rejected at compile time instead of silently corrupting math. - **Implicit `SAVE` trap killed:** Local variables never secretly turn into thread-unsafe static memory. - **100% `gfortran` compatible:** `!$enzo` is a standard `!` comment, so legacy compilers and BLAS checks keep working. ```fortran module compute_kernels use, intrinsic :: iso_fortran_env, only: int64, real32 implicit none (type, external) contains !$enzo kernel(fp(reproducible)) pure subroutine saxpy(y, x, alpha) real(real32), contiguous, intent(inout) :: y(:) !$enzo readonly :: x real(real32), contiguous, intent(in) :: x(:) real(real32), value :: alpha integer(int64) :: i ! Passing overlapping arrays `call saxpy(buf, buf, 2.0)` fails to compile! !$enzo parallel(lanes(vla)) do i = 1, size(y, kind=int64) y(i) = alpha * x(i) + y(i) end do end subroutine saxpy end module compute_kernels ``` Compiles untouched with `gfortran -std=f2018` while Rortran proves non-aliasing and emits Apple Native GPU, NVIDIA SASS, and SIMD code. ### Performance - **Direct hardware instructions:** Emits raw Apple Native GPU, NVIDIA SASS, and CPU vector code with zero PTX or middleware. - **True column-major slices:** Preserves 1-based `a(i, j)` extents directly for stride-1 loop interchange and tiling. - **Zero copy-in/copy-out traps:** Mandatory `contiguous` array slices eliminate silent megabyte heap temporaries. - **No accidental deep copies:** Whole-array `b = a` reallocation is banned; ownership moves in O(1) via `move_alloc`. ```fortran pure subroutine step_1d(out_cells, in_cells, scale) real(real64), contiguous, intent(out) :: out_cells(:) real(real64), contiguous, intent(in) :: in_cells(:) real(real64), value :: scale integer(int64) :: i, n n = size(in_cells, kind=int64) out_cells(1) = in_cells(1) do i = 2, n - 1 out_cells(i) = scale * (in_cells(i - 1) + in_cells(i + 1)) end do out_cells(n) = in_cells(n) end subroutine step_1d ``` `intent(out)` proves `out_cells` is disjoint from `in_cells` and fully initialized before return. ### Security & Code Safety - **Dead-on-move `move_alloc`:** Reading or querying `a` after `call move_alloc(a, b)` is a compile error. - **Checked `Result` errors:** Replaces ignored `stat=ierr` integers with exhaustive `select case` error handling. - **Linear device leases:** `!$enzo linear` prevents forgotten GPU staging buffers from leaking on early return. - **Constant-time routines:** `!$enzo constant_time` rejects secret-dependent branches and array subscripts. ```fortran !$enzo linear type :: DeviceLease integer(int64) :: slot_id end type DeviceLease !$enzo consumes subroutine release_lease(lease) type(DeviceLease), value :: lease end subroutine release_lease !$enzo constant_time pure function ct_select(bit, a, b) result(chosen) !$enzo secret :: bit, a, b integer(int64), value :: bit, a, b integer(int64) :: chosen, mask mask = -bit chosen = ior(iand(a, mask), iand(b, not(mask))) end function ct_select ``` ### Race-Free Parallel Loops & SPSC Pipelines - **No OpenMP `private` typos:** `do concurrent` and work-stealing tasks verify disjoint borrows at compile time. - **Wait-free solver pipelines:** Connect PDE and I/O stages over non-copyable `(Producer, Consumer)` SPSC ring slices. - **Zero mutable globals:** Generational `Signal` tables replace racy `module` and `common` simulation flags. ```fortran subroutine stream_tile(tx, grid) type(TileProducer), intent(inout) :: tx real(real64), contiguous, intent(in) :: grid(:) type(TileGrant) :: slot logical :: ok call tx%grant_one(slot, ok) if (ok) then slot%buf(:) = grid(:) call slot%commit() end if end subroutine stream_tile ``` ### What Rortran Isn't - **Not a Fortran 77 dustbin:** Fixed-form punchcard columns, `COMMON`, `EQUIVALENCE`, `ENTRY`, `GOTO`, and implicit `I..N` typing are banned. - **No `pointer` / `target` aliasing web:** Raw Fortran `pointer` and `target` attributes are banned in safe code. - **No reshaped F77 rank-punning:** Assumed-size `a(*)` dummies and passing `real a(100,100)` to `real a(10000)` are rejected. - **No blind OpenMP / OpenACC:** Unchecked `!$omp` shared writes are replaced by borrow-checked `!$enzo` parallelism. --- ## Direct JSON Endpoints for no_std Guides & Tutorials - Fetch any `no_std` Rust guide JSON at `https://rust.help/data/guides/.json` (full slug list in `https://rust.help/data/guides-index.json` and `https://rust.help/llms.txt`). - Fetch any visual Rust tutorial JSON at `https://rust.help/data/tutorials/.json` (full ID list in `https://rust.help/data/tutorials-index.json` and `https://rust.help/llms.txt`).