Skip to content

Conversation

@andrewkern
Copy link
Collaborator

New SIMD-accelerated functions

Trigonometric (via SLEEF):

  • sin(), cos(), tan()
  • asin(), acos(), atan(), atan2()

Power:

  • ^ operator (float arrays)
  • SpatialMap.power()

Performance improvements

Benchmarks on 1M elements show significant speedups:

Function Speedup
sin/cos 7x
tan 6x
asin 6x
acos 4.5x
atan 3x
atan2 4x
2.0^x 3x
x^y 1.3x

Implementation details

  • Added SLEEF wrapper functions in eidos_simd.h for all new operations
  • Updated sleef_config.h with macros for AVX2 and ARM NEON architectures
  • Added C++ unit tests for numerical correctness validation
  • Updated benchmark script to cover all SLEEF-accelerated functions

Files changed

  • eidos/sleef/sleef_config.h - SLEEF macro definitions
  • eidos/eidos_simd.h - SIMD wrapper functions
  • eidos/eidos_functions_math.cpp - Trig function implementations
  • eidos/eidos_interpreter.cpp - ^ operator implementation
  • core/spatial_map.cpp - SpatialMap.power() implementation
  • eidos/eidos_test_functions_math.cpp - C++ unit tests

Extend SLEEF coverage to include sin, cos, tan, asin, acos, atan, and
atan2 functions in Eidos. These functions now use SLEEF vectorization
when operating on float arrays, with scalar fallback for integer inputs.

Changes:
- sleef_config.h: Add SLEEF macros for trig functions (AVX2 + ARM NEON)
- eidos_simd.h: Add SIMD wrapper functions for all 7 trig functions
- eidos_functions_math.cpp: Update trig functions to use SIMD path
- eidos_test_functions_math.cpp: Add C++ level tests comparing SLEEF
  output against scalar std:: functions for numerical correctness

SLEEF functions now accelerated: exp, log, log10, log2, sin, cos, tan,
asin, acos, atan, atan2 (11 total, up from 4)
- Add EIDOS_SLEEF_POW_D macro for AVX2 and ARM NEON in sleef_config.h
- Add pow_float64(), pow_float64_scalar_exp(), and pow_float64_scalar_base()
  wrapper functions in eidos_simd.h
- Update Eidos ^ operator in eidos_interpreter.cpp to use SLEEF pow
- Update SpatialMap::power() in spatial_map.cpp to use SLEEF pow
- Add C++ unit tests for pow functions in eidos_test_functions_math.cpp
@andrewkern
Copy link
Collaborator Author

interesting... a few tests a failing. i'll investigate.

@andrewkern
Copy link
Collaborator Author

okay @bhaller this should be ready to merge

@bhaller
Copy link
Contributor

bhaller commented Dec 18, 2025

okay @bhaller this should be ready to merge

Beautiful work! I really like how you designed the tests. Thanks!

@bhaller bhaller merged commit ffa4ad0 into MesserLab:master Dec 18, 2025
17 checks passed
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.

2 participants