Difference between revisions of "MPI Hello World"

Jump to navigation Jump to search
218 bytes added ,  00:07, 21 December 2022
no edit summary
 
(2 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, len;
char version[MPI_MAX_LIBRARY_VERSION_STRING];
 
MPI_Init(&argc, &argv);
</nowiki>
 
and keep adding lines until you get to <tt> pnode40pnode64 slots=4 max_slots=8 </tt>.
 
The next step assumes you have set up your ssh keys as described in [[Cluster SSH Accessaccess]]
 
With 4064 nodes listed in your <tt> cluster_hosts </tt> file, run your program again with
 
mpirun --hostfile cluster_hosts ./hello_mpi
 
You should see the output shown below, which is 160256 lines long, four responses from each host, one for each core described.
 
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>

Navigation menu