113
edits
(4 intermediate revisions by one other user not shown) | |||
== MPI Hello World ==
Many parallel jobs are using [https://en.wikipedia.org/wiki/Message_Passing_Interface MPI] at the lowest level to manage parallel compute resources. You will want to successfully run this example to make sure your parallel computing environment is working properly. These instructions assume you've already set up your cluster ssh keys, as described in [[Cluster SSH access]]
This is a 'Hello World' program that will test the operation of sending jobs to remote workers.
int main(int argc, char* argv[])
{
int rank, size
MPI_Init(&argc, &argv);
Now, to run your mpi program on the cluster, you will need to create a hostfile.
First, lets create a simple hostfile that just runs four processes on the local machine
<nowiki>
</nowiki>
▲Put that line in a file called <tt>localhost </tt>.
Now run your program with that hostfile, using
mpirun --hostfile localhost ./hello_mpi
</nowiki>
and keep adding lines until you get to <tt>
The next step assumes you have set up your ssh keys as described in [[Cluster SSH
With
mpirun --hostfile cluster_hosts ./hello_mpi
You should see the output shown below, which is
Once you are able to run this program successfully, your MPI setup is working. This will be necessary before you can run other MPI-based programs, such as ipyparallel programs which use MPI.
Note: the example below was run on 40 nodes.
<nowiki>
|