gmpy 1.01 rc near... anybody wanna test>

A

Alex Martelli

I have fixed almost all of the outstanding bugreports and feature
request for gmpy: divm doesn't leak memory any more, truediv and
floordiv are implemented for all types, etc -- in the current CVS
version (one thing I must still look at is divm's behavior when its args
are not mutually prime). It currently compiles w/o warnings, and passes
all of its 1040+ tests, w/the current release of GMP (4.1.4), Python
(2.4.2), MacOSX (10.4.3), XCode (2.1), gcc (4.0).\\

gmpy users able to download and build from sourceforge's cvs are
encouraged to test the current CVS version. This is a great time to
send me any bug reports or (minor;-) feature requests, since I hope to
release a "1.01 release candidate" of gmpy ASAP. I'm currently unable
to build any Windows version -- any volunteer for THAT task is doubly
welcome;-).


Thanks,

Alex
 
C

casevh

I downloaded and tried the CVS version. Division still didn't work as
expected.
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):

Platform: Solaris 10 x86, SunStudio compiler, GMP 4.1.4, Python 2.4.2
 
S

Steve Holden

Alex said:
I have fixed almost all of the outstanding bugreports and feature
request for gmpy: divm doesn't leak memory any more, truediv and
floordiv are implemented for all types, etc -- in the current CVS
version (one thing I must still look at is divm's behavior when its args
are not mutually prime). It currently compiles w/o warnings, and passes
all of its 1040+ tests, w/the current release of GMP (4.1.4), Python
(2.4.2), MacOSX (10.4.3), XCode (2.1), gcc (4.0).\\

gmpy users able to download and build from sourceforge's cvs are
encouraged to test the current CVS version. This is a great time to
send me any bug reports or (minor;-) feature requests, since I hope to
release a "1.01 release candidate" of gmpy ASAP. I'm currently unable
to build any Windows version -- any volunteer for THAT task is doubly
welcome;-).
I tried compiling it with the MS free toolkit but the C compile
complains about the absence of "gmp.h". Since I see such a header in my
Cygwin installation I presume it's something that a full VC7
installation could expect to be present.

Unfortunately modifying the build to use the Cygwin include directory
gave errors, I suspect because other Cygwin headers were also being
picked up in error (I just added /cygwin/usr/include to include_dirs.

Compilation ran to completion with the header files from both Cygwin and
the GNU gmp-static library, but then of course in both cases I was
missing the gmp library to link it against.

So I'm afraid you might need someone with access to VC to test this on
Windows for you, sorry.

regards
Steve
 
P

Paul Rubin

gmpy users able to download and build from sourceforge's cvs are
encouraged to test the current CVS version.

Oh cool, I wondered whether any gmpy maintenance was still going on.
I'll see if I can give the new version a try.
 
A

Alex Martelli

Steve Holden said:
I tried compiling it with the MS free toolkit but the C compile
complains about the absence of "gmp.h". Since I see such a header in my
Cygwin installation I presume it's something that a full VC7
installation could expect to be present.

gmp.h is the header of GMP, the GNU library that gmpy wraps. It appears
to be preinstalled on Cygwin, from what you mention, but I'm pretty sure
Microsoft doesn't preinstall GPL-covered libraries from GNU with THEIR
stuff... a suitable Windows version need to be procured and installed in
some other way (having no Windows around I'm hard put to suggest what is
the best way to do this these days).
So I'm afraid you might need someone with access to VC to test this on
Windows for you, sorry.

Tx for the attempt, but I don't think VC per se will suffice -- somebody
needs to build or find a suitable version of GMP for Windows, too.


Alex
 
A

Alex Martelli

I downloaded and tried the CVS version. Division still didn't work as
expected.

Now that's truly interesting...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: unsupported operand type(s) for //: 'mpz' and 'mpz'

while, on my machine:

Helen:~/gmpy/test alex$ python
Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
etc, etc.

The CVS commit which I did before the post you're replying to gave me:

....
Checking in src/gmpy.c;
/cvsroot/gmpy/gmpy/src/gmpy.c,v <-- gmpy.c
new revision: 1.14; previous revision: 1.13
done
Mailing (e-mail address removed)...
Generating notification message...
Generating notification message... done.

and the logfile should be...:


Helen:~/gmpy alex$ cvs log src/gmpy.c | head -20
(e-mail address removed)'s password:

RCS file: /cvsroot/gmpy/gmpy/src/gmpy.c,v
Working file: src/gmpy.c
head: 1.14
branch:
locks: strict
access list:
symbolic names:
import_release: 1.1.1.1
import_vendor: 1.1.1
keyword substitution: kv
total revisions: 15; selected revisions: 15
description:
----------------------------
revision 1.14
date: 2005/11/07 05:29:24; author: aleax; state: Exp; lines: +83 -2

Add floordiv and truediv implementations to mpz, mpq, mpf (unittests
still need to be added).
----------------------------
revision 1.13
....


Unfortunately, I didn't have a CVS $Id$ in gmpy.c (silly me!) so
checking that you have the right version was hard. I have now added it,
and an accessor to it from Python:

Helen:~/gmpy/test alex$ python
Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Can you cvs update again and check what's going on? Thanks!


Alex
 
A

Alex Martelli

Paul Rubin said:
Oh cool, I wondered whether any gmpy maintenance was still going on.

Only when I get guilt-tripped into working a bit on it;-). gmpy as it
stands mostly meets my modest personal needs, but I'd still like to keep
it useful to others, too, of course.
I'll see if I can give the new version a try.

