diff --git a/Fgw.c b/Fgw.c index ddb062c953a406fac720a54ad717220634683bcb..9c40cd75070e931085f21a69d2cb9862ac8b957b 100644 --- a/Fgw.c +++ b/Fgw.c @@ -531,10 +531,10 @@ gw_ecm_stage1 (mpz_t f, curve *P, mpmod_t modulus, /* Allocate enough memory for any residue (mod k*b^n+c) for x, z */ /* ecmstag1.c in gwnum says it needs 60 bits more than the gwnum modulus size, so we add 64 bits here to maintain whole-word allocations for gw_x and gw_z */ - mpz_init2 (gw_x, kbnc_size + 96); - mpz_init2 (gw_z, kbnc_size + 96); + mpz_init2 (gw_x, 2*kbnc_size); + mpz_init2 (gw_z, 2*kbnc_size); mpres_init (gw_A, modulus); - options = 0; + options = 1; } else /* set for gwnum generic mod */ { @@ -560,10 +560,12 @@ gw_ecm_stage1 (mpz_t f, curve *P, mpmod_t modulus, siz_x = SIZ(gw_x); siz_z = SIZ(gw_z); - /* George Woltman says that the gwnum library can handle k values up to 49 - or 50 bits long, and the maximum c value is +/-8388607 */ + /* Per p95v3019b11.source/gwnum/gwnum.c, line 2181: + "if (k > 9007199254740991.0) return (GWERROR_K_TOO_LARGE);" + The stated value is 2^53-1, so we must require k <= 2^53-1. + The maximum c value is +/-8388607 (2^23-1) */ ASSERT_ALWAYS (gw_k == rint (gw_k)); /* check that k is an integer */ - ASSERT_ALWAYS (1.0 <= gw_k && gw_k < 0x1p49); + ASSERT_ALWAYS (1.0 <= gw_k && gw_k < 0x1p53); ASSERT_ALWAYS (-8388607 <= gw_c && gw_c <= 8388607); #if GMP_NUMB_BITS <= 32 youpi = gwnum_ecmStage1_u32 (gw_k, gw_b, gw_n, gw_c, diff --git a/INSTALL-gwnum b/INSTALL-gwnum index 6c0d9c66a9aa2dd220de337c1a115e36db08648f..bc920cdf84c254ecdaf67e4346a819adb44c9c61 100644 --- a/INSTALL-gwnum +++ b/INSTALL-gwnum @@ -8,15 +8,15 @@ Users should familiarize themselves with the instructions in 0) Download Prime 95 source files. As of Feb. 2024, the current .zip file is: - https://mersenne.org/download/software/v30/30.19/p95v3019b10.source.zip + https://mersenne.org/download/software/v30/30.19/p95v3019b11.source.zip Note: due to critical bug fixes in the gwnum/ecmstag1.c and FFT - assembly files used by GMP-ECM, versions of P95 before v3019b10 + assembly files used by GMP-ECM, versions of P95 before v3019b11 will not work here (make check will fail) and should not be used. Unzip/extract the P95 file to any convenient location. -1) Build gwnum.a. Navigate to the folder /p95v3019b10.source/gwnum. +1) Build gwnum.a. Navigate to the folder /p95v3019b11.source/gwnum. Follow the instructions for your machine/OS in the readme.txt file. For example, on 64-bit linux systems the command to execute is "$ make -f make64". @@ -28,10 +28,8 @@ Users should familiarize themselves with the instructions in -mtune=native -march=native - Save the file, then execute the build command. This should ensure - that George's FFT code will use the fastest instructions available - on your processor. - + Save the file, then execute the build command. + As an example, for the file gwnum/make64, the CFLAGS line changes from CFLAGS = -I.. -I../sqlite- <...> -O2 @@ -40,6 +38,10 @@ Users should familiarize themselves with the instructions in CFLAGS = -I.. -I../sqlite- <...> -O2 -mtune=native -march=native + Note that we have seen very large increases in run times on an + Intel® Core™ i9-13900K when gwnum.a is built without the "native" + CFLAGS. The cause is unknown at present. + 2) Configure and build with the gwnum.a library. Navigate back to the ECM build directory. If you have previously configured and built ECM, execute the command @@ -56,7 +58,7 @@ Users should familiarize themselves with the instructions in For example, if the ECM and p95 folders are both in the same home folder, the command might look like - $ ./configure --with-gwnum=../p95v3019b10.source/gwnum + $ ./configure --with-gwnum=../p95v3019b11.source/gwnum Note that you may also need to specify "--with-gmp=<gmpdir>" if "configure" has trouble finding GMP. @@ -87,7 +89,11 @@ Users should familiarize themselves with the instructions in (1) When the "k*b^n+c" form is used, the 'k*' term is not required if k = 1. The exponent 'n' may be entered as an integer or in the form (b2^n2), with 'n' or '(b2^n2)' < 10^10. Also, k must be a positive integer with - 1 <= k < 2^49, and c must be a non-zero integer with |c| < 2^23. + 1 <= k < 2^53, and c must be a non-zero integer with |c| < 2^23. + Note that the k upper limit of 2^53-1 is taken from the file + p95v3019b11.source/gwnum/gwnum.c, line 2181: + "if (k > 9007199254740991.0) return (GWERROR_K_TOO_LARGE);" + and is subject to change by Woltman. (2) For integer-character-only input strings N, GMP-ECM may detect if N = k*b^n+c, and find k, b, n, and c, but if possible the "k*b^n+c" form should be used. diff --git a/gwnum_linux.sh b/gwnum_linux.sh index 58bb3077765830df757a09e2309c3c223ccc0855..a448aa6ca34866a14d1545a5556a14048f8a4232 100755 --- a/gwnum_linux.sh +++ b/gwnum_linux.sh @@ -1,7 +1,7 @@ #! /bin/sh -P95_URL=https://mersenne.org/download/software/v30/30.19/p95v3019b10.source.zip -echo "Loading P95 version 30.19 build 10" +P95_URL=https://mersenne.org/download/software/v30/30.19/p95v3019b11.source.zip +echo "Loading P95 version 30.19 build 11" [ -d "/tmp/P95/" ] && rm -r /tmp/P95 mkdir /tmp/P95 wget -q -O /tmp/P95/P95_source.zip $P95_URL diff --git a/test.gwnum b/test.gwnum index 1c52110e89199f9d7ef37bd2b9d9b48b70940fd6..687965bb0c4f1c7da484252b76141aab2e559334 100755 --- a/test.gwnum +++ b/test.gwnum @@ -133,6 +133,9 @@ echo "(6^(2^11)+1)/(96479889653761)" | $ECM -no-gwnum -sigma 0:12521699575255072 echo "(2^839-1)/(26849*138561000316919*377801626929390823)" | $ECM -sigma 0:18041162131602966941 6e6; checkcode $? 14 echo "(2^839-1)/(26849*138561000316919*377801626929390823)" | $ECM -gwnum -sigma 0:18041162131602966941 6e6; checkcode $? 14 +# Exercise APR test plus large-k kbnc_str() input +echo "(562949953421312*3^1000+1)/36045048768571" | $ECM -sigma 0:9547094287835811496 1e5; checkcode $? 14 + # exercise -h $ECM -h