[−][src]Crate newel
This crate provides a set of bulk homogeneous-slice-typed operations. It's to be used as a building block for collection-oriented evaluators that don't JIT, but still want good performance from a fixed repertoire of type-specialized inner loops. It provides three notable features:
-
Isolates in one compilation unit the code amplification factor of the cartesian product of all primitive operations across all primitive types, compiled into (where possible) efficient SIMD loops. They only get compiled once, here.
-
Abstracts away the question of runtime selection of the most efficient implementation (eg. rayon chunking & SIMD, possibly GPU in the future).
-
Provides "outer" column-vs-column or vs-constant dynamic double-dispatches that are expected to be amortized over the inner loops, as well as the dynamic dispatch from ops to functions. Nothing in this crate should wind up inlined much into its users, despite going very fast once inside!
This is the kind of building block used in eg. APL evaluators or column-oriented databases, where the outer layer is an interpreter and it maintains good-but-not-maximal performance by having all the inner layers go fast: the homogeneous-slice-typed operators here. For data intensive programs it's a simple strategy that seems to pay off well, since the outer interpreter loop is only returned to relatively infrequently, and the code footprint of these inner loops is compiled once into the interpreter, so constant across all user programs and relatively cache-friendly.
Structs
EvalCtx | Every top-level evaluation step in newel happens against an EvalCtx that holds 3 mutable buffers of some multiple of CHUNKSZ bytes. These buffers (and the EvalCtx itself) get used up during the operation. The first two buffers are for holding possible conversions of 1 or 2 inputs to the operation; the third buffer stores the output. |
Enums
BoolBinOpCode | |
BoolUnOpCode | |
Const | |
EvalError | |
Operand | Operands are the primary types of arguments passed to newel's evaluator and returned from it after operations complete. They are either single-element constants or homogeneous slices. |
ScalarTy | All |
Slice | |
ValBinOpCode | |
ValUnOpCode |
Constants
CHUNKBYTES | |
VECBYTES |