浏览代码

Before removing fflush

Your Name 7 年之前
父节点
当前提交
427bac6e96
共有 7 个文件被更改,包括 101 次插入96 次删除
  1. 0 4
      Makefile
  2. 4 13
      apps.c
  3. 6 2
      controller_core.c
  4. 4 1
      controller_core.h
  5. 9 5
      my_rtrm.c
  6. 74 69
      scc_signals.c
  7. 4 2
      signal_handlers.c

+ 0 - 4
Makefile

@@ -104,10 +104,6 @@ ifeq ($(IDAG_SLEEP),1)
   exec_name=my_rtrm.idag_sleep	
 endif
 
-ifeq ($(NO_ISLANDS),1)
-  MY_FLAGS += -DNO_ISLANDS
-endif
-
 ifeq ($(LOW_VOLTAGE),0)
   MY_FLAGS += -DLOW_VOLTAGE_0
 endif

+ 4 - 13
apps.c

@@ -617,20 +617,11 @@ float Speedup(app cur_app, int num_of_cores) {
 }
 
 int get_times(app cur_app, int num_of_cores) {
-	/*
-	int type;
-
-	if (cur_app.array_size == 1024) type = 0;
-	else if (cur_app.array_size == 2048) type = 1;
-	else if (cur_app.array_size == 4096) type = 2;
-	else {
-		fprintf(log_file, "Unknown array size = %d\n",cur_app.array_size);
-		fflush(log_file);
-		return 0.0;
-	}
-	return (cur_app.workld * matr_times[type][num_of_cores-2]);
-	*/
+#ifndef ARTIFICIAL_APPS_SIM
 	return (cur_app.workld * Exec_Latencies[num_of_cores-2]);
+#else
+	return cur_app.workld * (ARTIFICIAL_ROUND_DURATION_NSEC / ((int) Speedup_Artificial_App(cur_app, num_of_cores+1))); /* FIXME cutting off floating points -- +1 is because in Speedup calc it is -1*/
+#endif
 }
 
 void matrix_transpose(int n1, float *src, float *dest, int node_id, int myFirst, int myLast, int pad_length){

+ 6 - 2
controller_core.c

@@ -12,7 +12,11 @@
 #include "structs.h"
 #include "variables.h"
 
-void idle_agent_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_NUM_SIZE]){
+#ifndef PLAT_LINUX
+void idle_agent_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_NUM_SIZE]) {
+#else
+void idle_agent_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_NUM_SIZE], int Selfopt_Radius, int Max_SelfOpt_Interval_MS) {
+#endif
 	int i, one_core; 
 	pid_t p;
 	core_list *tmp_cores_list;
@@ -102,7 +106,7 @@ void idle_agent_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_N
 				p = fork();
 				if (p==0){
 					node_id = i;
-					common_node_actions(scen_directory, scen_num);
+					common_node_actions(scen_directory,scen_num,Selfopt_Radius,Max_SelfOpt_Interval_MS);
 				}
 					
 				#endif

+ 4 - 1
controller_core.h

@@ -3,7 +3,10 @@
 
 #include "variables.h"
 
+#ifndef PLAT_LINUX
 void idle_agent_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_NUM_SIZE]);
-
+#else
+void idle_agent_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_NUM_SIZE], int Selfopt_Radius, int Max_SelfOpt_Interval_MS);
+#endif
 
 #endif

+ 9 - 5
my_rtrm.c

