Skip to content

brine 0.4.0

Choose a tag to compare

@github-actions github-actions released this 27 Oct 22:27
· 572 commits to main since this release
107f07d

Added

  • par for, par [...] maps and par reductions 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|auto picks the policy and BRINE_GPU_LOG=1 prints 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: --debug on Windows and Linux carries DWARF line and
    variable info, so gdb and lldb break at file.br:line or a brine function, step
    through brine lines and show locals by their brine names and types.
  • brine debug shows 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
    and irm 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: par reductions 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 sum and
    par product of floats can differ from 0.3.0 in the last bits (usually closer to
    the exact result), and whether an integer par sum or par product overflows 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 += t grows a string in place and s[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.
  • match on a let variable 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 min and max of -0.0 and 0.0 gave different results on different
    platforms; min now treats -0.0 as 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_BACKEND build could replace a default build's executable while it ran.
  • brine run --ranks N listened 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 | sh

Windows (PowerShell):

irm https://raw.githubusercontent.com/brinelang/brine/main/install.ps1 | iex

brine 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