|
Aesi Multiprecision
C++ class library of long integer arithmetic for GPU parallelization
|
A header-only static-sized multiprecision arithmetic library for C++ and CUDA. Supports constexpr expressions, move semantics, and GPU parallelization frameworks in CUDA environments.
Supports all arithmetic (binary and unary), bitwise, and boolean operations. Number theory functions include GCD, LCM, and modular exponentiation.
Via CMake FetchContent:
Via cmake –install / find_package:
Then include in your source:
The library is header-only and works in both C++ and CUDA projects without changing file extensions. The number's bitness is a template parameter with a default of 512 bits — must be a multiple of 32.
Initialization accepts integers, strings, string views, and library objects of different precision. Display works with STD streams (char and wchar_t), including std::showbase, std::uppercase, std::hex, std::dec, std::oct.
0x49eebc961ed279b02b1ef4f28d19a84f5973a1d2c7800000000000
Value in kernel thread: 1562144106091796071
Numbers of different precision can be mixed in most operations, though it causes implicit copying. Operation-assignment expressions (+=, -=, &=, etc.) require the left-hand bitness to be greater or equal to the right-hand. Use precisionCast<N>() to convert explicitly.
6680141832773294447513292887050873529
Functions susceptible to overflow (e.g. powm) should use a larger precision explicitly:
***Overflowed*** 201007033690655614485250957754150944769
The library is slower than CPU-optimized multiprecision libraries. Benchmark results are published in each Benchmarking workflow run as a job summary.
See CONTRIBUTING.md for commit conventions, branch naming, and how to run tests, benchmarks, and sanitizers.
This project is licensed under the BSD 2-Clause License. See the [LICENSE](LICENSE) file for details.