Repository navigation
brine 0.4.0
Added
par for,par [...]maps andparreductions run on the GPU when that's
faster: NVIDIA GPUs through CUDA (Windows and Linux) and Apple GPUs (M1 and later)
through Metal. Bodies that only compute qualify (arithmetic, comparisons,
branches, loops, reads of plain data and arrays, calls to such functions), and
nothing changes in the source. Results are bit-identical to the CPU's; a check
that fails on the device reruns the construct on the CPU, which panics as usual.
The GPU driver is loaded when the program runs, so there's nothing to install or
link.BRINE_GPU=off|on|autopicks the policy andBRINE_GPU_LOG=1prints where
each construct ran and why.- A native AArch64 backend for Linux: dev and debug builds on 64-bit ARM Linux go
straight to machine code, as on x86-64. - Native debug builds:
--debugon Windows and Linux carries DWARF line and
variable info, so gdb and lldb break atfile.br:lineor a brine function, step
through brine lines and show locals by their brine names and types. brine debugshows values the way brine prints them ("hello",[1, 2, 3],
Some(5)) when gdb has Python, and steps over the runtime.- Release builds on GitHub for Linux (x64, arm64), macOS (arm64, x64) and Windows
(x64), with checksums and build provenance, and one-line installers:
curl -fsSL https://raw.githubusercontent.com/brinelang/brine/main/install.sh | sh
andirm https://raw.githubusercontent.com/brinelang/brine/main/install.ps1 | iex. examples/find_signal.br: a GPS signal search whose indexing is proved safe and
whose search runs on the GPU.
Changed
- Breaking:
parreductions combine their elements in a fixed order: leaves of
16 consecutive elements, each folded left to right, then a balanced tree. The
result is the same for any thread count and on the GPU.par sumand
par productof floats can differ from 0.3.0 in the last bits (usually closer to
the exact result), and whether an integerpar sumorpar productoverflows is
decided by the new order. Programs that need the old bits must sum sequentially. - Faster native code: local variables and floats live in registers (dev builds of
nbody go from 7.96x C's time to 3.45x, spectral norm from 6.54x to 2.05x). - Loops that index a local array load it once and make it unique before the loop,
so C compilers vectorize them (matrix multiply: 8.7x C's time to 1.0x). - Faster strings:
s += tgrows a string in place ands[i]is inlined. - Faster allocation: small blocks come from brine's own allocator, and a value with
one reference is freed without an atomic instruction (binary-trees on Windows:
1.67x C's time to 0.67x). - Parallel regions start and end without a lock, so short regions no longer slow
down as threads are added. - Division and remainder by a constant power of two compile to a shift and a mask.
matchon aletvariable or a by-value parameter no longer retains and
releases each value it visits.
Fixed
- Programs failed to link on AArch64 Linux when clang was the C compiler (missing
__muloti4). - Float
minandmaxof-0.0and0.0gave different results on different
platforms;minnow treats-0.0as the smaller. - A panic's message could interleave with what other threads printed.
- The build cache could reuse an object built against an older runtime header,
which then failed to link. - A
BRINE_BACKENDbuild could replace a default build's executable while it ran. brine run --ranks Nlistened on every network interface, so Windows asked to
let each new build through the firewall; with every rank on this machine it
listens on loopback.
Install
Linux and macOS:
curl -fsSL https://raw.githubusercontent.com/brinelang/brine/main/install.sh | shWindows (PowerShell):
irm https://raw.githubusercontent.com/brinelang/brine/main/install.ps1 | iexbrine needs a C compiler (gcc or clang; MinGW on Windows): run brine doctor to check.
To install this version rather than the latest, set BRINE_VERSION=0.4.0 first. The
archives below are checked against SHA256SUMS by the installers, and each has a
build provenance attestation (gh attestation verify <file> -R brinelang/brine).
Full changelog: v0.3.0...v0.4.0