Skip to content
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
877fb4a
Add bignum.h and port exactfloat to use it.
smcallis Sep 24, 2025
383f43b
Rework Karatsuba and respond to PR comments.
smcallis Sep 24, 2025
71314f0
Address round 2 CR comments.
smcallis Sep 28, 2025
f374cb3
Address PR Round 3 comments.
smcallis Sep 29, 2025
54244eb
Fix Karatsuba for highly asymmetric operand sizes.
smcallis Sep 29, 2025
640f6b3
Remove assignment operator.
smcallis Sep 29, 2025
b2f72d3
PR round 4 fixes.
smcallis Sep 30, 2025
095e140
PR (Mega) round 5 changes.
smcallis Oct 3, 2025
ddc7b69
PR (Mega) Round 5 more changes.
smcallis Oct 3, 2025
29be9ff
PR Round 7 changes.
smcallis Oct 4, 2025
308698e
Cleanup util/math BUILD file and ensure clean compilation and run.
smcallis Oct 4, 2025
7e90c5c
Remove final usage of ssize_t.
smcallis Oct 4, 2025
81f846a
Add exactfloat_test to BUILD file.
smcallis Oct 4, 2025
c675cca
Use int64_t instead of int for size casts out of an abundance of caut…
smcallis Oct 4, 2025
593414d
Split INT_MIN construction test case into a separate named case.
smcallis Oct 4, 2025
f075655
Fix typo in bignum.cc.
smcallis Oct 4, 2025
5853f70
Add comment for the Numbers() function.
smcallis Oct 4, 2025
a470ace
Switch to std::unique_ptr in Arena.
smcallis Oct 4, 2025
f9697b1
Create tagged seed sequences for bignum tests and minor fixes.
smcallis Oct 5, 2025
746be61
CR Round 7 fixes.
smcallis Oct 8, 2025
d1b6920
CR round 8 changes.
smcallis Oct 10, 2025
eb1d501
Minor renaming and comment fixes.
smcallis Oct 11, 2025
dde62ae
Remove redundant borrow propagation loop.
smcallis Oct 11, 2025
f434e10
Revert .bazelrc changes.
smcallis Oct 22, 2025
05a39ae
Merge branch 'master' into remove-openssl
smcallis Oct 24, 2025
26b180b
Minor formatting cleanup.
smcallis Oct 24, 2025
6d5b227
Revert to using find_package for OpenSSL.
smcallis Oct 24, 2025
05605ea
Remove 0 - term when static_cast-ing INT_MIN to take absolute value.
smcallis Oct 24, 2025
4fc8806
Make find_package(OpenSSL) test-only and minor fixups.
smcallis Oct 24, 2025
1bbe409
Minor spacing fixes and more comments on AddBigit and MulAddBigit.
smcallis Oct 25, 2025
4a4380b
Minor edits.
smcallis Oct 30, 2025
fc43b3c
Add SafeAbs to avoid UB when casting INT_MIN.
smcallis Oct 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ add_definitions(-DABSL_MIN_LOG_LEVEL=1)
if (NOT TARGET absl::base)
find_package(absl REQUIRED)
endif()
find_package(OpenSSL REQUIRED)
# pthreads isn't used directly, but this is still required for std::thread.
find_package(Threads REQUIRED)

Expand Down Expand Up @@ -99,10 +98,6 @@ else()
add_compile_options(-fsized-deallocation)
endif()

# If OpenSSL is installed in a non-standard location, configure with
# something like:
# OPENSSL_ROOT_DIR=/usr/local/opt/openssl cmake ..
include_directories(${OPENSSL_INCLUDE_DIR})

if (WITH_PYTHON)
include_directories(${Python3_INCLUDE_DIRS})
Expand Down Expand Up @@ -215,6 +210,7 @@ add_library(s2
src/s2/util/bits/bit-interleave.cc
src/s2/util/coding/coder.cc
src/s2/util/coding/varint.cc
src/s2/util/math/exactfloat/bignum.cc
src/s2/util/math/exactfloat/exactfloat.cc
src/s2/util/math/mathutil.cc
src/s2/util/units/length-units.cc)
Expand All @@ -228,9 +224,9 @@ if (GOOGLETEST_ROOT)
src/s2/thread_testing.cc)
endif()


