Permalink
Browse files

added libtommath-0.08

  • Loading branch information...
1 parent 3cd7000 commit 2cfbb891421da04a2c85a659ad92faea25123bb0 Tom St Denis committed with sjaeckel Feb 28, 2003
Showing with 655 additions and 115 deletions.
  1. +304 −85 bn.c
  2. +5 −8 bn.h
  3. BIN bn.pdf
  4. +11 −11 bn.tex
  5. +8 −0 changes.txt
  6. +21 −5 demo.c
  7. +1 −0 etc/makefile
  8. +281 −0 etc/pprime.c
  9. +9 −4 makefile
  10. +9 −2 mtest/mtest.c
  11. +6 −0 timer.asm
View
389 bn.c

Large diffs are not rendered by default.

Oops, something went wrong.
View
13 bn.h
@@ -50,7 +50,7 @@
typedef unsigned long mp_digit;
typedef ulong64 mp_word;
- #define DIGIT_BIT 28U
+ #define DIGIT_BIT 28
#endif
#ifndef DIGIT_BIT
@@ -77,13 +77,10 @@
typedef int mp_err;
/* you'll have to tune these... */
-#ifdef FAST_FPU
- #define KARATSUBA_MUL_CUTOFF 100 /* Min. number of digits before Karatsuba multiplication is used. */
- #define KARATSUBA_SQR_CUTOFF 100 /* Min. number of digits before Karatsuba squaring is used. */
-#else
- #define KARATSUBA_MUL_CUTOFF 80 /* Min. number of digits before Karatsuba multiplication is used. */
- #define KARATSUBA_SQR_CUTOFF 80 /* Min. number of digits before Karatsuba squaring is used. */
-#endif
+#define KARATSUBA_MUL_CUTOFF 80 /* Min. number of digits before Karatsuba multiplication is used. */
+#define KARATSUBA_SQR_CUTOFF 80 /* Min. number of digits before Karatsuba squaring is used. */
+
+#define MP_PREC 64 /* default digits of precision */
typedef struct {
int used, alloc, sign;
View
BIN bn.pdf
Binary file not shown.
View
22 bn.tex
@@ -1,7 +1,7 @@
\documentclass{article}
\begin{document}
-\title{LibTomMath v0.07 \\ A Free Multiple Precision Integer Library}
+\title{LibTomMath v0.08 \\ A Free Multiple Precision Integer Library}
\author{Tom St Denis \\ tomstdenis@iahu.ca}
\maketitle
\newpage
@@ -484,23 +484,23 @@ \subsection{Observed Timings}
Multiply & 256 & 2,551 & 958 \\
Multiply & 512 & 7,913 & 2,476 \\
Multiply & 1024 & 28,496 & 7,927 \\
-Multiply & 2048 & 109,897 & 282,24 \\
-Multiply & 4096 & 469,970 & 104,681 \\
+Multiply & 2048 & 109,897 & 28,224 \\
+Multiply & 4096 & 469,970 & 101,171 \\
\hline
Square & 128 & 1,319 & 511 \\
Square & 256 & 1,776 & 947 \\
Square & 512 & 5,399 & 2,153 \\
Square & 1024 & 18,991 & 5,733 \\
Square & 2048 & 72,126 & 17,621 \\
-Square & 4096 & 306,269 & 70,168 \\
+Square & 4096 & 306,269 & 67,576 \\
\hline
-Exptmod & 512 & 32,021,586 & 4,472,406 \\
-Exptmod & 768 & 97,595,492 & 10,427,845 \\
-Exptmod & 1024 & 223,302,532 & 20,561,722 \\
-Exptmod & 2048 & 1,682,223,369 & 113,978,803 \\
-Exptmod & 2560 & 3,268,615,571 & 236,650,133 \\
-Exptmod & 3072 & 5,597,240,141 & 373,449,291 \\
-Exptmod & 4096 & 13,347,270,891 & 787,568,457
+Exptmod & 512 & 32,021,586 & 4,138,354 \\
+Exptmod & 768 & 97,595,492 & 9,840,233 \\
+Exptmod & 1024 & 223,302,532 & 20,624,553 \\
+Exptmod & 2048 & 1,682,223,369 & 114,936,361 \\
+Exptmod & 2560 & 3,268,615,571 & 229,402,426 \\
+Exptmod & 3072 & 5,597,240,141 & 367,403,840 \\
+Exptmod & 4096 & 13,347,270,891 & 779,058,433
\end{tabular}
\end{center}
View
@@ -1,3 +1,11 @@
+Jan 2nd, 2003
+v0.08 -- Sped up the multipliers by moving the inner loop variables into a smaller scope
+ -- Corrected a bunch of small "warnings"
+ -- Added more comments
+ -- Made "mtest" be able to use /dev/random, /dev/urandom or stdin for RNG data
+ -- Corrected some bugs where error messages were potentially ignored
+ -- add etc/pprime.c program which makes numbers which are provably prime.
+
Jan 1st, 2003
v0.07 -- Removed alot of heap operations from core functions to speed them up
-- Added a root finding function [and mp_sqrt macro like from MPI]
View
26 demo.c
@@ -23,7 +23,6 @@ extern ulong64 rdtsc(void);
extern void reset(void);
#else
-
ulong64 _tt;
void reset(void) { _tt = clock(); }
ulong64 rdtsc(void) { return clock() - _tt; }
@@ -33,6 +32,8 @@ ulong64 rdtsc(void) { return clock() - _tt; }
int _ifuncs;
#else
extern int _ifuncs;
+extern void dump_timings(void);
+extern void reset_timings(void);
#endif
void ndraw(mp_int *a, char *name)
@@ -103,11 +104,25 @@ int main(void)
mp_read_radix(&b, "4982748972349724892742", 10);
mp_sub_d(&a, 1, &c);
+
+#ifdef DEBUG
+ mp_sqr(&a, &a);mp_sqr(&c, &c);
+ mp_sqr(&a, &a);mp_sqr(&c, &c);
+ mp_sqr(&a, &a);mp_sqr(&c, &c);
+ reset_timings();
+#endif
mp_exptmod(&b, &c, &a, &d);
- mp_toradix(&d, buf, 10);
- printf("b^p-1 == %s\n", buf);
+#ifdef DEBUG
+ dump_timings();
+ return 0;
-#ifdef TIMER
+#endif
+
+ mp_toradix(&d, buf, 10);
+ printf("b^p-1 == %s\n", buf);
+
+
+#ifdef TIMER
mp_read_radix(&a, "340282366920938463463374607431768211455", 10);
mp_read_radix(&b, "340282366920938463463574607431768211455", 10);
while (a.used * DIGIT_BIT < 8192) {
@@ -194,7 +209,8 @@ int main(void)
}
printf("Exponentiating %d-bit took %llu cycles\n", mp_count_bits(&a), tt / ((ulong64)35));
}
- }
+ }
+
mp_read_radix(&a, "340282366920938463463374607431768211455", 10);
mp_read_radix(&b, "234892374891378913789237289378973232333", 10);
View
@@ -0,0 +1 @@
+CFLAGS += -I../ -Wall -W -O3 -fomit-frame-pointer -funroll-loops ../bn.c
Oops, something went wrong.

0 comments on commit 2cfbb89

Please sign in to comment.