How to use mpi on Mac OS X - macos

I have been searching for a way to use mpi on my mac but everything is very advanced.
I have successfully installed open-mpi using
brew install open-mpi
I have .c files ready for compiling and running. When I type:
mpicc -o <file> <file.c>
followed by
mpirun <file>
I get
[xxxxx-MacBook-Pro.local:13623] [[44919,0],0] ORTE_ERROR_LOG: Bad
parameter in file orted/pmix/pmix_server.c at line 262
[xxxxx-MacBook-Pro.local:13623] [[44919,0],0] ORTE_ERROR_LOG: Bad
parameter in file ess_hnp_module.c at line 666
It looks like orte_init failed for some reason; your parallel process
is likely to abort. There are many reasons that a parallel process
can fail during orte_init; some of which are due to configuration or
environment problems. This failure appears to be an internal failure;
here's some additional information (which may only be relevant to an
Open MPI developer):
pmix server init failed
--> Returned value Bad parameter (-5) instead of ORTE_SUCCESS
I also get the same message when I enter:
mpirun -np 2 <file>
What am I doing wrong?

If I were you, I'd do following:
Installation of Open MPI is fairly straightforward
https://www.open-mpi.org/software/ompi/v2.0/
> tar xf openmpi-2.0.2.tar
> cd openmpi-2.0.2/
> ./configure --prefix=$HOME/opt/usr/local
> make all
> make install
> $HOME/opt/usr/local/bin/mpirun --version
mpirun (Open MPI) 2.0.2
Report bugs to http://www.open-mpi.org/community/help/
You can use super simple hello world for testing purposes
#include <mpi.h>
#include <stdio.h>
int main(int argc, char** argv) {
MPI_Init(NULL, NULL);
int rank;
int world;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &world);
printf("Hello: rank %d, world: %d\n",rank, world);
MPI_Finalize();
}
After everything is in place, simply compile and run the code
$HOME/opt/usr/local/bin/mpicc -o hello ./hello.c
$HOME/opt/usr/local/bin/mpirun -np 2 ./hello
Hello: rank 0, world: 2
Hello: rank 1, world: 2
Works perfectly fine on macOS
Update
In case you are looking for MPI related environment on macOS, I suggest checking out concept of modules.
building MPICH/OpenMPI - https://www.owsiak.org/building-opencoarrays-on-macos-everything-from-the-sources-gcc-9-2-0/
modules - https://www.owsiak.org/modules-as-a-convenient-way-of-choosing-build-chain-on-macos/

Building on the answer provided by #Oo.oO.
Install OpenMPI.
It can be installed using brew.
brew install openmpi

On some versions of Mac OS X / MacOS Sierra, the default temporary directory location is sufficiently long that it is easy for an application to create file names for temporary files which exceed the maximum allowed file name length, Which can cause this error.
so you should set the temporary directory using export TMPDIR=/tmp
more details here https://www.open-mpi.org/faq/?category=osx

If you have anaconda installed, this is the fastest option for me:
conda install mpi4py openmpi

I have noticed that during execution pmix offers an unnecesary exception of the form:
PMIX ERROR: ERROR in file gds_ds12_lock_pthread.c at line 206
To prevent this, before the execution of main file always type this on the terminal prompt :
export PMIX_MCA_gds=hash
This helps subside the pmix noice and has to be repeated every session.
Note:
The maximum number of slots that pmi allows is by default 2 in macs. A "slot" is the Open MPI term for an allocatable unit where we can
launch a process. This determines how many time we can run an instruction in a code.
To extend the number of slots carry out the following steps:
1.Create a hostfile with anyname
2.within the write:
localhost slots = <#>
where #=no. of slots needed.
while compiling write the following on the terminal prompt:
mpicc -hostfile -<filename>
While running wite the following on the terminal prompt:
mpirun -hostfile -np <#>
Although be weary of the last note,it isnt often needed and the file extention of the hostfile may become a problem with certain architectures , such as my own x86.

Related

Error while installing Boost MPI on macOS

I'm trying to install boost mpi from boost 1_78_0 on macOS, but I'm getting this error:
error: Unable to find file or target named
error: '/mpi//mpi'
error: referred to from project at
error: 'libs/mpi/build'
I've tried various different entries in my project-config.jam:
using mpi ;
using mpi : /Users/nick/sfw/openmpi-4.1.2/bin/mpicxx ;
and putting the mpi bin directory in my PATH. I've run ./b2 with debugging output and it looks like my mpicxx is being used, but I'm still getting the error. I've installed this successfully many times on linux using the using mpi directive without a problem.
thanks.

ScaLapack installation fails with its auto installer package on Centos7 but it succeeds on Centos 6.7. Why?

I am trying to install the ScaLAPACK with the help of Python-based installer available at http://www.netlib.org/scalapack/scalapack_installer.tgz on CentOS 7(64bit). It is installing successfully but failing in test routines step and showing the error. how to fix it?
The command used for the compilation is as follows:
./setup.py --prefix=/home/tools/scalapack --blaslib="-L/usr/lib64 -lblas" --lapacklib="-L/usr/lib64 -llapack -lblas" --mpiincdir=/opt/apps/mpich32/include --fcflags="-fbounds-check" --mpirun=mpirun --mpicc=mpicc --mpif90=mpif90
The process description is as follows
Installing scalapack-2.0.2 ...
Writing SLmake.inc... done.
Compiling BLACS, PBLAS and ScaLAPACK... done
Getting ScaLAPACK version number... 2.0.1
Installation of ScaLAPACK successful.
(log is in /home/tools/scalapack_installer/build/log/scalog )
Compiling test routines... done
Running BLACS test routines... done
Running PBLAS test routines...
PBLAS: error running PBLAS test routines xcpblas2tst
PBLAS: Command mpirun -np 4 ./xcpblas2tst
stderr:
****************************************
At line 1 of file ctzpad.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'herm' (-960965440/1)

Building parallel hdf5 with cygwin

I recently attempted to install parallel hdf5-1.10.1 from source with cygwin 2.8.2 and stumbled into a "SIG_SETMASK undeclared" error during make. I wanted to use h5py to write hdf files in parallel (in windows environment).
I tried to follow the instructions from https://support.hdfgroup.org/ftp/HDF5/current/src/unpacked/release_docs/INSTALL_parallel
First I ran the c version of the Sample_mpio.c and it seems it worked:
Proc 2: all tests passed
Proc 3: all tests passed
Proc 1: all tests passed
Proc 0: all tests passed
So, the first step was configure:
CC=mpicc ./configure --enable-parallel --enable-shared
and then make
However, at some point make exited with several SIG_SETMASK undeclared error messages pointing to sigsetjmp(J,N) of the #define HDsigsetjmp(J,N) sigsetjmp(J,N) part followed by in expansion of macro ... for several macros.
Since there are no separate building instructions for cygwin, like for the serial case, I thought it might be an issue of cygwin.
What is the proper way to install parallel hdf5 (and h5py) on windows?
Edit 1:
Thanks to #varro 's suggestion, setting make CFLAGS=-D_POSIX_C_SOURCE resolved the error.
Nevertheless, now make check gives a segmentation fault...
Testing testhdf5.exe
/bin/sh: line 30: 22284 Segmentation fault (core dumped) srcdir="." ./${tname} >> ${log} 2>&1

FreeBSD make error File 5.19 supports only version 12 magic files. /usr/share/misc/magic.mgc is version 8

I'm having trouble reinstalling ProFTPD on a FreeBSD 10.1 setup. The server is newly upgraded from 10.0 to 10.1. When I start the make install clean process, these warnings first shows on screen.
===> proftpd-1.3.5_4 depends on shared library: libpcre.so
/usr/share/misc/magic, 93: Warning: Printf format `l' is not valid for type `lelong' in description `, %ld pages'
...
/usr/share/misc/magic, 15118: Warning: Printf format `l' is not valid for type `belong' in description `Volume %ld,'
/usr/share/misc/magic, 15609: Warning: Current entry does not yet have a description for adding a MIME type
file: File 5.19 supports only version 12 magic files. `/usr/share/misc/magic.mgc' is version 8
[: =: unexpected operator
- not found
And after i while, the make process stops with this error:
/bin/ln -s libpcre.so.1 /usr/ports/devel/pcre/work/stage/usr/local/lib/libpcre.so.3
====> Compressing man pages (compress-man)
===> Installing for pcre-8.35_2
===> Checking if pcre already installed
===> pcre-8.35_2 is already installed
You may wish to ``make deinstall'' and install this port again
by ``make reinstall'' to upgrade it properly.
If you really wish to overwrite the old port of pcre
without deleting it first, set the variable "FORCE_PKG_REGISTER"
in your environment or the "make install" command line.
*** Error code 1
Stop.
make[3]: stopped in /usr/ports/devel/pcre
*** Error code 1
Stop.
make[2]: stopped in /usr/ports/devel/pcre
*** Error code 1
Stop.
make[1]: stopped in /usr/ports/ftp/proftpd
*** Error code 1
Stop.
make: stopped in /usr/ports/ftp/proftpd
Seems that the file /usr/share/misc/magic.mgc is of a wrong version?
This might happens when I was upgrading from 10.0-RELEASE-p12 to 10.1-RELESE-p1?
If i run make install clean of the ProFTP port, and disable support for pcre, the process and install is successful.
But I believe that something is still broken?
My programming skills are limited, and also this level of error.
Please let me know if you have any ideas,
Thanks,
First of all, proftpd 1.3.5 is available as a binary package, it's much simpler to install it that way (pkg install proftpd).
Second - at first it looked like a port bug; as Etan said, there is a shell syntax error (something like '[ x == y ]' instead of '[ x = y ]'); those are common, and ports contain patches to fix those. However, there is a binary package, and packages are built from ports ("make package"), so port obviously does work on package build machines. So it's probably something specific to your environment.
If you really want to build from ports, try this: first, reinstall pcre. For some reason it had to be rebuilt, but failed to install, because it's already installed. So, "cd /usr/ports/*/pcre && make clean all deinstall reinstall". That should get rid of the second error. Then go back to "../*/proftpd" and see how far it goes.
But really, I'd try packages first. They have nothing in common with old pkg_add system, and are really nice.
freebsd-update diff for FreeBSD-SA-14:28.file seems wrong, and it breaks file(1).
Therefore simply pkg install file will be a workaround.

PLR Installation on Mac Lion

I am trying to install PL/R 8.3.0.13.1 on my MacBook Pro running OS X 10.7.5, Postgres 9.2 and R 2.15.2. I have found on the web a nice step-by-step guide for Windows but I can't find anything similar for Mac.
I got stuck when I run this command [as official documentation] ( http://www.joeconway.com/plr/doc/plr-install.html ):
USE_PGXS=1 make
Output:
make: pkg-config: Command not found
make: pkg-config: Command not found
make: pkg-config: Command not found
make: pkg-config: Command not found
make: pkg-config: Command not found
*** Cannot build PL/R because R_HOME cannot be found.
*** Refer to the documentation for details.
Clearly that means I need to create somehow R_HOME, variable and/or location...
Any idea how to do it?
The error message is actually a bit confusing. If you look at the Makefile of PL/R, the logic is that it uses R_HOME to find R when set, otherwise it tries pkg-config. You have neither set, so it bails out.
I recommend going the pkg-config route if possible. The R_HOME route appears to assume an R installation scheme that might not be universally applicable. Perhaps it applies to builds straight from source.
The above applies to all platforms. Now on OS X, it depends on how you installed R. For example, if you used MacPorts, it would go something like this:
sudo port install pkgconfig
sudo port install R
and then build PL/R itself:
make USE_PGXS=1
But that will break because PL/R does not expect that MacPorts separates the R headers into two separate directories (architecture-dependent and -independent I suppose).
Homebrew might work better, but the principle is the same.
You need to figure out what you should set your PLR environment R_HOME variable. In a terminal session I get this
computername:~ username$ R RHOME #only enter stuff after"$"
/Library/Frameworks/R.framework/Resources
This is at the bottom of that page you linked to:
"Tip: R_HOME must be defined in the environment of the user under which PostgreSQL is started, before the postmaster is started. Otherwise PL/R will refuse to load. See plr_environ(), which allows examination of the environment available to the PostgreSQL postmaster process. "
This is from a webpage describing the problem and offering a fix:
To fix: Add a "R_HOME = '/usr/lib/R' " to /etc/postgresql/version/cluster/environmen
Example Fix for version 8.1:
$ sudo -s
# echo -e "\nR_HOME = '/usr/lib/R'" >> /etc/postgresql/8.1/main/environment
# exit
To Test:
$ sudo /etc/init.d/postgresql-8.1 restart
$ sudo -u postgres psql plr_test
plr_test=# select test();
test
------

Resources