structs.h 6.4 KB

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