Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix benchmarks failing and adjust compilation flags #118

Merged
merged 5 commits into from
Mar 5, 2025

Conversation

miclegr
Copy link
Contributor

@miclegr miclegr commented Mar 3, 2025

Description

Three contributions in this PR:

  • Now that we have moved to nanobind and do not depend to numpy anymore, we need to install numpy when running the benchmarks.
  • when building python package compile native code using -O3 and some math optimization
  • Enable same math optimization in the native code build for the java package

@miclegr miclegr changed the title Fix benchmarks failing Fix benchmarks failing and adjust compilation flags Mar 4, 2025
Copy link
Member

@psobot psobot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you @miclegr! Just one note (really a TODO) about applying these same optimizations on Windows, although only ~4% of our daily installs are on Windows so we may be able to do that separately.

Comment on lines 53 to 62
# Allow for some math optimization on unix but not -ffast-math
# See: https://simonbyrne.github.io/notes/fastmath/#flushing_subnormals_to_zero
if (IS_UNIX)
add_compile_options(-fassociative-math -fno-signaling-nans -fno-trapping-math -fno-signed-zeros -freciprocal-math -fno-math-errno)
endif()

# Relase build on unix with all optimizations
if (CMAKE_BUILD_TYPE STREQUAL "Release" AND IS_UNIX)
add_compile_options(-O3)
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A TODO for later - we should probably specify /Ox here when building for MSVC/Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's trivial to add, I added it to this PR :)

@miclegr miclegr merged commit b8a6f7e into spotify:main Mar 5, 2025
62 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