Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# README - Wireworld Example
## Description
*Wireworld* is a simple cellular automaton, similar to the Game of Life. The game Area is a 2-Dimensional Rectangle of cells. Each generation a set of rules are applied which define the next state of the cell depending on the neighboring cells.
This example shows how to distribute the simulation of Wireworld across multiple compute nodes. This includes Parallel IO for the input/output files and parallel computation of the next generation.localized.
The computation is distributed by spatially splitting the Wireworld rectangle into smaller chunks (*Tiles*). Where each compute node has one tile. At the border of each tile, there has to be communication with the neighboring tiles (** Halo Exchange**)
This code sample demonstrates:
* Using **Collective IO** MPI functions for efficiently reading and writing from multiple nodes to the same File, i.e. `MPI_File_set_view`, `MPI_File_read_all`
* Using MPI Datatypes for IO and Communication, i.e. `MPI_Type_create_subarray`, `MPI_Type_vector`
* Creating a distributed **Graph Topology** for the Halo Exchange, i.e. `MPI_Dist_graph_create_adjacent`
* Two different approaches for the Halo Exchange:
1. Using **collective communication**, i.e. `MPI_Ineighbor_alltoallw`
1. Using **point to point communication**, i.e. 'MPI_Isend', 'MPI_Irecv'
The code sample is structured as follows:
* `Communicator.*`: Creating the graph topology, Datatypes, Communication
* `Configuration.*`: Command line parsing
* `FileIO.*`: Code for reading and writing the Wireworld file
* `MpiEnvironment.*`: Wrapper class for the MPI Environment
* `MpiSubarray.*`: Wrapper class for the MPI Datatype Subarray
* `MpiWireworld.*`: Simulating a generation step, computing next state
* `Tile.*`: Represents a Tile, memory management, debugging
File Format:
The Wireworld file format is a text format. The first line is the header. The header has 2 positive integers, separated by space, which define the number of *colums*(width) and the number of *rows*(height).
In the following lines, the wireworld data is provided.
Each line is a row.
There are exactly *rows* lines and each line is exactly *colums* long.
The following characters are allowed:
* ` `: whitespace/empty
* `#`: conductor
* `@`: electron head
* `~`: electron tail
Note: Be aware that the line ending must match your operating systems convention.
## Release Date
2016-10-24
## Version History
* 2016-10-24: Initial Release on PRACE CodeVault repository
## Contributors
* Thomas Steinreiter - [thomas.steinreiter@risc-software.at](mailto:thomas.steinreiter@risc-software.at)
## Copyright
This code is available under Apache License, Version 2.0 - see also the license file in the CodeVault root directory.
## Languages
This sample is entirely written in C++ 14.
## Parallelisation
This sample uses MPI-3 for parallelization.
## Level of the code sample complexity
Intermediate / Advanced
## Compiling
Follow the compilation instructions given in the main directory of the kernel samples directory (`/hpc_kernel_samples/README.md`).
## Running
To run the program, use something similar to
mpiexec -n 8 ./5_structured_wireworld -g 10000 -f ../worlds/primes.wi -o ../worlds/primes.out.wi -m Collective
either on the command line or in your batch script, where `g` specifies the number of iterations, `f` the input file, `o` the output file and `m` the communication mode.
### Command line arguments
`-r [ --gridrows ]`: number of rows in the grid to form the tiles (optional, automatically deduced)
`-c [ --gridcols ]`: number of columns in the grid to form the tiles (optional, automatically deduced)
`-g [ --generations ]`: number of generations simulated (default 1000)
`-m [ --commmode ]`: Communication Mode. Collective or P2P (default Collective)
`-f [ --inputfile ]`: path to wireworld input file (mandatory, flag can be obmitted)
`-o [ --outputfile ]`: path to wireworld input file (optional, no writing)
### Example
If you run
mpiexec -n 8 ./5_structured_wireworld -g 10000 -f ../worlds/primes.wi -o ../worlds/primes.out.wi -m Collective