target_link_libraries(
s2
${OPENSSL_LIBRARIES}
absl::absl_vlog_is_on
absl::base
absl::btree
Expand Down Expand Up @@ -458,7 +454,8 @@ if(S2_ENABLE_INSTALL)
src/s2/util/math/matrix3x3.h
src/s2/util/math/vector.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/math")
install(FILES src/s2/util/math/exactfloat/exactfloat.h
install(FILES src/s2/util/math/exactfloat/bignum.h
src/s2/util/math/exactfloat/exactfloat.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/math/exactfloat")
install(FILES src/s2/util/units/length-units.h
src/s2/util/units/physical-units.h
Expand Down Expand Up @@ -619,6 +616,7 @@ if (BUILD_TESTS)
src/s2/s2wrapped_shape_test.cc
src/s2/sequence_lexicon_test.cc
src/s2/value_lexicon_test.cc
src/s2/util/math/exactfloat/bignum_test.cc
src/s2/util/math/exactfloat/exactfloat_test.cc
src/s2/util/math/exactfloat/exactfloat_underflow_test.cc)

Expand All @@ -643,7 +641,8 @@ if (BUILD_TESTS)
absl::status
absl::strings
absl::synchronization
gmock_main)
gmock_main
crypto)
add_test(${test} ${test})
endforeach()
endif()
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ This issue may require revision of boringssl or exactfloat.
* [Abseil](https://github.com/abseil/abseil-cpp) >= LTS
[`20250814`](https://github.com/abseil/abseil-cpp/releases/tag/20250814.1)
(standard library extensions)
* [OpenSSL](https://github.com/openssl/openssl) (for its bignum library)
* [googletest testing framework >= 1.10](https://github.com/google/googletest)
(to build tests and example programs, optional)

Expand Down Expand Up @@ -139,6 +138,13 @@ Disable building of shared libraries with `-DBUILD_SHARED_LIBS=OFF`.

Enable the python interface with `-DWITH_PYTHON=ON`.

# For Testing

If BUILD_TESTS is 'on' (the default), then OpenSSL must be available to build
some tests:

* [OpenSSL](https://github.com/openssl/openssl) (for its bignum library)

If OpenSSL is installed in a non-standard location set `OPENSSL_ROOT_DIR`
before running configure, for example on macOS:
```
Expand Down Expand Up @@ -218,8 +224,6 @@ python -m build

The resulting wheel will be in the `dist` directory.

> If OpenSSL is in a non-standard location make sure to set `OPENSSL_ROOT_DIR`;
> see above for more information.

## Other S2 implementations

Expand Down
27 changes: 25 additions & 2 deletions src/s2/util/math/exactfloat/BUILD
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "bignum",
srcs = ["bignum.cc"],
hdrs = ["bignum.h"],
visibility = ["//visibility:private"],
deps = [
"@abseil-cpp//absl/algorithm:container",
"@abseil-cpp//absl/container:inlined_vector",
"@abseil-cpp//absl/log:absl_check",
],
)

cc_library(
name = "exactfloat",
srcs = ["exactfloat.cc"],
hdrs = ["exactfloat.h"],
deps = [
":bignum",
"//s2/base:logging",
"@abseil-cpp//absl/log:log",
"@abseil-cpp//absl/log:absl_check",
],
)

cc_test(
name = "bignum_test",
srcs = ["bignum_test.cc"],
deps = [
":bignum",
"//:s2_testing_headers",
"@abseil-cpp//absl/log:log_streamer",
"@abseil-cpp//absl/random:bit_gen_ref",
"@boringssl//:crypto",

Choose a reason for hiding this comment

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

I asked a couple of questions about this on a previous comment, but github apparently doesn't see fit to mark the conversations as unresolved and so I'm guessing you never saw those questions. Essentially, I'm asking whether these benchmarks are important enough that we want to continue to have a dependency on OpenSSL, even if it's just for testing purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Up to @jmr, it's easier to live with if it's just for testing.

"@googletest//:gtest_main",
],
)

Expand Down
Loading