GNU bug report logs - #10519
guile and (mini-)gmp

Previous Next

Package: guile;

Reported by: nisse <at> lysator.liu.se (Niels Möller)

Date: Sun, 15 Jan 2012 22:01:02 UTC

Severity: wishlist

Full log


Message #77 received at 10519 <at> debbugs.gnu.org (full text, mbox):

From: nisse <at> lysator.liu.se (Niels Möller)
To: Mark H Weaver <mhw <at> netris.org>
Cc: Andy Wingo <wingo <at> pobox.com>, 10519 <at> debbugs.gnu.org,
	Ludovic Courtès <ludo <at> gnu.org>,
	Torbjorn Granlund <tg <at> gmplib.org>
Subject: Re: bug#10519: guile and (mini-)gmp
Date: Tue, 26 Mar 2013 09:17:38 +0100
Mark H Weaver <mhw <at> netris.org> writes:

> FYI, I've pushed patches to Guile's git repository (stable-2.0 branch)
> which eliminate the known obstacles to mini-gmp integration.

Out of curiosity, I had a quick look at the patches as posted to the
guile devel list.

For the small integer gcd code, you may want to have a look at the
tricks used in
http://gmplib.org:8000/gmp/file/304af17b9ccc/mpn/generic/gcd_1.c, the
code under GCD_1_METHOD == 2

1. Shift out the least significant bit of both a and b (they're always
   one). Maybe you don't need this of you have some extra bits already
   (signed types, or some bits reserved for type info).

2. Then, the sign bit of a - b correctly gives the result of the
   comparison a < b. Constructing a mask from this difference is then a
   simple right shift (if >> on a signed int is not an arithmetic right
   shift, you need shift and a negation).

3. Use this bit mask when forming the absolute value |a - b|, and when
   swapping values around, to avoid unpredictable branches which
   typically are quite expensive.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.




This bug report was last modified 8 years and 217 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.