Thanks. The floordiv and truediv still need tests, and there's a
mysterious report of them not working at all (which I suspect is due to
a cvs update somehow going awry -- I've now added a gmpy._cvsid()
accessor to return the CVS $Id$ string to facilitate checking for such
issues); divm shouldn't leak memory any more, but still fails when
arguments aren't mutually prime (haven't looked into that yet). I will
be working on these issues presently.

I haven't even looked at what's new in GMP 4.1.4 to see if there's
anything there which I should wrap in gmpy (or use to reimplement some
of gmpy's existing functionality in a more optimized way...). I'm open
to suggestions for any such minor features or optimizations, although my
main goal for 1.01 is to remove bugs and leaks -- any _major_ new
feature will have to wait for a future 1.1 or whatever...

Current gmpy's biggest single issue right now is that I can't build it
on Windows, having no Windows machine, and even less any GMP 4.1.4 for
Windows...


Alex
 
S

Steve Holden

Alex said:
gmp.h is the header of GMP, the GNU library that gmpy wraps. It appears
to be preinstalled on Cygwin, from what you mention, but I'm pretty sure
Microsoft doesn't preinstall GPL-covered libraries from GNU with THEIR
stuff... a suitable Windows version need to be procured and installed in
some other way (having no Windows around I'm hard put to suggest what is
the best way to do this these days).




Tx for the attempt, but I don't think VC per se will suffice -- somebody
needs to build or find a suitable version of GMP for Windows, too.
Yes indeed. I took a look at the gmplib source distro, but it would mean
installing way too much other stuff to be practical right now,
unfortunately.

As a consolation prize you might like to know that it appears to build
and pass all tests happily under Cygwin. Sorry I can't be more help.

regards
Steve
 
C

casevh

Everything works fine with v1.16. I'm sure I was doing something wrong.
I shouldn't be testing that late at night. ;-)

It looks like the warning about "tp_compare" has been fixed.

I will try to build a version for Windows, but that may take me a day
or two.

Thanks for the updates to gmpy!

Case
 
A

Alex Martelli

Everything works fine with v1.16. I'm sure I was doing something wrong.
I shouldn't be testing that late at night. ;-)

It looks like the warning about "tp_compare" has been fixed.

I didn't touch tp_compare specifically, so the fix must have been a side
effect (?).
I will try to build a version for Windows, but that may take me a day
or two.

Great, pls let me know when you do (particularly if you're willing to
make your build available to others -- if you send it to me I can make
it downloadable from sourceforge).

Thanks for the updates to gmpy!

You're welcome, and thank YOU for the feedback &c.


Alex
 
C

casevh

Alex said:
I didn't touch tp_compare specifically, so the fix must have been a side
effect (?).


Great, pls let me know when you do (particularly if you're willing to
make your build available to others -- if you send it to me I can make
it downloadable from sourceforge).



You're welcome, and thank YOU for the feedback &c.


Alex
I made a successful installer for Windows using Mingw32 and Python 2.4.
I needed to edit setup.py to list gmp as a required library.

if sys.version.find('MSC')==-1:
gmpy_ext = Extension('gmpy', sources=['src/gmpy.c'],
# library_dirs=['/usr/local/lib'],
libraries=['gmp'])
else:
gmpy_ext = Extension('gmpy', sources=['src/gmpy.c'],
include_dirs=['./src'],
libraries=['gmp']) # I added libraries!

Will you be updating the information in setup.py file?

Tomorrow, I'll recreate my build process on another computer. I am
willing to create Windows installers.

Which versions of Python do you want to support?

Do you want versions that include GMP tailored for specific processors?


With GMP 4.1.4 compiled for pentium3, and running on a 1.8Ghz Pentium
M, I'm able to calculate the decimal form of 2^25964951 (the 43rd
Mersenne prime) in 10 seconds. The prior gmpy release takes just over
14 seconds. Without gmpy, Python takes 25.4 seconds. On an Athlon
MP2800+ (2.133Ghz) with GMP compiled for that processor, I can do it in
6.6 seconds using gmpy and 22.4 seconds without gmpy. I'm working with
blocks of 1000 digits and using a combination of Toom-Cook and
Nussbaumer convolution to perform the multiplies and squares.

