Difference between revisions of "Building the gmp"

From ApCoCoAWiki
(→‎The gmp vs. the Intel Math Kernel Library: correct some spelling, add info on linker option)
(→‎Better Assembly support for gmp on AMD64: update info for the 4.2.x release)
Line 41: Line 41:
 
The 4.1 release of the gmp doesn't provide assembly support for Opterons, hence performace is not as good as it could be. There are plans for better support on Opteron  in the next major gmp release. Until then you might check out [http://www.lix.polytechnique.fr/Labo/Pierrick.Gaudry/mpn_AMD64/ this webpage] by Pierrick Gaudry for a special Opteron build.
 
The 4.1 release of the gmp doesn't provide assembly support for Opterons, hence performace is not as good as it could be. There are plans for better support on Opteron  in the next major gmp release. Until then you might check out [http://www.lix.polytechnique.fr/Labo/Pierrick.Gaudry/mpn_AMD64/ this webpage] by Pierrick Gaudry for a special Opteron build.
  
 +
The issue has been resolved in the 4.2.x release of the gmp, hence the  patch isn't needed any more.
  
 
=Better Assembly support for gmp on Apple's G5=
 
=Better Assembly support for gmp on Apple's G5=

Revision as of 13:29, 18 December 2006

Versions of the gmp

We currently use the 4.2.1 release for building and testing. The 4.1.4 release still works at the moment, but we might drop support for that release soon.

Build Options for the gmp

There are many different possible configurations when building the gmp. One that is very important to CoCoA is how to allocate memory in the gmp since large numbers can overflow the stack quite easily. For a general overview for the gmp 4.1 have a look at http://www.gnu.org/software/gmp/manual/html_node/Build-Options.html.

So when configuring the gmp make sure that you choose

--enable-alloca=no

in order to use malloc and thereby using the heap instead of the stack. This entails a small (roughly 2% or so) performance penalty but at least your computation finishes instead of segfaulting for mysterious reasons.

Possible Workaround for Stack Size Issue

If you cannot recompile your gmp a workaround is to set your stack to unlimited or a larger value than you are currently using. This should be possible on most Linux/Unix systems. It actually depends on you installation whether there are hard limits or not. For more details check out man limit or man ulimit depending on the shell you are using or check with your friendly system administrator. On MacOSX 10.4 and higher the stack size is limited to 64 MB and you need root privileges to change that. On Windows we are currently not aware of a possibilty of changing stack size during runtime. One can set the size of the stack a binary uses during compile time.

The gmp vs. Windows

The standard gmp release (4.2.1 at the moment) does not compile on Windows when using the Microsoft Visual Studio compiler. While it is technically possible the build the non-optimized C version of the gmp it is only a stop gap measure since one looses lots of performace when going this route. The main culprit the gas style assembly syntax in the gmp. One way around this is to use nasm style assembly syntax. A complete Visual Studio project to build an optimized gmp can be found on Building gmp and ,mpfr with Microsoft Visual Studio 2005 provided by Brian Gladman. Another possible source for a prebuild optimized gmp library can be found at deltatrinity.dyndns.org.

The easiest way around this whole mess is to use the MinGW tools which compile the gmp out of the box just fine.

The gmp vs. the Intel Math Kernel Library

The Intel MKL comes with its own implementation of the gmp. So when trying to link the the CoCoALib against the gmp as well the Intel MKL the linker fails due to mkl_ia32.a (which is 40MB) containing the some symbols twice. The solution is to go into the builder directory of the Intel MKL and create a custom dynamic lib with only BLAS and Lapack symbols. On Linux do:

cat blas_list lapack_list > user_list
make ia32 name=libmklspecial.so export=user_list

Now you can link against that library with -lmklspecial.

You have to do something analog on Windows as well as MacOSX if you would like to use the Intel MKL.

gmp binding for scripting languages

If you like to use the CoCoA Library from your fourite scripting language, i.e. if you need to write bindings, you also need access to the buildin native gmp data structures. To make things easy for you we provide links for certain scripting languages:

  1. C# bindings from the DOTGnu project.
  2. mxNumber and gmpy for python


Better Assembly support for gmp on AMD64

The 4.1 release of the gmp doesn't provide assembly support for Opterons, hence performace is not as good as it could be. There are plans for better support on Opteron in the next major gmp release. Until then you might check out this webpage by Pierrick Gaudry for a special Opteron build.

The issue has been resolved in the 4.2.x release of the gmp, hence the patch isn't needed any more.

Better Assembly support for gmp on Apple's G5

There are patches that provide some faster routines especially for Apple's G5. The patches can be found in the gmp-devel archive. They have been tested with the 4.1.4 and the 4.2 prerelease.

Better Assembly support for gmp on Intel's Core Duo

Check out Jason Worth Martin's homepage for a patch for Mac OSX and Linux. Support for Windows currently doesn't appear to exist.