-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
62 lines (53 loc) · 1.24 KB
/
main.c
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
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <mpi.h>
#include "automaton.h"
#include "args.h"
#include "step0.h"
#include "step123.h"
#include "step4.h"
int main(int argc, char** argv)
{
MPI_Init(&argc, &argv);
int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
#ifdef DEBUG
fprintf(stderr, "Launched on %d procs\n", size);
#endif
inst instance;
if(parse_options(&instance, argc, argv, rank) == 1)
{
MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
exit(EXIT_FAILURE);
}
if(instance.step == 0)
{
if(rank == 0)
{
grid g;
parse_file(instance.input_path, &g);
step0(instance, &g);
}
}
else
{
if(size != instance.p * instance.q && rank == 0)
{
fprintf(stderr, "Error: there should be %d procs and not %d\n", (instance.p * instance.q), size);
print_usage();
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
}
if(instance.step <= 3)
step123(instance, rank, size);
else if(instance.step == 4)
step4(instance, rank, size);
MPI_Finalize();
}
return 0;
}
// on fait le truc de la non copie et alternance modulo 2 ?
//Sendrecv des edges
//void update_grid(cell *cells, quelques éléments de l'instance);