I did very that the tp_compare errors are fixed. I removed the warnings
filter in my code and the warning did occur with the old gmpy but did
not occur with my version.

Case
 
A

Alex Martelli

I made a successful installer for Windows using Mingw32 and Python 2.4.

Great, thanks.
I needed to edit setup.py to list gmp as a required library.

if sys.version.find('MSC')==-1:
gmpy_ext = Extension('gmpy', sources=['src/gmpy.c'],
# library_dirs=['/usr/local/lib'],
libraries=['gmp'])
else:
gmpy_ext = Extension('gmpy', sources=['src/gmpy.c'],
include_dirs=['./src'],
libraries=['gmp']) # I added libraries!

Will you be updating the information in setup.py file?

Done, in the current CVS version.
Tomorrow, I'll recreate my build process on another computer. I am
willing to create Windows installers.
Wonderful!

Which versions of Python do you want to support?

I have tested gmpy with 2.3 and 2.4 on Mac, and those two and also 2.2
on Linux. I think supporting 2.2 with a Windows download is probably
unneeded, but 2.4 is a must and I suspect 2.3 would be nice...
Do you want versions that include GMP tailored for specific processors?

My gut reaction here is that people with special processors, Windows,
and demanding performance needs should probably get their own
development environments and build GMP and gmpy accordingly.

Any opinions from the public on this one...?
With GMP 4.1.4 compiled for pentium3, and running on a 1.8Ghz Pentium
M, I'm able to calculate the decimal form of 2^25964951 (the 43rd
Mersenne prime) in 10 seconds. The prior gmpy release takes just over
14 seconds. Without gmpy, Python takes 25.4 seconds. On an Athlon
MP2800+ (2.133Ghz) with GMP compiled for that processor, I can do it in
6.6 seconds using gmpy and 22.4 seconds without gmpy. I'm working with
blocks of 1000 digits and using a combination of Toom-Cook and
Nussbaumer convolution to perform the multiplies and squares.

Sounds quite decent -- about a 2.5 to 3+ times speedup wrt Python, and
some speedup wrt gmpy 1.0 (all GMP's merit -- I didn't address
performance aspects at all in this delta). Just out of curiosity: what
performance do you get on the Athlon with a pentium3-compiled GMP?

I did very that the tp_compare errors are fixed. I removed the warnings
filter in my code and the warning did occur with the old gmpy but did
not occur with my version.

Excellent. Sounds like an "all systems go"...!-)


Thanks,

Alex
 
C

casevh

Will you be updating the information in setup.py file?
Done, in the current CVS version.

I will grab the CVS version and create installers.
I have tested gmpy with 2.3 and 2.4 on Mac, and those two and also 2.2
on Linux. I think supporting 2.2 with a Windows download is probably
unneeded, but 2.4 is a must and I suspect 2.3 would be nice...

I will definately build for 2.3 and 2.4.
My gut reaction here is that people with special processors, Windows,
and demanding performance needs should probably get their own
development environments and build GMP and gmpy accordingly.

Any opinions from the public on this one...?

Unless there is a demand for compatibilty with older processors
(Pentium, Pentium Pro, Pentium II), I will build for Pentium 3.
Sounds quite decent -- about a 2.5 to 3+ times speedup wrt Python, and
some speedup wrt gmpy 1.0 (all GMP's merit -- I didn't address
performance aspects at all in this delta). Just out of curiosity: what
performance do you get on the Athlon with a pentium3-compiled GMP?
I'll try to find out. Unfortunately, my Athlon box won't run Windows.
;-)
Thanks,

Alex

You're welcome,

Case
 
N

Nick Craig-Wood

I tested gmpy cvs as of now on Debian/testing/x86 with python2.3. It
compiled perfectly, ran all of its unit tests and also all my test
programs - Well done!

My test program seemed to run at the same speed with both versions
(not suprising really since both are using the same libgmp.so on the
system).

Thanks and look forward to the release

Nick
 
A

Alex Martelli

Nick Craig-Wood said:
I tested gmpy cvs as of now on Debian/testing/x86 with python2.3. It
compiled perfectly, ran all of its unit tests and also all my test
programs - Well done!
Thanks!

