ta-lib-dispatch 0.1.2

Runtime CPU-feature dispatch macro for the ta-lib crate (internal support crate).
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 6.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 26.5 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • TA-Lib/ta-lib
    1738 301 13
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mario4tier github:ta-lib:rust-crate-io-owners

ta-lib-dispatch

crates.io docs.rs

Runtime CPU-feature dispatch for fused multiply-add (FMA), used internally by the ta-lib crate — part of the TA-Lib project.

Why this exists

Fused multiply-add (FMA) computes a * b + c in one rounding step instead of two, and has been a hardware x86-64 instruction since 2013 (Haswell). A published crate has to run on any x86-64 CPU, though, so it can't require that instruction at compile time — the safe fallback is a software fma() call through libm, which costs up to ~7x in execution speed on FMA-heavy code.

This crate is one macro: check is_x86_feature_detected!("fma") once, then call whichever of two compiled clones — one built with #[target_feature(enable = "fma")], one without — matches the CPU. Both produce identical, correctly-rounded results; only speed changes.

Not a novel trick

Runtime CPU-feature dispatch for numerical code is standard practice — NumPy and OpenBLAS both select their FMA/SIMD kernels the same way, at runtime, based on detected CPU features.

Do you need this crate directly?

Almost certainly not. ta-lib already depends on an exact-pinned version of this crate — the macro is an internal contract between the two, not a public API.

License

BSD-3-Clause — see LICENSE.