Monday, April 30, 2007

If you need hypre on your Mac!

[This piece was originally written for the hypre support mailing list. I guess this can be of some use to people in the same situations, so I also post it here. If you don't understand what this is all about, you can visit the hypre webpage at LLNL, or you can just move on...]


Hi hypre-list,

As far as I can tell, MacOSX (Darwin) is not supported by hypre. We are however building a piece of sotware at Simula Research Lab, Norway, where we have added hypre as one of the dependenices (mainly for BoomerAMG), and since we need to support MacOSX, I went through the necessary steps for building hypre on MacOSX. I share it on this list as plain text now. If you in the future want to support Mac, and want help with testing or anything (patches?), just contact me!

I have to admit, some of my changes are a bit hack'y, my motivation was to get things going; I'll see if I can clean up things later. For reference, I am working with hypre-2.0.0 as downloaded from http://www.llnl.gov/casc/hypre/software.html in mid-april 2007.

This is how I run configure:
LDFLAGS="-framework vecLib -flat_namespace" CXX=g++-4 F77=gfortran ./configure --without-MPI --enable-shared --prefix=$HOME/software/hypre --without-fei --without-superlu --without-mli --with-blas --with-lapack


* First, I needed to add a "Darwin" section in the script src/configure, around line 9885:
---8<---
Darwin*) FFLAGS="${FFLAGS} -fno-common -fPIC"
CFLAGS="${CFLAGS} -fno-common -fPIC"
CXXFLAGS="${CXXFLAGS} -fno-common -fPIC"
BUILD_F77_SHARED="${F77} -flat_namespace -dynamiclib -undefined dynamic_lookup"
BUILD_CC_SHARED="${CC} -flat_namespace -dynamiclib -undefined dynamic_lookup"
BUILD_CXX_SHARED="${CXX} -flat_namespace -dynamiclib -undefined dynamic_lookup"
;;
---8<---

* Next problem was with multiple definitions of symbol 'final_innerprod_result', which appear as a global symbol in both src/struct_mv/struct_innerprod.c and src/struct_mv/struct_overlap_innerprod.c. To fix this, I changed the symbol to 'final_overlapinnerprod_result' in src/struct_mv/struct_overlap_innerprod.c.

* The common way to use blas and lapack on MacOSX is with the '-framework vecLib' LDFLAG. Because of this, the variables 'LAPACKLIBDIRS' and 'BLASLIBDIRS' in config/Makefile.config contains 'null' after finished configure. This is probably something that should be fixed in config/Makefile.config.in or in the configure script, but for now I just removed 'null' such that those variables read:

LAPACKLIBDIRS =
BLASLIBDIRS =

* There are some paths that seems to be hardcoded that end up in LDFLAGS in Makefile.config; after configure I have '-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.3' in there. On Darwin, gcc exit with an error if non-existent directories are passed in with -L flag, so this path must be removed. Also, /usr/apps/libs and /lib are in there. I removed all three in the configure script.

* On Darwin, dynamic libs should have the suffix .dylib, not .so. Unfortunately, .so is hardcoded into the hypre buildsystem. I tried to do something such that the same buildsystem could do both .so and .dylib, based on platform, but it took more effort than the hour I was willing to spend :) Renaming the compiled .so into .dylib seems to be sufficient, at least to compile and run some of the tests. So, while this is something that have to be fixed if Darwin is to be supported, it is not a showstopper.

As far as I can tell from the notes I made during my work on this, you'll have a working hypre on MacOSX after working through these steps.

Hope this can be of some help!

1 comment:

Anonymous said...

hi,
i am a student in the USA, my name is nancy. i recently downloaded hypre on (ubuntu OS)-my laptop.
i need help as i am unable to figure out how to make it work.
i learnt unix 9 years back and haven't worked with it since then.
i am completely lost.
please help me. my email id is nancy61@ymail.com
thanks