My test program seemed to run at the same speed with both versions
(not suprising really since both are using the same libgmp.so on the
system).

Yep, as I said any speed differences should be due to the underlying
GMP, since gmpy.c itself has not undergone any speed-related change.

Thanks and look forward to the release

Thank YOU for the feedback!


Alex
 
A

Alex Martelli

I've created Windows binaries for Python 2.3 and 2.4. It should be
compatible with PentiumPro or later processors.

Thanks! I hope to package up a release early next week, and to include
these.


Alex
 
M

mensanator

Alex said:
Thanks! I hope to package up a release early next week, and to include
these.


Alex

I downloaded the binaries and ran some Big Arithmetic tests:


First, I wanted to see how version 1.0 handled the test which
is a typical problem for which I use gmpy. A Type [1,2] Mersenne
Hailstone is an object I encounter in my Collatz Conjecture
research. There are an infinite number of them. Every 9th (starting
from the 5th) generation 1 hailstone is a generation 2 hailstone.
Every 9th (starting from the 5th) generation 2 hailstone is a
generation 3 hailstone, etc.

In this case, a closed form equation can be used to directly find
the ith member of the kth generation. But not all hailstone types
have closed form equations. For those, I use a recursive function
that uses divm().

The test makes three passes. The first is a brute force search
through every Mesenne Number from 1 to 177150 bits. A test
determines what generation each is (most are not Type [1,2] and
evaluate to generation 0). The test prints the first occurrence of
each generation.

The second pass uses the closed form equation to directly
calculate the 1st member of each generation. These results must
match those found in the brute force search.

Finally, the third pass takes each hailstone found in the second
pass, calculates it's absolute offset from the first general
Type [1,2] hailstone of the corresponding generation, and calls
the recursive function to see if it calculates the same hailstone
found in pass 2 and pass 1.

==========================================

gmpy.version: 1.0 (with divm() replaced by invert())

Brute force search: gclass(2**i-1,xyz)
Find 1st Generation k Type [1,2] Mersenne Hailstone

2**5-1 generation: 1
2**29-1 generation: 2
2**245-1 generation: 3
2**2189-1 generation: 4
2**19685-1 generation: 5

7.031 seconds

Closed form: Type12MH(k,i)
Find ith, kth Generation Type [1,2] Mersenne Hailstone
using the closed form equation

2**(6*((i-1)*9**(k-1)+(9**(k-1)-1)/2+1)-1)-1

2**5-1 generation: 1
2**29-1 generation: 2
2**245-1 generation: 3
2**2189-1 generation: 4
2**19685-1 generation: 5
2**177149-1 generation: 6
2**1594325-1 generation: 7

0.657 seconds

Verify Type12MH Hailstones:
Find ith, kth Generation Type (xyz) Hailstone
using the recursive equation

(gmpy.divm(y**(k-1)-prev_gen[2],y-x,y**(k-1))/y**(k-2))*y**(k-1)+prev_gen[3]

where i=((hailstone-geni(k,1,xyz))/(y**k))+1

2**5-1 generation: 1
2**29-1 generation: 2
2**245-1 generation: 3
2**2189-1 generation: 4
2**19685-1 generation: 5
2**177149-1 generation: 6
2**1594325-1 generation: 7

0.078 seconds

==========================================
NOTE: Brute force search could not reach generation 6 without
locking up

Switching to gmpy version 1.01
==========================================

gmpy.version: 1.01 (now using divm())

Brute force search: gclass(2**i-1,xyz)
Find 1st Generation k Type [1,2] Mersenne Hailstone

2**5-1 generation: 1
2**29-1 generation: 2
2**245-1 generation: 3
2**2189-1 generation: 4
2**19685-1 generation: 5

0.579 seconds

Closed form: Type12MH(k,i)
Find ith, kth Generation Type [1,2] Mersenne Hailstone
using the closed form equation

2**(6*((i-1)*9**(k-1)+(9**(k-1)-1)/2+1)-1)-1

2**5-1 generation: 1
2**29-1 generation: 2
2**245-1 generation: 3
2**2189-1 generation: 4
2**19685-1 generation: 5
2**177149-1 generation: 6
2**1594325-1 generation: 7

0 seconds

Verify Type12MH Hailstones:
Find ith, kth Generation Type (xyz) Hailstone
using the recursive equation

(gmpy.divm(y**(k-1)-prev_gen[2],y-x,y**(k-1))/y**(k-2))*y**(k-1)+prev_gen[3]

where i=((hailstone-geni(k,1,xyz))/(y**k))+1

