Browse Source

Before Speedup model for TECS

Your Name 7 years ago
parent
commit
5841a1e274
5 changed files with 108 additions and 7 deletions
  1. 6 0
      Makefile
  2. 2 0
      apps.c
  3. 9 3
      my_rtrm.c
  4. 20 1
      scc_signals.c
  5. 71 3
      signal_handlers.c

+ 6 - 0
Makefile

@@ -98,6 +98,12 @@ ifeq ($(EXTRA_DELAY),1)
   MY_FLAGS += -DEXTRA_DELAY
 endif
 
+ifeq ($(IDAG_SLEEP),1)
+  MY_FLAGS += -DIDAG_SLEEP
+
+  exec_name=my_rtrm.idag_sleep	
+endif
+
 ifeq ($(NO_ISLANDS),1)
   MY_FLAGS += -DNO_ISLANDS
 endif

+ 2 - 0
apps.c

@@ -576,6 +576,7 @@ int get_max_cores_count(app cur_app){
 #endif	
 }
 
+#ifdef ARTIFICIAL_APPS_SIM
 float Speedup_Artificial_App(app cur_app, int num_of_cores) {
 	float res=0;
 	
@@ -601,6 +602,7 @@ float Speedup_Artificial_App(app cur_app, int num_of_cores) {
 
 	return res;
 }
+#endif
 
 float Speedup(app cur_app, int num_of_cores) {
 	if ((num_of_cores < 2) || (num_of_cores > get_max_cores_count(cur_app))) {

+ 9 - 3
my_rtrm.c

@@ -677,9 +677,11 @@ int main(int argc, char *argv[]) {
 		if (state == IDLE_IDAG) {
 			scc_pause();
 			scc_signals_check();
-			if (num_apps_terminated == num_apps)
+			if (num_apps_terminated == num_apps) {
 				state = USER_INPUT;
-			else if (!timer_init_null && init_pending_head != NULL) {
+				fprintf(log_file,"All apps terminated. Switching to USER_INPUT\n");
+				fflush(log_file);
+			} else if (!timer_init_null && init_pending_head != NULL) {
 				its.it_value.tv_sec = 10;
 				its.it_value.tv_nsec = 0;
 				if (timer_settime(timerid, 0, &its, NULL) == -1) perror("timer_settime error9");
@@ -863,7 +865,11 @@ int main(int argc, char *argv[]) {
 			//	scc_signals_check();
 			//}
 
-			for (k=0; k<15000; k++) {//pause(); my_cores_count
+#ifndef IDAG_SLEEP
+			for (k=0; k<15000; k++) {
+#else
+			for (k=0; k<20; k++) {
+#endif
 				scc_pause();
 				scc_signals_check();
 			}

+ 20 - 1
scc_signals.c

@@ -9,8 +9,13 @@
 #include "controller_core.h"
 
 int sig_read_ar[2 * LINE_SIZE];
-
 int R = 0;
+#ifdef IDAG_SLEEP
+#include <time.h>
+#define SLEEP_ROUND_DURATION_NSEC 50000000 //100000000
+extern int my_idag;
+#endif 
+
 
 int find_sender_id(int SID){
 	
@@ -125,9 +130,11 @@ int scc_kill(int target_ID, int sig, inter_list *ref_inter_list) {
 			memcpy(&sig_array_local[6],&init_app.var,sizeof(int));
 			memcpy(&sig_array_local[7],&init_app.A,sizeof(int));
 #endif			
+			/*
 			sig_array_local[8] = ref_inter_list->data.reg_arr.region_arr[0].C;
 			sig_array_local[9] = ref_inter_list->data.reg_arr.region_arr[0].r;
 			increase_cnt = 2;
+			*/
 			//fprintf(log_file, "Cores=%d r=%d\n",sig_array_local[5],ref_inter_list->data.reg_arr.region_arr[0].r);
                         //fflush(log_file);
 			//free(ref_inter_list->data.reg_arr.region_arr);
@@ -142,9 +149,11 @@ int scc_kill(int target_ID, int sig, inter_list *ref_inter_list) {
 			memcpy(&sig_array_local[6],&my_app.var,sizeof(int));
 			memcpy(&sig_array_local[7],&my_app.A,sizeof(int));
 #endif
+			/*
 			sig_array_local[8] = ref_inter_list->data.reg_arr.region_arr[0].C;
 			sig_array_local[9] = ref_inter_list->data.reg_arr.region_arr[0].r;
 			increase_cnt = 2;
+			*/
 			//fprintf(log_file, "Cores=%d r=%d\n",sig_array_local[5],ref_inter_list->data.reg_arr.region_arr[0].r);
 			//fflush(log_file);
 			//free(ref_inter_list->data.reg_arr.region_arr);
@@ -659,7 +668,17 @@ void scc_signals_check(void) {
 
 void scc_pause(void) {
 	int dummy=0, i;
+	
+	#ifdef IDAG_SLEEP
+	struct timespec ts;
 
+	if (my_idag == -1) { /* I am a Controller core */
+		/* sleep(1); */
+        	ts.tv_sec = 0;
+        	ts.tv_nsec = SLEEP_ROUND_DURATION_NSEC;
+        	nanosleep(&ts, NULL);
+	}
+	#endif	
 	
 	#ifdef LOW_VOLTAGE_0
 	if ((node_id >= 0 && node_id <= 3) || (node_id >= 12 && node_id <= 15))

+ 71 - 3
signal_handlers.c

@@ -793,6 +793,27 @@ void sig_ACK_handler(int sender_id){
 			}		
 		} else if (tmp_inter_list->type == AGENT_REQ_CORES_PENDING) {
 			tmp_inter_list->type = AGENT_REQ_CORES;
+
+			/* Was added to avoid increasing counter inside signal handler, because it is not the same when asking for an offer or when getting a reply */
+			data_array_local[0] = tmp_inter_list->data.reg_arr.region_arr[0].C;
+			data_array_local[1] = tmp_inter_list->data.reg_arr.region_arr[0].r;
+			#ifdef PLAT_SCC
+			error = RCCE_put((t_vcharp)(&data_array[0]), (t_vcharp)(&data_array_local[0]), LINE_SIZE * sizeof(int), sender_id);
+			if (error != RCCE_SUCCESS) {
+				RCCE_error_string(error, error_str, &str_len);
+				printf("I am %d and i got an error in put data to %d with descr %s\n",node_id,sender_id,error_str);
+			}	
+
+			RCCE_flag_write(&flag_data_written, RCCE_FLAG_SET, sender_id);
+			#else
+			mem_offset = sender_id * MAX_DATA_LIST_LEN * LINE_SIZE;
+			for (i=0; i<LINE_SIZE; i++)
+				 data_array[mem_offset + i] = data_array_local[i];
+
+			sem_post(&flag_data_written[sender_id]);
+			//fprintf(log_file,"I free flag_data_written lock %d\n", sender_id);
+			#endif
+
 			free(tmp_inter_list->data.reg_arr.region_arr);
 			my_stats.message_size += sizeof(region);
 			my_stats.message_size += sizeof(app);
@@ -800,6 +821,27 @@ void sig_ACK_handler(int sender_id){
 		} else if (tmp_inter_list->type == SELFOPT_REQ_CORES_PENDING) {
 			my_stats.message_size += sizeof(app);
 			my_stats.message_size += sizeof(region);
+
+			 /* Was added to avoid increasing counter inside signal handler, because it is not the same when asking for an offer or when getting a reply */
+                        data_array_local[0] = tmp_inter_list->data.reg_arr.region_arr[0].C;
+                        data_array_local[1] = tmp_inter_list->data.reg_arr.region_arr[0].r;
+                        #ifdef PLAT_SCC
+                        error = RCCE_put((t_vcharp)(&data_array[0]), (t_vcharp)(&data_array_local[0]), LINE_SIZE * sizeof(int), sender_id);
+                        if (error != RCCE_SUCCESS) {
+                                RCCE_error_string(error, error_str, &str_len);
+                                printf("I am %d and i got an error in put data to %d with descr %s\n",node_id,sender_id,error_str);
+                        }       
+
+                        RCCE_flag_write(&flag_data_written, RCCE_FLAG_SET, sender_id);
+                        #else
+                        mem_offset = sender_id * MAX_DATA_LIST_LEN * LINE_SIZE;
+                        for (i=0; i<LINE_SIZE; i++)
+                                 data_array[mem_offset + i] = data_array_local[i];
+
+                        sem_post(&flag_data_written[sender_id]);
+                        //fprintf(log_file,"I free flag_data_written lock %d\n", sender_id);
+                        #endif
+
 			tmp_inter_list->type = SELFOPT_REQ_CORES;
 			free(tmp_inter_list->data.reg_arr.region_arr);
 			clear = 0;
@@ -1738,9 +1780,30 @@ void sig_REQ_CORES_handler(int sender_id, int *inc_cnt, int cur_index_top) {
 	fflush(log_file);	
 		
 	if (core_inter_head[sender_id] == NULL && my_cores != NULL) {
-		*inc_cnt = *inc_cnt + 1;
+		/* *inc_cnt = *inc_cnt + 1; */
 		
 		/* 12.7.2017 really major change compared to TECS 8x6 to add an extra readline in REQ_CORES for artificial apps */
+		/* 31.7.2017 Change to data array in order to avoid inc_cnt */
+
+		#ifdef PLAT_SCC
+		RCCE_flag_write(&flag_data_written, RCCE_FLAG_UNSET, node_id);
+		scc_kill(sender_id, SIG_ACK, core_inter_head[sender_id]);
+
+		RCCE_wait_until(flag_data_written, RCCE_FLAG_SET);		
+						
+		error = RCCE_get((t_vcharp)(&data_array_local[0]), (t_vcharp)(&data_array[0]), LINE_SIZE * sizeof(int), node_id);
+		if (error != RCCE_SUCCESS) {
+			RCCE_error_string(error, error_str, &str_len);
+			printf("I am %d and i got an error in get data in sig_REQ_CORES_handler from %d with descr %s\n",node_id,sender_id,error_str);
+		}
+		 
+		#else
+		scc_kill(sender_id, SIG_ACK, core_inter_head[sender_id]);	
+		sem_wait(&flag_data_written[node_id]);
+		my_RCCE_get(&data_array_local[0], &data_array[0], LINE_SIZE, node_id);	
+		#endif
+
+		/*
 		#ifdef PLAT_SCC
 		RCCE_acquire_lock(node_id);
 		#else
@@ -1757,11 +1820,12 @@ void sig_REQ_CORES_handler(int sender_id, int *inc_cnt, int cur_index_top) {
 				fflush(log_file);
 			}
 		#else
-			/* FIXME this will block in simulation if we do not add sem_post */
+			// FIXME this will block in simulation if we do not add sem_post
 			new_RCCE_get(sig_read_ar, sig_array, cur_index_top, LINE_SIZE, node_id);
 		#endif
  
-		scc_kill(sender_id, SIG_ACK, NULL);		
+		scc_kill(sender_id, SIG_ACK, NULL);
+		*/
 		my_stats.msg_count++;
 		my_stats.distance += distance(node_id,sender_id);
 		req_app.id = sig_read_ar[2];
@@ -1801,8 +1865,12 @@ void sig_REQ_CORES_handler(int sender_id, int *inc_cnt, int cur_index_top) {
 		off_arr.offer_arr = (offer *) malloc(off_arr.num_of_offers * sizeof(offer));
 		core_inter_tail[sender_id]->next = NULL;
 
+		/*
 		cur_reg.C = sig_read_ar[8];
 		cur_reg.r = sig_read_ar[9];
+		*/
+		cur_reg.C = data_array_local[0];
+		cur_reg.r = data_array_local[1];
 		fprintf(log_file,"Searching in C = %d r = %d\n",cur_reg.C,cur_reg.r);
                 fflush(log_file);