Skip to content

Add Goose - #509

Open
aardappel wants to merge 1 commit into
hanabi1224:mainfrom
aardappel:add-goose
Open

aardappel wants to merge 1 commit into
hanabi1224:mainfrom
aardappel:add-goose

Conversation

@aardappel

Copy link
Copy Markdown

Goose is a systems language that compiles to C: data lives
on bump-allocated data stacks freed by scope, arrays nest inline, and links can be 4-byte
relative references, with lifetimes and bounds checked statically where they can be and at run
time where they can't.

This adds Goose programs for every problem except http-server (Goose has no networking yet):
30 programs for 17 problems, a single-threaded one for each and a -m one where the fast
programs of other languages are multithreaded.

Build. goose -O2 --standalone -o app.c app.goose writes the program and the runtime as one C
file, which clang @app.rsp compiles with the C entries' flags (-O3 -fomit-frame-pointer -march=broadwell). Goose's simd fns, which otherwise also build AVX-512 versions and pick one at
run time, are capped at AVX2 (-DGS_SIMD=1) to match -march=broadwell. .github/goose.sh
installs a Goose release, as odin.sh does Odin's.

Notes on the programs

  • binarytrees builds each tree in a pool local to the function that builds it, freed when that
    function returns, as the C and C++ programs use memory pools. merkletrees forbids arenas, so
    there every node is allocated and freed on its own, from a pool with a freelist.
  • coro-prime-sieve: Goose has no coroutines, so it builds the chain the generator programs (C#,
    D, Python) build: a lazy filter stage per prime, each pulling values from the stage before it.
  • pidigits, edigits and secp256k1 carry their own big-integer code, since Goose has no bignum
    library; json-serde uses Goose's standard json module and carries its own MD5.
  • fasta uses the prescribed LCG as written; knucleotide/1 counts in its own hash table as C's
    1.c does, knucleotide/2 with the standard library's dictionary.
  • nbody/1 and spectral-norm/1 are the plain algorithms; nbody/2 and spectral-norm/2 lay the data
    out for vector registers (spectral-norm/2 sums four columns' fractions over one division, as
    C's 6-im does).

Testing. With the tool, --task build --langs goose builds all 30 programs and --task test
passes all 58 unit tests (Ubuntu 24.04, clang 18). The same programs also build and pass with
Ubuntu 22.04's clang 14, and with clang 20.

Goose (https://github.com/aardappel/goose) programs for every problem but http-server, built through the generated C with clang and PLB's C flags.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant