370CT: Distributed Programming - 2
Dr Carey Pridgeon
Created: 2017-03-08 Wed 18:01
Printing out hostnames
- In OpenMP we can print the Id of the thread we are currently in.
- MPI lets us do the same, only for compute nodes. We will start by doing this.
- To try this out you will need to be able to compile a program to run using the
- Log into Nostromo, create a folder for this work, then using wget, fetch the
files listed in exercise sheet d2.
- Once you have them, use the code in the sheet to write the program you need to
complete this exercise.
- This exercise just involved generating fairly trivial data on the target node,
which isn't really how we use clusters. We need to process data on the
- To do this we need to send data to the nodes, and retreive it.
- MPI can't actually manipulate datatypes as defined for specific
languages. It has it own, and converts to and from those. You won't
use all of them, or need to know them, but here they are.
MPI Datatypes - 2
||unsigned long int
MPI Datatypes - 3
MPI Datatypes - 4
Structs and MPI
- MPI does not do Objects at all, nor can it do structs, but it can transform
structs into its own equivilent packed multi type container.
- But that's getting a bit ahead of ourselves. We will cover that next week in
- For now lets step back and focus on a simple INT to send from one node to
- After we've done that we'll cover converting to and from C++ datatypes and
- A computer (or compute node)'s position in an MPI heirarchy is its rank, which
is an integer from 0 to n.
- We can use this rank in our program logic, as the exercise we are about to
follow will demonstrate. The first exercise did too, but not as explicitelly.
- Specifically we can set code that will only be executed on a particular node.
- Note that this is different from OpenMP, where we had no ability to to state
what code ran in what thread.
Send and Receive
- For our first exercise where we manipulate data across the cluster, follow the
directions in exercise d3.
- the data are sent from one node and received by another node, with the code to
do the sending and receiving only executing if we are on the correct node.