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

LibTomMath backend support #155

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
058e346
Preliminary support for LibTomMath as backend instead of GMP.
antoinemine Jul 16, 2020
1ccc6be
minor fixes for Windows compatibility
antoinemine Jul 16, 2020
dbd97db
typos
antoinemine Jul 16, 2020
278b5d0
build against the develop branch of LibTomMath, fix compile warnings
antoinemine Jul 17, 2020
17a5f5a
fixed deserialization
antoinemine Jul 20, 2020
5c79b98
fix bugs in the TomMath backend
antoinemine Jul 31, 2020
f903b16
Better support for multiple backends.
antoinemine Jul 31, 2020
20d7625
changed backend detection in tests
antoinemine Jul 31, 2020
1b2a460
hash function that gives the same result as the GMP one
antoinemine Aug 17, 2020
7cce0ff
enable 'marshal round trip' tests with LibTomMath backend
antoinemine Aug 17, 2020
c7a16c3
Z.digit_bits () returns the number of bits used in each limb/digit
antoinemine Aug 18, 2020
16777fb
LibTomMath: hashing, testing and doc
antoinemine Aug 18, 2020
72c9899
use 'diff -u' for tests instead of 'cmp -s'
antoinemine Aug 19, 2020
8ba4099
add reference test results for LibTomMath on 64-bit Windows VS
antoinemine Aug 20, 2020
2cf4527
Merge branch 'master' into features/tommath-support
antoinemine Nov 10, 2020
65aa200
Merge branch 'master' into features/tommath-support
antoinemine Nov 11, 2020
5512639
import #78, #84 and #85 from caml_z.c
antoinemine Nov 11, 2020
b1a1be2
Merge branch 'master' into features/tommath-support
antoinemine Jan 26, 2021
6ce46a5
generate zarith_version.ml from configure instead of Makefile
antoinemine Mar 2, 2021
2bb4cdb
fix 64-bit bounds for convertion from double
antoinemine Mar 28, 2023
ee7fba8
pow function for LibTomMath
antoinemine Mar 31, 2023
f7bb20b
Fix overflow error when compiling with LLVM 17.
antoinemine Oct 30, 2023
40059f3
Merge branch 'master' into features/tommath-support
antoinemine Aug 20, 2024
e708423
add bit extraction operations to LibTomMath backend
antoinemine Aug 20, 2024
9f9f146
added sqrt_rem to LibTomMath backend
antoinemine Aug 20, 2024
f3e70f9
added hamdist to the LibTomMath backend
antoinemine Aug 20, 2024
34292cd
added divisible to LibTomMath backend
antoinemine Aug 20, 2024
47c5671
Cleaning.
antoinemine Aug 21, 2024
906f475
mp_init error checking in LibTomMath backend
antoinemine Aug 21, 2024
6b02421
Z_ARG or Z_REFRESH must be called after OCaml memory allocation
antoinemine Aug 21, 2024
0d88188
remove hardcoded -g
antoinemine Aug 21, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
Makefile
depend
zarith_version.ml
html
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,29 @@ Source files | Description
--------------------|-----------------------------------------
configure | configuration script
z.ml[i] | Z module and implementation for small integers
caml_z.c | C implementation
caml_z.c | C implementation using GMP/MPIR
caml_z_tommath.c | C implementation using LibTomMath
big_int_z.ml[i] | wrapper to provide a Big_int compatible API to Z
q.ml[i] | rational library, pure OCaml on top of Z
zarith_top.ml | toplevel module to provide pretty-printing
projet.mak | builds Z, Q and the tests
zarith.opam | package description for opam
z_mlgmpidl.ml[i] | conversion between Zarith and MLGMPIDL
tests/ | simple regression tests and benchmarks


## BACK-END COMPATIBILITY

Zarith supports several back-ends to implement multi-word integers: GMP, MPIR, and LibTomMath.
GMP is the default.
The `configure` script will try them in the following order: GMP, MPIR, LibTomMath.
The choice of back-end can be overridden with the `-gmp`, `-mpir`, and `-tommath` configure options.

GMP and MPIR support all functions and should give identical results.
The hashing function is identical and the marshalling format is compatible for GMP and MPIR, and for 32-bit and 64-bit.

LibTomMath support is partial and experimental.
Not all functions are implemented.
Unsupported functions raise a `Failure` exception.
The hashing function is different from the GMP/MPIR one, and the hashed value actually depends on the digit bit-size used by LibTomMath (which can be queried with `digit_bits ()`).
Additionally, the marshaling format is incompatible with the GMP/MPIR one, although it is independent from the digit bit-size.
5 changes: 5 additions & 0 deletions caml_z.c
Original file line number Diff line number Diff line change
Expand Up @@ -3538,6 +3538,11 @@ CAMLprim value ml_z_init()
return Val_unit;
}

CAMLprim value ml_z_digit_bits()
{
return Val_long(sizeof(mp_limb_t) * 8);
}

#ifdef __cplusplus
}
#endif
Loading
Loading