tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Codegen: unboxed-float workers (ADR 0045, issue #190)

A Float is a heap block: every arithmetic result allocated. A function
whose parameters and result are known Float (lowering records which in
FnDecl::float_sig — dictionaries and capabilities marked, generics and
non-Float results excluded) now gets a second emission next to its
wrapper: a worker f$uf taking the marked parameters and returning the
result as raw doubles, the body's float arithmetic raw. A boxed operand
is unboxed in place (the type checker guarantees it), a raw value
escaping into data or an unknown call is boxed at the boundary, and
self-recursion stays raw through the goto loop. Direct callers unbox the
arguments and box the result once per call; closures and unknown callers
keep the wrapper. The interpreter never sees a worker (boxed semantics),
so the differential tests compare bit-for-bit — they hold.

The analysis refuses, falling back to just the wrapper: cross-function
tail calls (musttail needs the uniform shape), early exit, reuse tokens
or switches on raw values, and non-finite literals (which take the boxed
literal). LOUISE_NO_FLOAT_UNBOX turns workers off.

No ABI bump: the workers are internal to generated code, and the
box/unbox helpers were already in the runtime header. ADR 0045's
Revision 1 records that and the rest of what the implementation found.

Measured (LOUISE_THREADS=1 instruction counts): floats -94.2%, the new
matmul kernel -34.4%, everything else +-0.00%; fsum's loop contains no
tl_alloc and no boxed float op. tests/bench/matmul.lse is the done-when's
float-heavy kernel (64x64 product over flat arrays).

olivier · il y a 1 mois · 00292e75be04606e24f4e2abd00b6486f47eef3e

Parents e0210f8

22 fichiers modifiés, 1077 ajouts, 31 suppressions

Mcrates/louise_codegen_c/src/emit/mod.rs+292−27
Acrates/louise_codegen_c/src/float.rs+421−0
Mcrates/louise_codegen_c/src/lib.rs+1−0
Mcrates/louise_codegen_c/src/ranges.rs+4−3
Acrates/louise_codegen_c/tests/float_workers.rs+182−0
Mcrates/louise_core/src/callgraph.rs+1−0
Mcrates/louise_core/src/evidence.rs+1−0
Mcrates/louise_core/src/lower/derive.rs+1−0
Mcrates/louise_core/src/lower/mod.rs+30−0
Mcrates/louise_core/src/opt/cpr.rs+1−0
Mcrates/louise_core/src/opt/fuse.rs+1−0
Mcrates/louise_core/src/opt/specialise.rs+1−0
Mcrates/louise_core/tests/lowering.rs+48−0
Mcrates/louise_perceus/tests/programs.rs+1−0