structs.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. #ifndef __STRUCTS_H__
  2. #define __STRUCTS_H__
  3. #define OLD_INIT_AREAS_NUM 8
  4. #include <time.h>
  5. #include <sys/time.h>
  6. typedef enum available_core_states {
  7. IDLE_CORE, //0
  8. WORKING_NODE, //1
  9. TERMINATED, //2
  10. /* Controller States */
  11. IDLE_IDAG, //3
  12. IDLE_IDAG_INIT_SEND, //4
  13. IDLE_CHK_APP_FILE, //5
  14. CHK_APP_FILE, //6
  15. USER_INPUT, //7 //FIXME change to a reasonable name
  16. /* Initial core States */
  17. INIT_MANAGER, //8
  18. INIT_MANAGER_SEND_OFFERS,//9
  19. IDLE_INIT_MAN, //10
  20. INIT_MAN_CHK_OFFERS, //11
  21. /* Manager States */
  22. IDLE_AGENT, //12
  23. IDLE_AGENT_WAITING_OFF, //13
  24. AGENT_INIT_STATE, //14
  25. AGENT_SELF_OPT, //15
  26. AGENT_SELF_CHK_OFFERS, //16
  27. AGENT_ENDING, //17
  28. IDAG_ENDING, //18
  29. NO_PENDING_STATE, //19
  30. AGENT_ZOMBIE, //20
  31. /* Multiple Pending States */
  32. AGENT_INIT_APP_INIT, //21
  33. AGENT_INIT_CHK_OFFERS, //22
  34. AGENT_INIT_IDLE_INIT, //23
  35. IDLE_INIT_IDLE_AGENT, //24
  36. IDLE_INIT_AGENT_SELFOPT,//25
  37. INIT_CHK_OFFERS_IDLE_AGENT, //26
  38. INIT_CHK_OFFERS_SELFOPT,//27
  39. /*PAXOS STATES*/
  40. PAXOS_ACTIVE, //28
  41. NEW_IDAG, //29
  42. NEW_AGENT, //30
  43. FAILED_CORE //31
  44. } core_states;//avail_states;
  45. typedef enum available_app_states {
  46. NO_APP, //0
  47. APP_TERMINATED, //1
  48. RUNNING, //2
  49. RESIZING, //3
  50. } application_states;//avail_states;
  51. typedef enum available_exec_apps{
  52. MATRIX_MUL,
  53. SVM,
  54. FFT
  55. } app_exec;
  56. typedef enum interaction_types {
  57. /* General Interaction Types */
  58. INIT_CORE, //0
  59. REMOVE_APP, //1
  60. /* 0 <--> Initial */
  61. INIT_APP, //2
  62. DECLARE_INIT_AVAILABILITY,//3
  63. /* 0 --> Controller */
  64. DEBUG_IDAG_REQ_DDS, //4 FIXME Find better name
  65. /* Initial <--> Controller Related Interaction Types */
  66. IDAG_FIND_IDAGS_PENDING, //5
  67. IDAG_FIND_IDAGS, //6
  68. IDAG_REQ_DDS_PENDING, //7
  69. IDAG_REQ_DDS, //8
  70. REP_IDAG_FIND_IDAGS, //9
  71. REP_IDAG_REQ_DDS, //10
  72. /* Initial --> Manager OR Controller */
  73. AGENT_REQ_CORES, //11
  74. AGENT_REQ_CORES_PENDING,//12
  75. /* Manager <--> Manager OR Controller */
  76. REP_AGENT_REQ_CORES, //13
  77. AGENT_OFFER_SENT, //14
  78. REP_AGENT_OFFER_SENT, //15
  79. REP_AGENT_OFFER_PENDING,//16
  80. /* Manager --> Controller */
  81. SELFOPT_IDAG_FIND_IDAGS_PENDING, //17
  82. SELFOPT_IDAG_FIND_IDAGS,//18
  83. SELFOPT_IDAG_REQ_DDS_PENDING,//19
  84. SELFOPT_IDAG_REQ_DDS, //20
  85. SELFOPT_REQ_CORES_PENDING,//21
  86. SELFOPT_REQ_CORES, //22
  87. IDAG_ADD_CORES_DDS, //23
  88. IDAG_REM_CORES_DDS, //24
  89. /* Initial --> Manager */
  90. INIT_AGENT, //25
  91. /* Manager --> Worker */
  92. INIT_WORK_NODE_PENDING, //26
  93. APPOINT_WORK_NODE_PENDING,//27
  94. INIT_WORK_NODE, //28
  95. APPOINT_WORK_NODE, //29
  96. /* Controller <--> Cores */
  97. TERMINATION_STATS, //30
  98. REP_STATISTICS, //31
  99. /* PAXOS INTERACTIONS */
  100. PAXOS_INIT, //32
  101. PREPARE_REQUEST, //33
  102. PREPARE_ACCEPT_NO_PREVIOUS,//34
  103. PREPARE_ACCEPT, //35
  104. ACCEPT_REQUEST, //36
  105. ACCEPTED, //37
  106. LEARN, //38
  107. LEARN_ACK, //39
  108. LEARN_ACK_CONTR, //40
  109. REINIT_APP, //41
  110. CONTR_TO, //42
  111. REMOVE_FROM_DDS, //43
  112. ADD_TO_DDS, //44
  113. HEARTBEAT_REQ, //45
  114. HEARTBEAT_REP, //46
  115. PAXOS_STATS_REQ, //47
  116. PAXOS_STATS_REP, //48
  117. RECOVERED //49
  118. /* END */
  119. } inter_types;
  120. typedef struct app_tag app;
  121. struct app_tag {
  122. int id;
  123. int array_size; // 0 = 1024, 1= 2048, 3= 4096
  124. int workld;
  125. int num_of_cores;
  126. int app_type;
  127. //int segment_id;
  128. };
  129. typedef struct region_tag region;
  130. struct region_tag {
  131. int C;
  132. int r;
  133. };
  134. typedef struct offer_tag offer;
  135. struct offer_tag {
  136. int num_of_cores;
  137. int *offered_cores;
  138. float spd_loss;
  139. //float spd_gain;
  140. };
  141. typedef struct offer_list_tag offer_list;
  142. struct offer_list_tag {
  143. offer off;
  144. int sender;
  145. int *answer;
  146. offer_list *next;
  147. };
  148. typedef struct target_list_tag target_list;
  149. struct target_list_tag {
  150. int target;
  151. int num_of_regions;
  152. region region_arr[OLD_INIT_AREAS_NUM];
  153. target_list *next;
  154. };
  155. struct region_array_tag {
  156. int num_of_regions;
  157. region *region_arr;
  158. };
  159. typedef struct region_array_tag region_array;
  160. struct offer_array_tag {
  161. int num_of_offers;
  162. offer *offer_arr;
  163. };
  164. typedef struct offer_array_tag offer_array;
  165. struct metrics_tag {
  166. long long int msg_count;
  167. int fd_msg_count;
  168. int message_size;
  169. int distance;
  170. int app_turnaround;
  171. int comp_effort;
  172. int cores_utilized;
  173. int times_accessed;
  174. };
  175. typedef struct metrics_tag metrics;
  176. /*
  177. struct far_req_info_tag {
  178. int orig_sender;
  179. app far_app;
  180. region reg;
  181. };
  182. typedef struct far_req_info_tag far_req_info;
  183. */
  184. struct my_time_stamp_tag {
  185. int tm_sec; /* seconds */
  186. int tm_min; /* minutes */
  187. int tm_hour; /* hours */
  188. suseconds_t tm_usec;
  189. };
  190. typedef struct my_time_stamp_tag my_time_stamp;
  191. struct init_app_info_tag {
  192. app new_app;
  193. my_time_stamp new_app_times[2];
  194. int *new_app_cores;
  195. };
  196. typedef struct init_app_info_tag init_app_info;
  197. typedef struct core_list_tag core_list;
  198. struct core_list_tag {
  199. int core_id;
  200. int offered_to; //-1 if offered to nobody
  201. int workload[2]; /* 27.6.2016 Added by dimos. If worker fails i have to know the workload given in order to reappoint */
  202. core_list *next;
  203. };
  204. typedef struct DDS_tag DDS_list;
  205. struct DDS_tag {
  206. int agent_id;
  207. int num_of_cores;
  208. DDS_list *next;
  209. };
  210. typedef struct coworkers_list_tag coworkers_list;
  211. struct coworkers_list_tag{
  212. int core_id;
  213. int agent_id;
  214. coworkers_list *next;
  215. };
  216. typedef struct agent_info_tag agent_info;
  217. struct agent_info_tag {
  218. int my_agent;
  219. int array_size;
  220. int work_bounds[2];
  221. int segment_id;
  222. int app_type;
  223. };
  224. typedef struct interact_list_tag inter_list;
  225. struct interact_list_tag {
  226. //int core_id;
  227. inter_types type;
  228. union {
  229. region reg;
  230. region_array reg_arr;
  231. app new_app;
  232. init_app_info one_app;
  233. offer my_offer;
  234. offer_array off_arr;
  235. metrics stats;
  236. int *idags_in_reg;
  237. int *agents_in_reg;
  238. int *app_cores;//first element is num of cores
  239. int offer_accepted;
  240. int *offer_acc_array;
  241. //int far_req_man;
  242. //far_req_info far_req;
  243. int work_bounds[3];
  244. int agent_ended;
  245. /* PAXOS */
  246. int proposal_number;
  247. int accepted_values[3]; // 0 is proposal_number, 1 is value, 2 is state
  248. int learn_ack_info[2];
  249. app reappointed_app;
  250. int controller_index;
  251. int failed_node;
  252. int workers_info[9];
  253. int paxos_stats[2];
  254. } data;
  255. inter_list *next;
  256. };
  257. typedef struct{
  258. int highest_acc_n; //Highest accepted proposal number
  259. int highest_acc_value; //Value paired with highest accepted proposal number
  260. int highest_proposed_n; //Highest proposed proposal number
  261. }acceptor_var;
  262. typedef struct{
  263. int highest_replied_n;
  264. int highest_replied_value;
  265. int cores_promised;
  266. int cores_accepted;
  267. int *core_states;
  268. }proposer_var;
  269. typedef struct{
  270. int accepted_value;
  271. int cores_accepted;
  272. }learner_var;
  273. #endif