duplexsystem / fath

Fa(st ma)th library written in Rust, built for speed.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fath crates.io

Fa(st ma)th library written in Rust, built for speed.


This library heavily relies on unsafe and nightly features to achieve the best performance. The primary use case for this library is in games or graphics development, where speed matters more than precision

When using SIMD functions in this package, compile with LTO and opt-level=3 to ensure that auto-vectorization takes place. All SIMD functions have a feature cap at AVX2, and nothing in this library utilizes anything from AVX512. If certain functions vectorize on lower requirements, that's a bonus.

Most of the functions in here are faster than equivalent functions in sleef, at the expense of safety. (TODO: add comparison to sleef_rs)

Currently Implemented Functions

Approximate f32 Functions:

Allows setting a variable precision level as a const generic.

  • sin and cos
    • Does include wrapping with a range reduction, but will become less accurate as the input gets larger.
  • log (const base and variable base)
    • This is based on a log base 2 approximation, and is scaled for other bases. The fastest version of this is const base 2.0.

Exact Unsigned Integer Functions:

  • ilog with const base
    • Has multiple implementations depending on the base to achieve maximum performance. The fastest impl is for log base 2.
  • exp with const coefficient
    • Similar to previous function, but calculates COEFF^x instead.

Contributing

Any help on the library is greatly appreciated. If you'd like to contribute, just submit a PR and I'll respond to it as soon as I can. For development, I'd recommend looking at the genertated assembly often. For development of individual functions, I would recommend using a tool like Compiler Explorer, and using something like llvm-mca (available in CE under "tools") often to get an idea of performance on different platforms.

About

Fa(st ma)th library written in Rust, built for speed.

License:GNU Lesser General Public License v3.0


Languages

Language:Rust 100.0%