fix bigint mul non-compilation after #231

This commit is contained in:
Mamy Ratsimbazafy 2023-07-09 18:57:12 +02:00
parent d69c7bf8e9
commit cb038bb515
No known key found for this signature in database
GPG Key ID: 6227262F49BE273A
4 changed files with 13 additions and 4 deletions

View File

@ -302,7 +302,7 @@ const testDesc: seq[tuple[path: string, useGMP: bool]] = @[
("tests/math_bigints/t_io_bigints.nim", false),
# ("tests/math_bigints/t_bigints.nim", false),
# ("tests/math_bigints/t_bigints_multimod.nim", false),
# ("tests/math_bigints/t_bigints_mul_vs_gmp.nim", true),
("tests/math_bigints/t_bigints_mul_vs_gmp.nim", true),
# ("tests/math_bigints/t_bigints_mul_high_words_vs_gmp.nim", true),
# Big ints - arbitrary precision

View File

@ -39,7 +39,7 @@ macro mul_gen[rLen, aLen, bLen: static int](r_PIR: var Limbs[rLen], a_MEM: Limbs
let
r = asmArray(r_PIR, rLen, PointerInReg, asmInputOutputEarlyClobber, memIndirect = memWrite) # MemOffsettable is the better constraint but compilers say it is impossible. Use early clobber to ensure it is not affected by constant propagation at slight pessimization (reloading it).
a = asmArray(a_MEM, aLen, MemOffsettable, asmInput)
b = asmArray(b_MEM, aLen, MemOffsettable, asmInput)
b = asmArray(b_MEM, bLen, MemOffsettable, asmInput)
tSym = ident"t"
t = asmValue(tSym, Reg, asmOutputEarlyClobber)

View File

@ -63,6 +63,10 @@ proc main() =
mpz_init(r)
mpz_init(a)
mpz_init(b)
defer:
mpz_clear(b)
mpz_clear(a)
mpz_clear(r)
testRandomModSizes(12, rBits, aBits, bBits, wordsStartIndex):
# echo "--------------------------------------------------------------------------------"

View File

@ -16,6 +16,7 @@ import
../../constantine/math/arithmetic,
../../constantine/platforms/abstractions,
# Test utilities
../../constantine/platforms/codecs,
../../helpers/prng_unsafe
echo "\n------------------------------------------------------\n"
@ -60,6 +61,10 @@ proc main() =
mpz_init(r)
mpz_init(a)
mpz_init(b)
defer:
mpz_clear(b)
mpz_clear(a)
mpz_clear(r)
testRandomModSizes(12, rBits, aBits, bBits):
# echo "--------------------------------------------------------------------------------"
@ -117,8 +122,8 @@ proc main() =
discard mpz_export(aBuf[0].addr, aW.addr, GMP_MostSignificantWordFirst, 1, GMP_WordNativeEndian, 0, a)
discard mpz_export(bBuf[0].addr, bW.addr, GMP_MostSignificantWordFirst, 1, GMP_WordNativeEndian, 0, b)
"\nMultiplication with operands\n" &
" a (" & align($aBits, 4) & "-bit): " & aBuf.toHex & "\n" &
" b (" & align($bBits, 4) & "-bit): " & bBuf.toHex & "\n" &
" a (" & align($aBits, 4) & "-bit): " & aBuf.toHex() & "\n" &
" b (" & align($bBits, 4) & "-bit): " & bBuf.toHex() & "\n" &
"into r of size " & align($rBits, 4) & "-bit failed:" & "\n" &
" GMP: " & rGMP.toHex() & "\n" &
" Constantine: " & rConstantine.toHex() & "\n" &