Perl: Parallel::MPI::Simple with mpich MPI implementation in a clustered environment
Here is how I successfully installed the Perl module Parallel::MPI::Simple (v0.03) in a clustered environment with the mpich MPI implementation. There are other ways this could be achieved, but I present here what I’ve done.
Before proceeding, make sure the command « mpicc » is available on your system.
1. Installing Perl
On the system I have access to (and on which I have no root access), the installed version of Perl is 5.8.8, which is insufficient for my needs; notably, I need threads support. So I downloaded the 5.12.2 Perl sources and configured it for my system with:
sh Configure -Dusethreads -Dusemorebits -Dcc=icc -A ccflags='-fPIC' -Dprefix='/my_home/path' -de
then « make » (or preferably qmake with SGE), then « make install ».
2. Fixing CPAN
Don’t do the following if your cpan is working fine; however, if you get errors about file locks, here is a VERY dirty fix:
- save the following into a file, say « CPAN.pm.patch »:
--- CPAN.pm.orig 2010-10-23 11:52:01.000000000 -0400 +++ CPAN.pm 2010-10-23 11:52:39.000000000 -0400 @@ -504,6 +504,11 @@ sub _flock { my($fh,$mode) = @_; + +#EM: Dirty hack +flock $fh, $mode; +return 1; + if ( $Config::Config{d_flock} || $Config::Config{d_fcntl_can_lock} ) { return flock $fh, $mode; } elsif (!$Have_warned->{"d_flock"}++) {
- find your CPAN.pm file (mine is in $PREFIX/lib/perl5/5.12.2)
- do:
cp CPAN.pm.patch $PREFIX/lib/perl5/5.12.2/ cd $PREFIX/lib/perl5/5.12.2 patch <CPAN.pm.patch
- If you have the file « $PREFIX/lib/perl5/5.12.2/CPAN/Config.pm », delete it.
3. Installing Parallel::MPI::Simple
- Run « cpan » (procede with configuration if asked to).
- Do:
install Parallel::MPI::Simple
- If you notice well, it won’t work, because compilation will fail at some point. So exit from cpan and go to « ~/.cpan/build », and there you should see a folder named something like « Parallel-MPI-Simple-0.03-xxxxxx ». Go in it, then edit the file « Makefile » and change the line « CC = cc » for « CC = mpicc », and change the line « LD = cc » for « LD = mpicc ».
- Run « make », then « make install », and you’re done! 🙂
Commentaires récents