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 https://computing.llnl.gov/tutorials/mpi/ Substitute any LANL-specific instructions by ours for math-compute.

Contents

Exercise 1

Following https://computing.llnl.gov/tutorials/mpi/exercise.html 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:

wget https://computing.llnl.gov/tutorials/mpi/samples/Fortran/mpi_hello.f

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 https://computing.llnl.gov/tutorials/mpi/exercise.html and scroll down.

Suggestion: do not look at the solution, look at a simpler example https://www.mcs.anl.gov/research/projects/mpi/tutorial/gropp/node50.html 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: https://github.com/janmandel/fortran90_test

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox