runner_pt.h 1.97 KB
Newer Older
stefanwessel's avatar
stefanwessel committed
1
2
3
#ifndef MCL_RUNNER_H
#define MCL_RUNNER_H

4
5
#include <mpi.h>

stefanwessel's avatar
stefanwessel committed
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
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <vector>

#include "mc_pt.h"
#include "definitions.h"
#include "measurements.h"
#include "dump.h"
#include "parser.h"

struct one_task
{
	int task_id;
	int n_steps;
	int is_done;
	int run_counter;
	int steps_done;  //for master-slave communication
	int mes_done;    //for master-slave communication
	int pt_pos;      //for master-slave communication 
};

class runner_pt
{
	private:
		
		one_task my_task;
		std::string my_taskdir;
		std::string my_rundir;
	
		mc_pt * sys;
		
		std::string jobfile;
		std::string statusfile;
		std::string masterfile;
		std::string acceptfile;
44
		std::string positionsfile;
stefanwessel's avatar
stefanwessel committed
45
46
47
48
49
50
51
52
		
		std::vector<one_task> tasks;
		std::vector<string> taskfiles;
		
		std::vector<int> pt_node_task;
		std::vector<int> pt_node_order;
		std::vector<int> pt_node_mes_done;
		std::vector<int> pt_node_steps_done;
53
54
55
56
#ifdef MCL_HISTOGRAM
		std::vector<int> histogram_up,
			histogram_down;
#endif
57
58
59
#ifdef MCL_POS
		std::stringstream pt_position_order;
#endif
stefanwessel's avatar
stefanwessel committed
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
		std::vector<int> pt_accepted;
		int pt_moves;

		randomnumbergenerator * pt_rng;

		std::ofstream * STATUS;

		bool * pt_node_waits_for_global_update;
		int pt_N_global_update_waiter;
		
		double chktime, walltime, time_start, time_last_chkpt;

		bool time_is_up();
		
		// master stuff
		void M_read();
		void M_wait();
		void M_send_action(int, int);
		void M_write();
		void M_end_of_run();
		void M_update(int);
		void M_report();
		void M_report_acc_ratio();
83
#ifdef MCL_POS
84
		void M_report_pt_positions();
85
#endif
stefanwessel's avatar
stefanwessel committed
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
		void M_global_update();
		
		// slave stuff
		void run();
		bool is_chkpt_time();
		void end_of_run();
		int recv_action();
		void what_is_next(int);
		void global_update();
		void checkpointing();
		void merge_measurements();
		
		int N_exit;
		
		
	public:
		int my_rank, world_size;
		runner_pt(int argc, char *argv[]);
		~runner_pt();

		void start();

};

#endif