boostorg / multiprecision

Boost.Multiprecision
Boost Software License 1.0
194 stars 111 forks source link

About cpp_int::size() and MinBits #549

Closed afabri closed 1 year ago

afabri commented 1 year ago

I use boost::multiprecision::number<boost::multiprecision::cpp_int_backend<512> > and perform multiplications on them. Does that mean that there should be up to 512/64 limbs not allocated dynamically?

I ask because I have only few multiplications where the result has more than 8 limbs (I create a histogram on the value returned by the helper function cpp_int::size()), but in vtune I see that I still spend a lot of time in the resize() call in multiply.h

jzmaddock commented 1 year ago

I use boost::multiprecision::number<boost::multiprecision::cpp_int_backend<512> > and perform multiplications on them. Does that mean that there should be up to 512/64 limbs not allocated dynamically?

No. That type has an internal cache size of 512 bits and no upper limit.

Use cpp_int_backend<512, 512> if you want a non-resizable type, or better still boost::multiprecision::int512_t