Skip to content

Commit

Permalink
[SymForce] build symforce_gen with -ffast-math
Browse files Browse the repository at this point in the history
This 1) should be safe and 2) should speed things up, e.g. for things
that rely on Horner's method.  Included an option to turn this off,
although I have it on by default, which I think is a good idea.

Relying on existing tests?  Not sure how confident we are flipping this.
Mostly uploading to run tests for now.

One thing is that this requires we're more careful about repeatedly
normalizing Rot3's, since it seems like that's no longer necessarily
idempotent (and I guess it was before).  That's a performance win anyway
though.

Topic: sym-fast-math
GitOrigin-RevId: 13bcdea25f335d0a6c5527b8b86f61181e4a367d
  • Loading branch information
aaron-skydio committed Feb 21, 2024
1 parent 1441f88 commit 7c7bbde
Show file tree
Hide file tree
Showing 47 changed files with 267 additions and 102 deletions.
18 changes: 13 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,23 @@ option(SYMFORCE_SKYMARSHAL_PRINTING
)

# ------------------------------------------------------------------------------
# Misc
# Build Customization

option(SYMFORCE_BUILD_STATIC_LIBRARIES "Build libraries as static" OFF)

set(SYMFORCE_COMPILE_OPTIONS -Wall;-Wextra CACHE STRING
"Extra flags to pass to the compiler; defaults to enabling warnings"
)

option(SYMFORCE_NO_FAST_MATH "Don't automatically add -ffast-math to some targets" OFF)

set(SYMFORCE_EIGEN_TARGET "Eigen3::Eigen" CACHE STRING
"Target to depend on for Eigen. Default is to find Eigen with find_package."
)

# ------------------------------------------------------------------------------
# Misc

set(SYMFORCE_PYTHON_OVERRIDE "" CACHE STRING
"Python executable to use - if empty (the default), find python in the environment"
)
Expand All @@ -98,10 +107,6 @@ set(SYMFORCE_PY_EXTENSION_MODULE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/pybind
"Location to place generated python extension modules"
)

set(SYMFORCE_EIGEN_TARGET "Eigen3::Eigen" CACHE STRING
"Target to depend on for Eigen. Default is to find Eigen with find_package."
)

# ==============================================================================
# Setup
# ==============================================================================
Expand Down Expand Up @@ -281,6 +286,9 @@ add_library(
${SYMFORCE_GEN_HEADERS}
)
target_compile_options(symforce_gen PRIVATE ${SYMFORCE_COMPILE_OPTIONS})
if(NOT SYMFORCE_NO_FAST_MATH)
target_compile_options(symforce_gen PRIVATE -ffast-math)
endif()
target_link_libraries(symforce_gen ${SYMFORCE_EIGEN_TARGET} symforce_lcmtypes_cpp)
target_include_directories(
symforce_gen
Expand Down
12 changes: 10 additions & 2 deletions gen/cpp/sym/atan_camera_cal.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions gen/cpp/sym/double_sphere_camera_cal.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions gen/cpp/sym/equirectangular_camera_cal.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions gen/cpp/sym/linear_camera_cal.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/cpp/sym/ops/atan_camera_cal/group_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/cpp/sym/ops/double_sphere_camera_cal/group_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/cpp/sym/ops/equirectangular_camera_cal/group_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/cpp/sym/ops/linear_camera_cal/group_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/cpp/sym/ops/polynomial_camera_cal/group_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/cpp/sym/ops/pose2/group_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/cpp/sym/ops/pose3/group_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/cpp/sym/ops/rot2/group_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion gen/cpp/sym/ops/rot2/storage_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/cpp/sym/ops/rot3/group_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion gen/cpp/sym/ops/rot3/storage_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/cpp/sym/ops/spherical_camera_cal/group_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/cpp/sym/ops/unit3/group_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion gen/cpp/sym/ops/unit3/storage_ops.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions gen/cpp/sym/polynomial_camera_cal.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions gen/cpp/sym/pose2.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions gen/cpp/sym/pose2.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions gen/cpp/sym/pose3.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions gen/cpp/sym/pose3.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7c7bbde

Please sign in to comment.