Skip to content
Snippets Groups Projects
Verified Commit 96d9415a authored by baptiste.coudray's avatar baptiste.coudray
Browse files

Updated doc

parent 3b7a7d26
No related branches found
No related tags found
No related merge requests found
......@@ -73,7 +73,6 @@ void compute_next_chunk_board(struct dispatch_context *dc,
int main(int argc, char *argv[]) {
/* ... MPI & Futhark Init ... */
const int N_ITERATIONS = 100;
int elems_dimensions[1] = {600};
struct dispatch_context *disp_context =
......@@ -85,7 +84,6 @@ int main(int argc, char *argv[]) {
compute_next_chunk_elems(disp_context, fut_context, &ci);
int8_t *sca = get_data(disp_context);
}
/* ... Free resources ... */
}
```
......
......@@ -50,15 +50,16 @@ void compute_next_chunk_board(struct dispatch_context *dc,
}
int main(int argc, char *argv[]) {
/* ... */
/* ... MPI & Futhark Init ... */
int board_dimensions[2] = {800, 800};
struct dispatch_context *disp_context =
dispatch_context_new(board_dimensions, MPI_INT8_T, 2);
/* ... */
/* ... */
const int N_ITERATIONS = 100;
for (int i = 0; i < N_MEASURES; ++i) {
compute_next_chunk_board(disp_context, fut_context, &ci);
}
/* ... */
/* ... Free resources ... */
}
```
......
......@@ -10,7 +10,38 @@ fundamental research, as it keeps the cycle between the elaboration of a theory
## Distributed version
We implement the Lattice-Boltzmann Method with our library to test it with a three-dimensional cellular automaton. Each cell is containing an array of 27 floats.
We implement the Lattice-Boltzmann Method with our library to test it with a three-dimensional cellular automaton. The code is almost the same as the previous example, so we focus on custom types in this example. A cell in this cellular automaton is of type of array containing 27 floats. In MPI, there is no predeclared type of array, so we need to create one. Thanks to our library, it is possible to do that with a minimum code.
```c
typedef struct lbm_values {
float values[NB_VALUES];
} lbm_values_t;
int main(int argc, char *argv[]) {
/* ... MPI & Futhark Init ... */
int count = 1;
int block_lengths[] = {NB_VALUES};
MPI_Aint displacements[] = {offsetof(struct lbm_values, values)};
MPI_Datatype types[] = {MPI_FLOAT};
MPI_Datatype lbm_type = create_type(count, block_lengths, displacements,
types);
int lbm_dimensions[3] = {400, 400, 400};
struct dispatch_context *disp_context =
dispatch_context_new(lbm_dimensions, lbm_type, 3);
/* ... Temporal loop & Free resources ... */
}
````
We need to declare a structure specifying a cell, so `lbm_values` is a struct containing an array of 27 floats. After that, in the `main` function, we describe the structure as follows:
* there is one field (`values`),
* the first field is containing 27 values,
* we compute where is located the field `values` in the structure,
* `values` is of type `MPI_FLOAT`.
Finally, we call our library function `create_type` with the previous parameters, and it returns an `MPI_Datatype` that can be pass to the function `dispatch_context_new`.
## CPU Benchmarks
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment