1
1
\page Hands_on Hands-on
2
2
3
- # Environment
4
-
5
- This hands-on has been tested on the
6
- [ Poincare] ( https://groupes.renater.fr/wiki/poincare/ ) machine but it should be
7
- easy to adapt to another machine.
8
-
9
- ## Poincare machine
3
+ # Setup
10
4
11
- You should load the file ` /gpfslocal/pub/pdi/training-env.bash ` in your
12
- environment.
13
- To do that, you must source it in every shell you open.
5
+ After %PDI \ref Installation installation, you can proceed with getting the sources for the
6
+ hands-on tutorial from [ gitlab] ( https://github.com/pdidev/PDI-hands-on ) .
14
7
15
8
``` bash
16
- $ source /gpfslocal/pub/pdi/training-env.bash
17
- (load) gnu version 7.3.0
18
- Using gnu compiler to configure openmpi wrappers...
19
- (load) openmpi version 2.1.3_gnu73
20
- (load) hdf5 version 1.10.2_gnu73_openmpi2
21
- (load) PDI version 0.4.0_gnu73_openmpi2
22
- (load) git version 2.19.1
23
- (load) cmake version 3.9.4
24
- PDI training environment loaded!
25
- $ pdi
26
- PDI training environment is available!
9
+ git clone https://github.com/pdidev/PDI-hands-on.git
27
10
```
28
11
29
- # Setup
30
-
31
- When %PDI is correctly loaded, you can proceed with getting the sources for the
32
- hands-on tutorial from
33
- [ gitlab] ( https://gitlab.maisondelasimulation.fr/PDI/PDI_hands-on ) .
34
-
12
+ To setup your environment run
35
13
``` bash
36
- git clone https://gitlab.maisondelasimulation.fr/PDI/PDI_hands-on.git
14
+ source pdi_path/share/pdi/env.bash
37
15
```
16
+ where ` pdi_path ` is your path to installed PDI directory.
38
17
39
- Setup the compilation by detecting all dependencies (MPI, paraconf, %PDI, ...)
40
- using cmake:
18
+ Next, setup the compilation by detecting all dependencies:
41
19
``` bash
42
20
cd PDI_hands-on
43
21
cmake .
@@ -47,75 +25,65 @@ Now you're ready to work, **good luck**!
47
25
48
26
# Tutorial
49
27
50
- ## Ex1. Getting started
51
-
52
- Ex1 is a simple MPI stencil code.
53
- There is no output in the code yet, so we can not see its result.
54
- Examine the source code, compile it and run it.
28
+ Compile exercise by:
29
+ ``` bash
30
+ make ex ?
31
+ ```
32
+ Run execise by:
55
33
``` bash
56
- make ex1 # compile the code
57
- llsubmit ex1.sh # run the code
34
+ pdirun mpirun -n 1 ./ex?
58
35
```
36
+ Where ` ? ` is the number of the exercise.
59
37
60
- Play with and understand the code parameters in ex1.yml
38
+ ## Ex1. Getting started
61
39
62
- Run the code with 3 MPI processes.
40
+ Ex1 is an implementation \ref heat_algorithm mentioned in \ref PDI_example.
41
+ If you didn't read it yet, it is recommended to do it before continuing.
42
+ There is no input/output operations in the code yet, so we can not see its result.
63
43
64
- ## Ex2. Now with some PDI
44
+ Play with and understand the code parameters in ` ex1.yml ` .
65
45
66
- Ex2 is the same code as ex1 with %PDI calls added.
67
- The %PDI test plugin is used to trace %PDI calls.
46
+ Set values in ` ex1.yaml ` to be able to run the code with 3 MPI processes.
68
47
69
- Examine the source code, compile it and run it.
70
- ``` bash
71
- make ex2 # compile the code
72
- llsubmit ex2.sh # run the code
73
- ```
48
+ ## Ex2. Now with some PDI
49
+
50
+ Ex2 is the same code as ex1 with %PDI calls added in main function. The
51
+ \ref trace_plugin is used to trace %PDI calls.
74
52
75
53
Add the required ` PDI_share ` and ` PDI_reclaim ` calls to match the output of
76
- ` ex2.out ` .
54
+ ` ex2.log ` file.
55
+
56
+ Notice that some share/reclaim pairs come one after the other while others are interlaced.
57
+ Is one better than the other? If you do not know the answer to this question, please endure
58
+ to exercise 5 :)
77
59
78
- Notice that some share/reclaim pairs come one after the other while others are
79
- interlaced.
80
- Is one better than the other?
81
60
82
61
## Ex3. HDF5 through PDI
83
62
84
63
Let's take the code from ex2 and make it output some HDF5 data.
85
64
No need to touch the C code here, the %PDI yaml file should be enough.
86
- We have replaced the %PDI test plugin by the Decl'HDF5 plugin.
87
-
88
- Examine the yaml, compile the code and run it.
89
- ``` bash
90
- make ex3 # compile the code
91
- llsubmit ex3.sh # run the code
92
- ```
65
+ We have replaced the \ref trace_plugin by \ref Decl_HDF5_plugin.
93
66
94
- We need to fill 2 sections in the yaml file:
67
+ Fill 2 sections in the yaml file:
95
68
* the ` data ` section to indicate to %PDI the type of the fields that are
96
69
exposed,
97
- * the ` decl_hdf5 ` for the configuration of the Decl'HDF5 plugin
70
+ * the ` decl_hdf5 ` for the configuration of \ref Decl_HDF5_plugin
98
71
99
72
Only dsize is written as of now, let's add ` psize ` and ` pcoord ` to match the
100
- content expected described in ` ex3.out ` .
73
+ content expected described in ` ex3_result.h5 ` (use ` h5dump ` command to see content of HDF5 file) .
101
74
102
75
## Ex4. Writing some real data
103
76
104
- We keep the same code and touch only the yaml file again.
77
+ In this exercise each MPI process will write its local matrix
78
+ to separete HDF5 file. Touch only the yaml file again.
105
79
106
80
This time:
107
- * we will write the real 2D data contained in ` main_field ` ,
108
- * we will use 2 MPI processes.
81
+ * write the real 2D data contained in ` main_field ` ,
82
+ * use 2 MPI processes.
109
83
110
84
Notice that we use a list to write multiple files in the decl_hdf5 section
111
85
instead of a single mapping as before.
112
86
113
- Examine the yaml, compile the code and run it.
114
- ``` bash
115
- make ex4 # compile the code
116
- llsubmit ex4.sh # run the code
117
- ```
118
-
119
87
Unlike the other fields we manipulated until now, the type of ` main_field ` is
120
88
not fully known, its size is dynamic.
121
89
By moving other fields in the ` metadata ` section, we can reference them from
@@ -128,8 +96,7 @@ In order not to overwrite it every time it is exposed, we can add a `when`
128
96
condition to restrict its output.
129
97
Only write ` main_field ` at the second iteration (when ` ii==0 ` ).
130
98
131
- Change the parallelism degree to 2 in height (don't forget to use 2 processes in
132
- ex4.sh) and try to match the expected content described in ` ex4.out ` .
99
+ Change the parallelism degree to 2 in height and try to match the expected content described in ` ex4_result.h5 ` .
133
100
134
101
## Ex5. Introducing events
135
102
@@ -141,16 +108,9 @@ Since `ii` and `main_field` are shared in an interlaced way, they are both
141
108
available at the same time and could be written without opening the file twice.
142
109
We have to use events for that.
143
110
144
- Examine the yaml and source code, compile and run.
145
- ``` bash
146
- make ex5 # compile the code
147
- llsubmit ex5.sh # run the code
148
- ```
149
-
150
- Add a ` PDI_event ` call to the code when both ` ii ` and ` main_field ` are
151
- available.
152
- With the test plugin, check that the event is indeed triggered at the expected
153
- time as described in ` ex5-trace.out ` .
111
+ Call %PDI event named ` loop ` when both ` ii ` and ` main_field ` are shared.
112
+ With the \ref trace_plugin, check that the event is indeed triggered at the expected
113
+ time as described in ` ex5.log ` .
154
114
155
115
Use the ` on_event ` mechanism to trigger the write of ` ii ` and ` main_field ` .
156
116
This mechanism can be combined with a ` when ` directive, in that case the write
@@ -159,21 +119,15 @@ is only executed when both mechanisms agree.
159
119
Also notice the extended syntax that make it possible to write data to a dataset
160
120
with a name different from the data in %PDI.
161
121
Use this mechanism to write main_field at iterations 1 and 2, in two distinct
162
- groups.
163
- Match the content as expected in ` ex5-hdf5.out ` .
122
+ groups ` iter1 ` and ` iter2 ` .
123
+ Match the content as expected in ` ex5_result.h5 ` .
164
124
165
125
## Ex6. Simplifying the code
166
126
167
127
As you can notice, the %PDI code is quite redundant.
168
128
In this exercise, we will use ` PDI_expose ` and ` PDI_multi_expose ` to simplify
169
129
the code while keeping the exact same behaviour.
170
130
171
- Examine the source code, compile it and run it.
172
- ``` bash
173
- make ex6 # compile the code
174
- llsubmit ex6.sh # run the code
175
- ```
176
-
177
131
There are lots of matched ` PDI_share ` /` PDI_reclaim ` in the code.
178
132
Replace these by ` PDI_expose ` that is the exact equivalent of a ` PDI_share `
179
133
followed by a matching ` PDI_reclaim ` .
@@ -186,57 +140,86 @@ Replace the remaining `PDI_share`/`PDI_reclaim` by `PDI_expose`s and
186
140
` PDI_multi_expose ` s.
187
141
188
142
Ensure that your code keeps the exact same behaviour by comparing its trace to
189
- ` ex6.out `
143
+ ` ex6.log ` .
190
144
191
- ## Ex7. writing a selection
145
+ ## Ex7. Writing a selection
192
146
193
- In this exercise, we will only write a selection of the data to the HDF5 file.
194
-
195
- Examine the yaml, compile the code and run it.
196
- ``` bash
197
- make ex7 # compile the code
198
- llsubmit ex7.sh # run the code
199
- ```
147
+ In this exercise, we will only write a selection (part) of the data to the HDF5 file.
200
148
201
149
As you can notice, we now independantly describe the dataset in the file.
202
150
We also use two directives to specify a selection from the data to write and a
203
151
selection in the dataset where to write.
204
152
153
+ - ` memory_selection ` tells what part to take from the data.
154
+ - ` dataset_selection ` tells where to write this part of data in file.
155
+
156
+ Here is an example:
157
+ ``` yaml
158
+ memory_selection :
159
+ size : [8, 8]
160
+ subsize : [4, 4]
161
+ start : [4, 4]
162
+ dataset_selection :
163
+ size : [8, 8]
164
+ subsize : [4, 4]
165
+ start : [4, 0]
166
+ ` ` `
167
+ The graphical representation:
168
+
169
+ \i mage html PDI_hdf5_selection.jpg
170
+
171
+
172
+
205
173
Restrict the selection to the second line from the data and write it to a
206
174
one-dimensional dataset in file.
207
175
Match the expected output described in ` ex7.out`.
208
176
177
+ # # Ex8. Writing an advanced selection
178
+
209
179
You can also add dimensions, write the 2D array excluding ghosts as a slab of a
210
180
3D dataset including a dimension for the time-iteration.
181
+
182
+ Here is an example :
183
+ ` ` ` yaml
184
+ memory_selection:
185
+ size: [8, 8]
186
+ subsize: [4, 4]
187
+ start: [4, 4]
188
+ dataset_selection:
189
+ size: [3, 8, 8]
190
+ subsize: [1, 4, 4]
191
+ start: [$ii, 4, 0]
192
+ ` ` `
193
+
194
+ And the graphical representation :
195
+
196
+ \image html PDI_hdf5_selection_advanced.jpg
197
+
211
198
Write iterations 1 to 3 inclusive into dimensions 0 to 2.
212
- Match the expected output described in ` ex7-bis.out ` .
199
+ Match the expected output described in `ex8_result.h5 `.
213
200
214
- ## Ex8. going parallel
201
+ # # Ex9. Going parallel
215
202
216
203
Running the current code in parallel should already work and yield one file per
217
204
process containing the local data block.
218
205
In this exercise we will write one single file with parallel HDF5 whose content
219
206
should be independent from the number of processes used.
220
207
221
- Examine the yaml, compile the code and run it.
222
- ``` bash
223
- make ex8 # compile the code
224
- llsubmit ex8.sh # run the code
225
- ```
226
-
227
208
We loaded the `mpi` plugin to make sharing MPI communicators possible.
228
209
229
- By uncommenting the ` communicator ` directive of the Decl'HDF5 plugin , we can now
210
+ By uncommenting the `communicator` directive of \ref Decl_HDF5_plugin , we can now
230
211
switch to parallel I/O.
231
212
* Change the file name so all processes open the same file.
232
213
* Change the dataset dimension to take the full parallel size into account.
233
214
* Ensure the dataset selection of each process does not overlap with the others.
234
- * Try to match the output from ` ex8.out ` that should be independant from the number of processes used.
215
+ * Try to match the output from `ex9.out` that should be independant from the number of processes used.
216
+
217
+ Here is graphical representation :
218
+
219
+ \image html PDI_hdf5_parallel.jpg
220
+
235
221
236
222
# What next ?
237
223
238
224
You can experiment with other \ref Plugins "plugins".
239
225
Why not try \ref FlowVR_plugin "FlowVR" for example?
240
-
241
- Take a look at the examples in the %PDI repository:
242
- ` https://gitlab.maisondelasimulation.fr/jbigot/pdi/tree/0.5/example `
0 commit comments