java -cp . zz big n
chooses an n bit test case and writes a small file to be included when
mp.c
is compiled.
This provides C definitions of some big numbers to challenge
the modPow routine as a test.
The answer is included.
The main routine that includes the “#include xx.h” statement
can be enabled to use this file.
In a Unix command shell this can be used thus:
javac zz.java
java -cp . zz big 1492 > xx.h
gcc -O3 mp.c
time ./a.out
The java program, zz, will choose a test case of 1492 bits,
file xx.h will be created and included in the source of the C program
which prints the result and “Goodness!” if it computes the provided answer.
(2009 Apr 13: n = 14920, CPU = 1.83 GHz Intel Core Duo => 120.77s user)
(2010 Sept 30: n = 14920, CPU = 1.83 GHz Intel Core Duo => 91.02s user)
(ditto with clang, CPU = 1.83 GHz Intel Core Duo => 80.87s user)
(2011 Jan 29: n = 14920, CPU = 1.83 GHz Intel Core Duo => 91.02s user)
(ditto with clang, CPU = 1.83 GHz Intel Core Duo => 80.88s user)
(clang, n = 10920, CPU = 1.83 GHz Intel Core Duo => 30.91s user)
(gcc, n = 10920, CPU = 2.4 GHz Intel Core 2 Duo => 6.43s user)
(clang, n = 10920, CPU = 2.4 GHz Intel Core 2 Duo => 6.40s user)