|
| 1 | +<!-- |
| 2 | +SPDX-License-Identifier: CC-BY-SA-4.0 |
| 3 | +SPDX-FileCopyrightText: 2025-2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk> |
| 4 | +--> |
| 5 | + |
| 6 | +# What Is This? |
| 7 | + |
| 8 | +Futharkiser identifies array-parallel patterns in your code, extracts |
| 9 | +them, generates [Futhark](https://futhark-lang.org) programs, and |
| 10 | +compiles those programs to **GPU kernels** (OpenCL, CUDA, or multicore |
| 11 | +CPU) — all without requiring the user to know anything about GPU |
| 12 | +programming. |
| 13 | + |
| 14 | +[Futhark](https://futhark-lang.org) (by Troels Henriksen et al., DIKU |
| 15 | +Copenhagen) is a purely functional array language that compiles to |
| 16 | +highly optimised GPU code. It guarantees no data races and achieves |
| 17 | +near-hand-tuned performance on parallel array operations. Almost nobody |
| 18 | +knows it exists. Futharkiser democratises GPU computing by putting |
| 19 | +Futhark behind a simple manifest. |
| 20 | + |
| 21 | +# How It Works |
| 22 | + |
| 23 | +Annotate array operations in your code with `#[futharkise]` (or describe |
| 24 | +them in `futharkiser.toml`). Futharkiser then: |
| 25 | + |
| 26 | +1. **Analyses** your source code for parallelisable array patterns |
| 27 | + |
| 28 | +2. **Extracts** operations that map to Futhark’s second-order array |
| 29 | + combinators (SOACs): `map`, `reduce`, `scan`, `scatter`, |
| 30 | + `flatten`/`unflatten` |
| 31 | + |
| 32 | +3. **Proves** parallelism safety via the Idris2 ABI layer (no data |
| 33 | + races, correct memory layouts, valid GPU buffer descriptors) |
| 34 | + |
| 35 | +4. **Generates** Futhark programs with optimal data layouts and memory |
| 36 | + transfers |
| 37 | + |
| 38 | +5. **Compiles** via `futhark` `opencl`, `futhark` `cuda`, `futhark` |
| 39 | + `multicore`, or `futhark` `c` (sequential, for debugging) |
| 40 | + |
| 41 | +6. **Creates** a Zig FFI bridge so the compiled GPU kernels are |
| 42 | + callable from your application with zero ceremony |
| 43 | + |
| 44 | +# Key Value |
| 45 | + |
| 46 | +- **GPU computing for everyone** — no CUDA/OpenCL expertise needed |
| 47 | + |
| 48 | +- **10-1000x speedups** on array-heavy workloads, with Futhark’s |
| 49 | + compiler performing fusion, tiling, and memory coalescing |
| 50 | + automatically |
| 51 | + |
| 52 | +- **Automatic memory management** across the CPU/GPU boundary |
| 53 | + (host/device/shared memory spaces are tracked by the ABI layer) |
| 54 | + |
| 55 | +- **Safety guarantees** — Futhark is purely functional with no data |
| 56 | + races; Idris2 proofs verify the interface contracts at compile time |
| 57 | + |
| 58 | +- **Multiple GPU backends** — OpenCL (widest hardware support), CUDA |
| 59 | + (NVIDIA), multicore CPU (no GPU required), sequential C (debugging) |
| 60 | + |
| 61 | +# Use Cases |
| 62 | + |
| 63 | +- **Scientific computing** — matrix operations, PDE solvers, linear |
| 64 | + algebra |
| 65 | + |
| 66 | +- **Image processing** — convolutions, filters, histograms on pixel |
| 67 | + arrays |
| 68 | + |
| 69 | +- **Monte Carlo simulation** — massively parallel random sampling |
| 70 | + |
| 71 | +- **Neural network primitives** — custom forward/backward passes on |
| 72 | + tensors |
| 73 | + |
| 74 | +- **Financial modelling** — option pricing, risk calculations over large |
| 75 | + portfolios |
| 76 | + |
| 77 | +- **Signal processing** — FFT, spectral analysis on array data |
| 78 | + |
| 79 | +# Architecture |
| 80 | + |
| 81 | +Follows the hyperpolymath -iser pattern: |
| 82 | + |
| 83 | + futharkiser.toml User describes WHAT they want |
| 84 | + | |
| 85 | + v |
| 86 | + Source Analysis Identifies map/reduce/scan/scatter patterns |
| 87 | + | |
| 88 | + v |
| 89 | + Idris2 ABI Layer Proves parallelism safety, validates GPU buffer layouts |
| 90 | + (src/interface/abi/) Types: SOAC, GPUBackend, ArrayShape, ParallelPattern, MemorySpace |
| 91 | + | |
| 92 | + v |
| 93 | + Futhark Codegen Generates .fut programs with SOACs |
| 94 | + (src/codegen/) |
| 95 | + | |
| 96 | + v |
| 97 | + GPU Compilation futhark opencl | futhark cuda | futhark multicore | futhark c |
| 98 | + | |
| 99 | + v |
| 100 | + Zig FFI Bridge C-ABI callable GPU kernels |
| 101 | + (src/interface/ffi/) |
| 102 | + | |
| 103 | + v |
| 104 | + Your Application Calls GPU kernels as normal functions |
| 105 | + |
| 106 | +## Futhark SOACs (Second-Order Array Combinators) |
| 107 | + |
| 108 | +Futharkiser maps source patterns to these Futhark primitives: |
| 109 | + |
| 110 | +| SOAC | Description | Example pattern | |
| 111 | +|----|----|----| |
| 112 | +| `map` | Apply function to every element | `items.iter().map(|x|` `x` `*` `2)` | |
| 113 | +| `reduce` | Fold array with associative operator | `items.iter().sum()` | |
| 114 | +| `scan` | Inclusive prefix scan | Running totals, prefix sums | |
| 115 | +| `scatter` | Irregular write to array positions | Histogram binning, sparse updates | |
| 116 | +| `flatten`/`unflatten` | Reshape nested arrays | Matrix operations, batch processing | |
| 117 | + |
| 118 | +## GPU Backends |
| 119 | + |
| 120 | +| Backend | Use case | Flag | |
| 121 | +|----|----|----| |
| 122 | +| OpenCL | Widest hardware support (AMD, Intel, NVIDIA) | `--backend` `opencl` | |
| 123 | +| CUDA | NVIDIA GPUs (best NVIDIA performance) | `--backend` `cuda` | |
| 124 | +| Multicore CPU | No GPU available; still parallel | `--backend` `multicore` | |
| 125 | +| Sequential C | Debugging, correctness testing | `--backend` `c` | |
| 126 | + |
| 127 | +Part of the [-iser family](https://github.com/hyperpolymath/iseriser) of |
| 128 | +acceleration frameworks. |
| 129 | + |
| 130 | +# Status |
| 131 | + |
| 132 | +**Codebase in progress.** Architecture defined, CLI scaffolded, RSR |
| 133 | +template complete, Idris2 ABI types stubbed. Futhark codegen and GPU |
| 134 | +compilation pipeline are the next milestones. |
| 135 | + |
| 136 | +# Quick Start |
| 137 | + |
| 138 | +```bash |
| 139 | +# Initialise a manifest in your project |
| 140 | +futharkiser init |
| 141 | + |
| 142 | +# Edit futharkiser.toml to describe your array operations |
| 143 | +# Then generate, build, and run: |
| 144 | +futharkiser generate |
| 145 | +futharkiser build --backend opencl |
| 146 | +futharkiser run |
| 147 | +``` |
| 148 | + |
| 149 | +# Building from Source |
| 150 | + |
| 151 | +```bash |
| 152 | +cargo build --release |
| 153 | +``` |
| 154 | + |
| 155 | +# License |
| 156 | + |
| 157 | +SPDX-License-Identifier: CC-BY-SA-4.0 |
0 commit comments