3 ms·
Yep, the program referenced in the blogpost https://github.com/briandfoy/excellent_numbers/blob/master/c/excellent-gmp.c https://github.com/briandfoy/excellent_
by madars 5y ago
Yep, the program referenced in the blogpost https://github.com/briandfoy/excellent_numbers/blob/master/c/excellent-gmp.c https://github.com/briandfoy/excellent_numbers/blob/master/c... is using GMP's variable-width numbers (mpz_* routines). If you know bit lengths in advance you provide pre-allocated C arrays to mpn_* routines: https://gmplib.org/manual/Low_002dlevel-Functions https://gmplib.org/manual/Low_002dlevel-Functions . This is likely going to be much faster (you avoid bookkeeping and malloc inside mpz_*), and what e.g. libsnark does for its general Fp arithmetic. (E.g. addition becomes https://github.com/scipr-lab/libff/blob/develop/libff/algebra/fields/prime_base/fp.tcc#L510 https://github.com/scipr-lab/libff/blob/develop/libff/algebr... ) Of course, mpn_* routines still do loops which __int128 ones would presumably unroll but the bulk of the gain should come from reducing mpz_* overheads.