Skip to content

mpn_mod backend for APRCL + tuning fmpz_is_prime - #2784

Merged
fredrik-johansson merged 1 commit into
flintlib:mainfrom
fredrik-johansson:aprcl
Jul 27, 2026
Merged

mpn_mod backend for APRCL + tuning fmpz_is_prime#2784
fredrik-johansson merged 1 commit into
flintlib:mainfrom
fredrik-johansson:aprcl

Conversation

@fredrik-johansson

Copy link
Copy Markdown
Collaborator

The APRCL primality test gets an mpn_mod backend for the cyclotomic arithmetic when n is small enough, which is significantly faster than the generic-size fmpz_mod backend. I also used this opportunity to merge all unity_zp files in the APRCL module which really didn't need to be separate.

Also improve the criterion for using Pocklington and Morrison.

Done using Claude Fable 5.

This significantly speeds up fmpz_is_prime for medium input, fixing most of the remaining slowness for this function observed in #2625.

Time to check 10 random primes of the respective bit size with fmpz_is_prime:

bits        old        new  speedup
  80  2.940e-05  2.940e-05  1.000x
  96  9.780e-03  2.270e-03  4.308x
 112  1.010e-02  4.150e-03  2.434x
 128  1.560e-02  5.670e-03  2.751x
 144  2.620e-02  1.370e-02  1.912x
 160  4.170e-02  2.250e-02  1.853x
 176  5.050e-02  2.890e-02  1.747x
 192  6.190e-02  4.160e-02  1.488x
 208  7.900e-02  3.990e-02  1.980x
 224  9.180e-02  5.330e-02  1.722x
 240  1.120e-01  6.780e-02  1.652x
 256  1.250e-01  8.030e-02  1.557x
 272  1.560e-01  9.000e-02  1.733x
 288  1.800e-01  1.080e-01  1.667x
 304  1.980e-01  1.250e-01  1.584x
 320  2.340e-01  1.500e-01  1.560x
 336  2.750e-01  1.640e-01  1.677x
 352  3.800e-01  2.550e-01  1.490x
 368  4.010e-01  2.730e-01  1.469x
 384  4.610e-01  3.130e-01  1.473x
 400  5.470e-01  3.420e-01  1.599x
 416  5.920e-01  3.940e-01  1.503x
 432  6.520e-01  4.380e-01  1.489x
 448  7.080e-01  4.720e-01  1.500x
 464  8.130e-01  5.170e-01  1.573x
 480  8.850e-01  6.020e-01  1.470x
 496  9.060e-01  6.150e-01  1.473x
 512  1.027e+00  6.990e-01  1.469x
 528  1.183e+00  8.460e-01  1.398x
 544  1.271e+00  9.430e-01  1.348x
 560  1.475e+00  1.132e+00  1.303x
 576  1.601e+00  1.216e+00  1.317x
 592  1.796e+00  1.369e+00  1.312x
 608  1.894e+00  1.508e+00  1.256x
 624  1.905e+00  1.532e+00  1.243x
 640  2.113e+00  1.680e+00  1.258x
 656  2.436e+00  1.951e+00  1.249x
 672  2.591e+00  2.153e+00  1.203x
 688  2.640e+00  2.196e+00  1.202x
 704  2.890e+00  2.387e+00  1.211x
 720  3.577e+00  2.999e+00  1.193x
 736  3.748e+00  3.195e+00  1.173x
 752  3.955e+00  3.460e+00  1.143x
 768  4.250e+00  3.630e+00  1.171x
 784  5.778e+00  5.094e+00  1.134x
 800  5.856e+00  5.214e+00  1.123x

@fredrik-johansson
fredrik-johansson merged commit 9b0f426 into flintlib:main Jul 27, 2026
13 checks passed
@fredrik-johansson
fredrik-johansson deleted the aprcl branch July 27, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant