Step 1 : If you haven't installed
XCODE. Download and Install
XCODE
Step 2 :
Install Open MPI. Download the latest stable release of Open MPI from the
Open Source High Performance Computing website.
Step 3:
Open terminal and Go to the downloaded directory
Extract the downloaded archive :
tar -zxvf openmpi-1.6.5.tar.gz
Open terminal and Go to the extracted directory:
cd /path/to/extracted/openmpi-1.6.5
Run the following commands
./configure --prefix=/usr/local
make all
sudo make install
Step 4: Add OpenMPI path to your path, run the following commands
export
PATH=/usr/local/openmpi/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
Step 5: Compile your C/C++ program
For C:
mpicc -o myProgExe myProg.c
For C++:
mpic++ -o myProgExe myProg.cpp
Step 6: Run, where -np is the number of processor to run on.
mpirun -np 8 myProgExe