mini-gmp

Vincent Lefevre vincent at vinc17.net
Fri Dec 21 12:15:45 UTC 2018


On 2018-12-21 01:43:12 +0100, Marco Bodrato wrote:
> We know, we never claimed that mini-gmp was supporting different limb sizes.
> The suggestion was "by Paul" :-)

In https://gmplib.org/list-archives/gmp-devel/2018-December/005117.html
you said:

  A attach a possible implementation of mini-gmp that should support limbs
  of "any" size. Can you test it with MPFR? Both correctness and speed...

But perhaps this hadn't been pushed yet.

> By the way, I pushed a possible adaptation of mini-gmp.

Thanks. I'll try it, but first...

 #define gmp_umul_ppmm(w1, w0, u, v)                                    \
   do {                                                                 \
+    int LOCAL_GMP_LIMB_BITS = GMP_LIMB_BITS;                           \
+    if (sizeof (unsigned int) >= 2 * sizeof (mp_limb_t))               \
+      {                                                                        \
+       unsigned int __ww = (unsigned int) (u) * (v);                   \
+       w0 = (mp_limb_t) __ww;                                          \
+       w1 = (mp_limb_t) (__ww >> LOCAL_GMP_LIMB_BITS);                 \
+      }                                                                        \
+    else if (sizeof (unsigned long int) >= 2 * sizeof (mp_limb_t))     \
+      {                                                                        \
+       unsigned long int __ww = (unsigned long int) (u) * (v);         \
+       w0 = (mp_limb_t) __ww;                                          \
+       w1 = (mp_limb_t) (__ww >> LOCAL_GMP_LIMB_BITS);                 \
+      }                                                                        \
+    else {                                                             \

Wouldn't it be sufficient to have only the unsigned long version?

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the gmp-devel mailing list