Difference between revisions of "Install MPI on a MacBook"

From dftwiki3
Jump to: navigation, search
(Compile and Run)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 12:43, 7 October 2013 (EDT)
+
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 12:43, 7 October 2013 (EDT)<br />
 +
updated --[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 16:50, 4 March 2017 (EST)
 
----
 
----
 +
{| style="width:100%;"
 +
|
 +
__TOC__
 +
|
 +
[[Image:OpenMPILogo.png|right|200px]]
 +
|}
 +
 +
<br />
 +
<br />
 +
<br />
 +
<br />
  
 
=Download=
 
=Download=
* from [http://www.open-mpi.org/software/ompi/v1.6/ http://www.open-mpi.org/software/ompi/v1.6/]
+
<br />
* get the tar file openmpi-1.6.5.tar.gz (or whichever latest version is the current one).
+
* from [https://www.open-mpi.org/software/ompi/v2.0/ https://www.open-mpi.org/software/ompi/v2.0/]
 +
* get the tar file openmpi-2.0.2.tar.bz2 (or whichever latest version is the current one).
 +
 
  
 +
<br />
 
=Extract and Install=
 
=Extract and Install=
 +
<br />
 
* Assume that the downloaded file is in your ~/Downloads directory
 
* Assume that the downloaded file is in your ~/Downloads directory
 
* Just follow the directions in the INSTALL file, which are summarized below.  The installation was done on *my* machine, and assumes the user is '''thiebaut'''.  Change and plug-in your own user name.
 
* Just follow the directions in the INSTALL file, which are summarized below.  The installation was done on *my* machine, and assumes the user is '''thiebaut'''.  Change and plug-in your own user name.
Line 15: Line 31:
 
  mkdir mpi/download
 
  mkdir mpi/download
 
  cd mpi/download
 
  cd mpi/download
  mv ../Downloads/openmpi-1.6.5.tar.gz .
+
  mv ../Downloads/openmpi-2.0.2.tar.bz2  .
  tar -xzvf openmpi-1.6.5.tar.gz
+
  tar -xzvf openmpi-2.0.2.tar.bz2
  cd openmpi-1.6.5
+
  cd openmpi-2.0.2
 
  ./configure --prefix=/Users/thiebaut/mpi/    (''replace thiebaut by your user name on your Mac)
 
  ./configure --prefix=/Users/thiebaut/mpi/    (''replace thiebaut by your user name on your Mac)
 
    
 
    
The last command will take 10 minutes or so.  When it is done, make all and install
+
* The last command will take 10 minutes or so.  When it is done, make all and install
  
 
  make all install
 
  make all install
  
This last command takes a while as well...
+
* This last command takes a while as well...
 +
<br />
  
 
==Update your path==
 
==Update your path==
 +
<br />
  
*
 
 
* edit the '''.bash_profile''' file in your main account directory.
 
* edit the '''.bash_profile''' file in your main account directory.
 
* locate the line that reads  '''PATH=...'''
 
* locate the line that reads  '''PATH=...'''
Line 43: Line 60:
 
* You are done!
 
* You are done!
  
 +
<br />
 
=Testing=
 
=Testing=
 +
<br />
 
Create this file in the directory of your choice, and call it '''helloWorld.c''':
 
Create this file in the directory of your choice, and call it '''helloWorld.c''':
 
<br />
 
<br />
Line 69: Line 88:
  
 
==Compile and Run==
 
==Compile and Run==
 +
<br />
  
 
  '''mpicc -o hello helloWorld.c'''
 
  '''mpicc -o hello helloWorld.c'''

Latest revision as of 16:55, 4 March 2017

--D. Thiebaut (talk) 12:43, 7 October 2013 (EDT)
updated --D. Thiebaut (talk) 16:50, 4 March 2017 (EST)


OpenMPILogo.png





Download




Extract and Install


  • Assume that the downloaded file is in your ~/Downloads directory
  • Just follow the directions in the INSTALL file, which are summarized below. The installation was done on *my* machine, and assumes the user is thiebaut. Change and plug-in your own user name.
  • open a Terminal window, and type the following commands in it:
cd
mkdir mpi
mkdir mpi/download
cd mpi/download
mv ../Downloads/openmpi-2.0.2.tar.bz2  .
tar -xzvf openmpi-2.0.2.tar.bz2
cd openmpi-2.0.2
./configure --prefix=/Users/thiebaut/mpi/    (replace thiebaut by your user name on your Mac)
 
  • The last command will take 10 minutes or so. When it is done, make all and install
make all install
  • This last command takes a while as well...


Update your path


  • edit the .bash_profile file in your main account directory.
  • locate the line that reads PATH=...
  • right below this line, add the new line
     PATH=$PATH:/Users/thiebaut/mpi/bin/       
  • and make sure your replace thiebaut by your account name!
  • source your .bash_profile so that the new path is learnt by your system
 cd
 source .bash_profile
  • You are done!


Testing


Create this file in the directory of your choice, and call it helloWorld.c:

/* C Example */
#include <stdio.h>
#include <mpi.h>


int main (argc, argv)
     int argc;
     char *argv[];
{
  int rank, size;

  MPI_Init (&argc, &argv);	/* starts MPI */
  MPI_Comm_rank (MPI_COMM_WORLD, &rank);	/* get current process id */
  MPI_Comm_size (MPI_COMM_WORLD, &size);	/* get number of processes */
  printf( "Hello world from process %d of %d\n", rank, size );
  MPI_Finalize();
  return 0;
}


Compile and Run


mpicc -o hello helloWorld.c
mpirun -np 2 ./hello
Hello world from process 0 of 2
Hello world from process 1 of 2
  • If you see the two lines starting with "Hello world" on your screen, MPI was successfully installed on your system!