MPI tutorial

From CCM
Jump to: navigation, search

See how to use math-compute for the basics of building and running MPI programs in our environment.

We will be using the MPI tutorial from LANL at Substitute any LANL-specific instructions by ours for math-compute.


Exercise 1

Following with changes for our environment.

Compile and run MPI program

Make a directory in your account on Math compute cluster for the exercise and cd there. Find mpi_hello.f, right click on it and copy the link. Then back in your terminal window paste the link on the line to copy the file:


Compile the file and submit, following the instructions for Math compute cluster.

Identify the components of the MPI "Hello world" program

  • Use the appropriate MPI include file
  • Identify task 0 as the "master" task
  • Initialize the MPI environment
  • Get the total number of tasks
  • Get the task's rank (who it is)
  • Get the name of the processor it is executing on
  • Print a hello message that includes its task rank and processor name
  • Have the master task alone print the total number of tasks
  • Terminate the MPI environment

Exercise 2

See and scroll down.

Suggestion: do not look at the solution, look at a simpler example first: send a single message to another node that receives it.

Exercise 3

Using mpi_allreduce.

You can do almost everything with just these 4: mpi_send, mpi_receive, mpi_allreduce, and mpi_bcast.

Exercise 4

Graduating to fortran 90:

Personal tools