@@ -448,7 +448,7 @@ int main(int argc, char *argv[]) {
 		p = fork();
 		if (p == 0) {
 			node_id = idag_id_arr[i];
-			idle_agent_actions(scen_directory,scen_num);
+			idle_agent_actions(scen_directory,scen_num,Selfopt_Radius,Max_SelfOpt_Interval_MS);
 			printf("I am newly created idag with i = %d and node_id = %d\n",i,node_id);
 			fflush(stdout);
 			break;
@@ -457,7 +457,11 @@ int main(int argc, char *argv[]) {
 	#endif
 	
 	if ((node_id != idag_id_arr[0]) && (is_core_idag(node_id) == 1)) {
-		idle_agent_actions(scen_directory,scen_num); //dimos comment out
+		#ifndef PLAT_LINUX
+		idle_agent_actions(scen_directory,scen_num);
+		#else
+		idle_agent_actions(scen_directory,scen_num,Selfopt_Radius,Max_SelfOpt_Interval_MS);
+		#endif
 	} else if (node_id != idag_id_arr[0]) {
 		common_node_actions(scen_directory,scen_num,Selfopt_Radius,Max_SelfOpt_Interval_MS);
 	} else {
@@ -506,9 +510,9 @@ int main(int argc, char *argv[]) {
 
 			 #ifdef PLAT_LINUX
 			 p = fork();
-			 if (p==0){
-				  node_id = i;
-				  common_node_actions(scen_directory, scen_num);
+			 if (p==0) {
+				node_id = i;
+				common_node_actions(scen_directory,scen_num,Selfopt_Radius,Max_SelfOpt_Interval_MS);	
 			 }
 			 #endif
 		}

+ 74 - 69
scc_signals.c

@@ -550,74 +550,75 @@ void scc_signals_check(void) {
 			
 			if (paxos_state == FAILED_CORE && sig_read_ar[0] == SIG_RECOVER){
 				fail_flag = 1;
-			} else if (paxos_state != FAILED_CORE)
-			if (sig_read_ar[0] == SIG_INIT) {
-				sig_INIT_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_ACK) {
-				sig_ACK_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_TERMINATE) {
-				sig_TERMINATE_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_INIT_APP) {
-				sig_INIT_APP_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_IDAG_FIND_IDAGS) {
-				sig_IDAG_FIND_IDAGS_handler(sender_id, &increase_cnt, index_top);
-			} else if (sig_read_ar[0] == SIG_REQ_DDS) {
-				sig_REQ_DDS_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_REQ_CORES) {
-				sig_REQ_CORES_handler(sender_id, &increase_cnt, index_top); /* increase_cnt was put like this because in response there is no need for increase */ 
-			} else if (sig_read_ar[0] == SIG_REP_OFFERS) {
-				sig_REP_OFFERS_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_INIT_AGENT) {
-				sig_INIT_AGENT_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_ADD_CORES_DDS) {
-				sig_ADD_CORES_DDS_handler(sender_id, &increase_cnt, index_top);
-			} else if (sig_read_ar[0] == SIG_REM_CORES_DDS) {
-				sig_REM_CORES_DDS_handler(sender_id, &increase_cnt, index_top);
-			} else if (sig_read_ar[0] == SIG_APPOINT_WORK) {
-				sig_APPOINT_WORK_handler(sender_id, &increase_cnt, index_top);
-			} else if (sig_read_ar[0] == SIG_FINISH) {
-				sig_FINISH_handler(sender_id, &increase_cnt, index_top);
-			} else if (sig_read_ar[0] == SIG_REJECT) {
-				sig_REJECT_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_APP_TERMINATED) {
-				num_apps_terminated++;
-				fprintf(log_file,"app_terminated = %d sender_id = %d\n",num_apps_terminated,sender_id);
-				printf("app_terminated = %d sender_id = %d\n",num_apps_terminated,sender_id);
-			/* PAXOS SIGNALS HANDLING */
-			} else if (sig_read_ar[0] == SIG_PREPARE_REQUEST){
-				sig_PREPARE_REQUEST_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_PREPARE_ACCEPT_NO_PREVIOUS){
-				sig_PREPARE_ACCEPT_NO_PREVIOUS_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_PREPARE_ACCEPT){
-				sig_PREPARE_ACCEPT_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_ACCEPT_REQUEST){
-				sig_ACCEPT_REQUEST_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_ACCEPTED){
-				sig_ACCEPTED_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_LEARN){
-				sig_LEARN_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_REINIT_APP){
-				sig_REINIT_APP_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_CONTR_TO){
-				sig_CONTR_TO_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_REMOVE_FROM_DDS){
-				sig_REMOVE_FROM_DDS_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_ADD_TO_DDS){
-				sig_ADD_TO_DDS_handler(sender_id,&increase_cnt,index_top);
-			} else if (sig_read_ar[0] == SIG_HEARTBEAT_REQ){
-				sig_HEARTBEAT_REQ_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_HEARTBEAT_REP){
-				sig_HEARTBEAT_REP_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_FAIL){
-				sig_FAIL_handler();
-			} else if (sig_read_ar[0] == SIG_PAXOS_STATS_REQ){
-				sig_PAXOS_STATS_REQ_handler(sender_id);
-			} else if (sig_read_ar[0] == SIG_PAXOS_STATS_REP){
-				sig_PAXOS_STATS_REP_handler(sender_id);
-			/* END OF PAXOS SIGNAL HANDLING */
-			} else if (sig_read_ar[0] != NO_SIG) {
-				fprintf(log_file,"I read smth different than no_sig which is %d from %d\n",sig_read_ar[0],sender_id);
-				fflush(log_file);
+			} else if (paxos_state != FAILED_CORE) {
+				if (sig_read_ar[0] == SIG_INIT) {
+					sig_INIT_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_ACK) {
+					sig_ACK_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_TERMINATE) {
+					sig_TERMINATE_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_INIT_APP) {
+					sig_INIT_APP_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_IDAG_FIND_IDAGS) {
+					sig_IDAG_FIND_IDAGS_handler(sender_id, &increase_cnt, index_top);
+				} else if (sig_read_ar[0] == SIG_REQ_DDS) {
+					sig_REQ_DDS_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_REQ_CORES) {
+					sig_REQ_CORES_handler(sender_id, &increase_cnt, index_top); /* increase_cnt was put like this because in response there is no need for increase */ 
+				} else if (sig_read_ar[0] == SIG_REP_OFFERS) {
+					sig_REP_OFFERS_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_INIT_AGENT) {
+					sig_INIT_AGENT_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_ADD_CORES_DDS) {
+					sig_ADD_CORES_DDS_handler(sender_id, &increase_cnt, index_top);
+				} else if (sig_read_ar[0] == SIG_REM_CORES_DDS) {
+					sig_REM_CORES_DDS_handler(sender_id, &increase_cnt, index_top);
+				} else if (sig_read_ar[0] == SIG_APPOINT_WORK) {
+					sig_APPOINT_WORK_handler(sender_id, &increase_cnt, index_top);
+				} else if (sig_read_ar[0] == SIG_FINISH) {
+					sig_FINISH_handler(sender_id, &increase_cnt, index_top);
+				} else if (sig_read_ar[0] == SIG_REJECT) {
+					sig_REJECT_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_APP_TERMINATED) {
+					num_apps_terminated++;
+					fprintf(log_file,"app_terminated = %d sender_id = %d\n",num_apps_terminated,sender_id);
+					printf("app_terminated = %d sender_id = %d\n",num_apps_terminated,sender_id);
+				/* PAXOS SIGNALS HANDLING */
+				} else if (sig_read_ar[0] == SIG_PREPARE_REQUEST) {
+					sig_PREPARE_REQUEST_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_PREPARE_ACCEPT_NO_PREVIOUS) {
+					sig_PREPARE_ACCEPT_NO_PREVIOUS_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_PREPARE_ACCEPT) {
+					sig_PREPARE_ACCEPT_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_ACCEPT_REQUEST) {
+					sig_ACCEPT_REQUEST_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_ACCEPTED) {
+					sig_ACCEPTED_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_LEARN)	{
+					sig_LEARN_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_REINIT_APP) {
+					sig_REINIT_APP_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_CONTR_TO) {
+					sig_CONTR_TO_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_REMOVE_FROM_DDS) {
+					sig_REMOVE_FROM_DDS_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_ADD_TO_DDS) {
+					sig_ADD_TO_DDS_handler(sender_id,&increase_cnt,index_top);
+				} else if (sig_read_ar[0] == SIG_HEARTBEAT_REQ) {
+					sig_HEARTBEAT_REQ_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_HEARTBEAT_REP) {
+					sig_HEARTBEAT_REP_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_FAIL) {
+					sig_FAIL_handler();
+				} else if (sig_read_ar[0] == SIG_PAXOS_STATS_REQ) {
+					sig_PAXOS_STATS_REQ_handler(sender_id);
+				} else if (sig_read_ar[0] == SIG_PAXOS_STATS_REP) {
+					sig_PAXOS_STATS_REP_handler(sender_id);
+				/* END OF PAXOS SIGNAL HANDLING */
+				} else if (sig_read_ar[0] != NO_SIG) {
+					fprintf(log_file,"I read smth different than no_sig which is %d from %d\n",sig_read_ar[0],sender_id);
+					fflush(log_file);
+				}
 			}
 
 			if (sig_read_ar[0] != NO_SIG)
@@ -661,7 +662,11 @@ void scc_signals_check(void) {
 		fprintf(log_file, "My state 2 is %s %s\n", id2string(state), id2string(paxos_state));
 		signals_enable();
 		fprintf(log_file, "My state 3 is %s %s\n", id2string(state), id2string(paxos_state));
-		idle_agent_actions("", "");
+		#ifndef PLAT_LINUX
+                idle_agent_actions("", "");
+                #else
+                idle_agent_actions("", "",0,0); /* FIXME Change to correct last two arguments!!! */
+                #endif
 	}
 	signals_enable();
 }

+ 4 - 2
signal_handlers.c

@@ -3609,11 +3609,13 @@ void sig_FINISH_handler(int sender_id, int *inc_cnt, int cur_index_top){
 								core_inter_tail[one_core]->data.work_bounds[1] = row_reached-1;
 								tmp_cores_list->workload[1] = row_reached-1; /* 27.6.2016 dimos. If worker fails i have to know the workload given in order to reappoint */
 #else								
+								/* The workload[1] is practically the Speedup of the app. Internally in execution
+								 * of the app this is translated to the correct time delay */
 								core_inter_tail[one_core]->data.work_bounds[0] = 0;
-                                                                tmp_cores_list->workload[0] = 0;
+								tmp_cores_list->workload[0] = 0;
 
 								core_inter_tail[one_core]->data.work_bounds[1] = per_core_rows;
-                                                                tmp_cores_list->workload[1] = per_core_rows;
+								tmp_cores_list->workload[1] = per_core_rows;
 #endif								
 								core_inter_tail[one_core]->next = NULL;