2**5-1 generation: 1
2**29-1 generation: 2
2**245-1 generation: 3
2**2189-1 generation: 4
2**19685-1 generation: 5
2**177149-1 generation: 6
2**1594325-1 generation: 7

0.015 seconds

==========================================
NOTE: Wow, what an improvement!
How far can I go now?
==========================================

gmpy.version: 1.01

Brute force search: gclass(2**i-1,xyz)
Find 1st Generation k Type [1,2] Mersenne Hailstone

2**5-1 generation: 1
2**29-1 generation: 2
2**245-1 generation: 3
2**2189-1 generation: 4
2**19685-1 generation: 5
2**177149-1 generation: 6

31.92 seconds

Closed form: Type12MH(k,i)
Find ith, kth Generation Type [1,2] Mersenne Hailstone
using the closed form equation

2**(6*((i-1)*9**(k-1)+(9**(k-1)-1)/2+1)-1)-1

2**5-1 generation: 1
2**29-1 generation: 2
2**245-1 generation: 3
2**2189-1 generation: 4
2**19685-1 generation: 5
2**177149-1 generation: 6
2**1594325-1 generation: 7
2**14348909-1 generation: 8
2**129140165-1 generation: 9

0.234 seconds

Verify Type12MH Hailstones:
Find ith, kth Generation Type (xyz) Hailstone
using the recursive equation

(gmpy.divm(y**(k-1)-prev_gen[2],y-x,y**(k-1))/y**(k-2))*y**(k-1)+prev_gen[3]

where i=((hailstone-geni(k,1,xyz))/(y**k))+1

2**5-1 generation: 1
2**29-1 generation: 2
2**245-1 generation: 3
2**2189-1 generation: 4
2**19685-1 generation: 5
2**177149-1 generation: 6
2**1594325-1 generation: 7
2**14348909-1 generation: 8
2**129140165-1 generation: 9

8.766 seconds

==========================================
NOTE: Brute force can now reach generation 6, but won't try
anything higher.
Generation 9 is a 129 million bit number!
Can we get to generation 10?
==========================================

gmpy.version: 1.01

Brute force search: gclass(2**i-1,xyz)
Find 1st Generation k Type [1,2] Mersenne Hailstone

2**5-1 generation: 1
2**29-1 generation: 2
2**245-1 generation: 3
2**2189-1 generation: 4
2**19685-1 generation: 5
2**177149-1 generation: 6

32.14 seconds

Closed form: Type12MH(k,i)
Find ith, kth Generation Type [1,2] Mersenne Hailstone
using the closed form equation

2**(6*((i-1)*9**(k-1)+(9**(k-1)-1)/2+1)-1)-1

2**5-1 generation: 1
2**29-1 generation: 2
2**245-1 generation: 3
2**2189-1 generation: 4
2**19685-1 generation: 5
2**177149-1 generation: 6
2**1594325-1 generation: 7
2**14348909-1 generation: 8
2**129140165-1 generation: 9
2**1162261469-1 generation:10

51.83 seconds

Verify Type12MH Hailstones:
Find ith, kth Generation Type (xyz) Hailstone
using the recursive equation

(gmpy.divm(y**(k-1)-prev_gen[2],y-x,y**(k-1))/y**(k-2))*y**(k-1)+prev_gen[3]

where i=((hailstone-geni(k,1,xyz))/(y**k))+1

2**5-1 generation: 1
2**29-1 generation: 2
2**245-1 generation: 3
2**2189-1 generation: 4
2**19685-1 generation: 5
2**177149-1 generation: 6
2**1594325-1 generation: 7
2**14348909-1 generation: 8
2**129140165-1 generation: 9
Traceback (most recent call last):
File "C:\Python23\user\gmpy ver 1.01\MHtest.py", line 64, in ?
i = (h-a0)/(xyz[1]**g)

==========================================
NOTE: No, ran out of virtual memory. Probably due to the
recursion and having to store the pass 2 numbers.

I used to have a sign in my lab saying
"Test to Destruction"
But the paranoid schizophrenic field engineer
got freaked out by it and the boss made me
take it down.
==========================================


Excellent work guys!

Not only is the divm() bug fixed but it looks like we got a
significant performance increase.
 
C

casevh

What processor are you running?

I only have Windows running on an old Pentium 3. It is easy for me to
build a version that will running on almost any recent processor. I'm
willing to try and override the CPU detection and make a processor
specific build for you. I won't be able to test it, though.

Thanks for the testing!

Case
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,797
Messages
2,569,647
Members
45,377
Latest member
Zebacus

Latest Threads

Top