README.md 3.75 KB
Newer Older
Philip Carns's avatar
Philip Carns committed
1
# Mochi Boot Camp Session 3: SSG
2

Shane Snyder's avatar
Shane Snyder committed
3
4
5
6
7
8
9
10
Please refer back to documentation from
[Session 2: Hands-on](sessions/s2-hands-on/README.md) for general details on
logging onto JLSE, installing Mochi software, and running jobs. We will build
on your Spack environment from that session, additionally installing SSG before
attempting to run and modify an SSG example.

## Installing SSG

Shane Snyder's avatar
Shane Snyder committed
11
Run the following to download, compile, and install SSG:
Shane Snyder's avatar
Shane Snyder committed
12
13

```
Shane Snyder's avatar
Shane Snyder committed
14
spack install ssg
Shane Snyder's avatar
Shane Snyder committed
15
16
17
18
19
20
21
22
```

Note that this SSG installation depends on MPI, with Spack able to identify
an existing mpich installation on the system.

To load the SSG module, run the following:

```
Shane Snyder's avatar
Shane Snyder committed
23
24
25
26
27
28
29
30
spack load -r ssg
```

... and again inspect to confirm SSG, Margo, etc. modules have been loaded in
your environment with:

```
module list
Shane Snyder's avatar
Shane Snyder committed
31
32
```

Shane Snyder's avatar
Shane Snyder committed
33
34
## Building and running the SSG example

Shane Snyder's avatar
Shane Snyder committed
35
36
37
As an example demonstration of SSG, we have developed a simple token ring
application. In this example, a group of processes is excecuted using MPI,
with the MPI communicator used to create an SSG group. Using group rank
Shane Snyder's avatar
Shane Snyder committed
38
39
information, a token is passed around the logical group ring, originating and
ending at rank 0. After each rank receives the forwarded token, it shuts down.
Shane Snyder's avatar
Shane Snyder committed
40
41
42

To build this example, run the following:

Shane Snyder's avatar
Shane Snyder committed
43
44
45
46
47
```
cd ~/bootcamp/mochi-boot-camp/sessions/s3-ssg/token-ring
make
```

Shane Snyder's avatar
Shane Snyder committed
48
49
50
51
52
53
54
55
56
Note that this builds 2 different executables: `ssg-token-ring1` and
`ssg-token-ring2`. `ssg-token-ring1` implements the token ring functionality
exactly as we have described so far: a single token is sent forward through the
ring, originating and ending at rank 0, with ranks shutting down on receipt
of the token (i.e., rank 1 shuts down first, rank 0 shuts down last).

Using your test system, try executing the example to confirm the behavior:

```
Shane Snyder's avatar
Shane Snyder committed
57
58
59
60
61
62
63
64
65
66
67
68
69
[snyder@it03 token-ring]$ mpirun -n 4 ./ssg-token-ring1
Member 0 forwarding token 48879 to 1
Member 1 got token 48879
Member 1 forwarding token 48879 to 2
Member 1 shutting down
Member 2 got token 48879
Member 2 forwarding token 48879 to 3
Member 2 shutting down
Member 3 got token 48879
Member 3 forwarding token 48879 to 0
Member 3 shutting down
Member 0 got token 48879
Member 0 shutting down
Shane Snyder's avatar
Shane Snyder committed
70
71
72
```

## Modifying the SSG example
Shane Snyder's avatar
Shane Snyder committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86

Once comfortable with the initial token ring implementation, we will
attempt to modify its behavior. Rather than having all ranks shutdown
immediately on receiving the token, we will instead have rank 0 initiate
shutdowns in  reverse-order through the ring once it receives the token. So,
assuming 4 members, once rank 0 receives the initial token, it will tell rank 3
to shutdown, who will tell rank 2 to shutdown, etc., with rank 0 shutting down
last. This requires definition of a new Margo RPC as well as some additional
logic in the existing token forwarding RPC handlers.

Executable `ssg-token-ring2` fully implements this new functionality, which can
be confirmed by executing:

```
Shane Snyder's avatar
Shane Snyder committed
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
[snyder@it03 token-ring]$ mpirun -n 4 ./ssg-token-ring2
Member 1 got token 48879
Member 0 forwarding token 48879 to 1
Member 1 forwarding token 48879 to 2
Member 2 got token 48879
Member 2 forwarding token 48879 to 3
Member 3 got token 48879
Member 3 forwarding token 48879 to 0
Member 0 got token 48879
Member 0 forwarding shutdown to 3
Member 3 forwarding shutdown to 2
Member 3 shutting down
Member 2 forwarding shutdown to 1
Member 2 shutting down
Member 1 forwarding shutdown to 0
Member 1 shutting down
Member 0 shutting down

Shane Snyder's avatar
Shane Snyder committed
105
106
107
108
109
110
111
112
113
```

As an exercise, try extending the initial token ring example to account for this
new functionality by directly modifying `ssg-token-ring1.c` and
re-building/re-running. The source code contains `XXX` markers to help point
participants to the right locations in the code to modify. Participants are also
welcome to examine the `ssg-token-ring2.c` source directly for inspiration.

Let us know if you have any questions!