-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmpi_project.cpp
More file actions
55 lines (45 loc) · 1.4 KB
/
Copy pathmpi_project.cpp
File metadata and controls
55 lines (45 loc) · 1.4 KB
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
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;
#include "mpi_simulator.h"
#include "videomaker.h"
#include "mpi.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);
char profile_filename[256];
strcpy(profile_filename, "profile.txt");
if(argc == 2)
strcpy(profile_filename, argv[1]);
printf("Start simulation using profile '%s'\n", profile_filename);
printf("MPI: rank = %d, size = %d\n", rank, size);
MPISimulator sim(rank, size);
sim.initialize(profile_filename);
VideoMaker* video;
if(rank == 0) video = VideoMaker_Create("imgs/video", sim.render.width, sim.render.height);
for(int i = 0; i < sim.max_frame; i++) {
Timing tm("Frame");
sim.runSimulation();
sim.runSimulation();
sim.runSimulation();
tm.measure("run");
sim.renderFrame();
if(rank == 0) {
video->addFrame(sim.render.colors, sim.render.width, sim.render.height);
tm.measure("write");
}
if(i % 1000 == 0) {
sim.dumpData(i);
}
}
if(rank == 0) { video->finish(); delete video; }
MPI_Finalize();
return 0;
}