Browse Source

Artificial added

Your Name 7 years ago
parent
commit
aebab3aefc
9 changed files with 618 additions and 664 deletions
  1. 18 4
      Makefile
  2. 72 399
      apps.c
  3. 98 17
      common_core.c
  4. 21 18
      my_rtrm.c
  5. 11 4
      paxos_signal_handlers.c
  6. 53 49
      scc_signals.c
  7. 333 169
      signal_handlers.c
  8. 1 1
      signal_handlers.h
  9. 11 3
      structs.h

+ 18 - 4
Makefile

@@ -19,7 +19,7 @@ else
 endif
 
 OBJS=my_rtrm.o libfun.o nocfun.o sigaux.o controller.o common_node.o signal_handlers.o scc_signals.o idag_defs.o paxos_signal_handlers.o apps.o resource_negotiation.o $(ARCHIVE)
-
+exec_name=my_rtrm
 #
 #PAXOS OBJECTS
 #
@@ -72,6 +72,20 @@ ifeq ($(SINGLE_WORKER),1)
   MY_FLAGS += -DSINGLE_WORKER
 endif
 
+ifeq ($(ADAM_SIM),1)
+	MY_FLAGS += -DADAM_SIM
+
+	ifneq ($(SINGLE_IDAG),1)	 
+		MY_FLAGS += -DSINGLE_IDAG
+	endif
+
+	exec_name=my_rtrm_adam
+endif
+
+ifeq ($(APPS_SIM),1)
+	MY_FLAGS += -DARTIFICIAL_APPS_SIM
+endif
+
 ifeq ($(SINGLE_IDAG),1)
   MY_FLAGS += -DSINGLE_IDAG
 endif
@@ -116,8 +130,8 @@ ifeq ($(GREEDY_MANAGER),1)
   MY_FLAGS += -DGREEDY_MANAGER
 endif
 
-my_rtrm:$(OBJS) 
-	cd ./../bin && $(CCOMPILE) $(CFLAGS) $(MY_FLAGS) -o my_rtrm $(OBJS) -pthread -lrt -lm
+$(exec_name):$(OBJS) 
+	cd ./../bin && $(CCOMPILE) $(CFLAGS) $(MY_FLAGS) -o $(exec_name) $(OBJS) -pthread -lrt -lm
 
 nocfun.o: noc_functions.c noc_functions.h my_rtrm.h idag_defs.h $(PLATFORM_INCLUDES)
 	$(CCOMPILE) $(CFLAGS) $(MY_FLAGS) -o ./../bin/nocfun.o -c noc_functions.c
@@ -156,7 +170,7 @@ resource_negotiation.o: resource_negotiation.c resource_negotiation.h apps.h noc
 	$(CCOMPILE) $(CFLAGS) $(MY_FLAGS) -o ./../bin/resource_negotiation.o -c resource_negotiation.c
 
 clean:
-	rm -f ./../bin/my_rtrm ./../bin/my_rtrm.o ./../bin/libfun.o ./../bin/nocfun.o ./../bin/sigaux.o ./../bin/common_node.o ./../bin/controller.o ./../bin/signal_handlers.o ./../bin/paxos_signal_handlers.o ./../bin/scc_signals.o ./../bin/idag_defs.o ./../bin/apps.o ./../bin/my_rtrm.resource_negotiation.o
+	rm -f ./../bin/my_rtrm ./../bin/my_rtrm_adam ./../bin/my_rtrm.o ./../bin/libfun.o ./../bin/nocfun.o ./../bin/sigaux.o ./../bin/common_node.o ./../bin/controller.o ./../bin/signal_handlers.o ./../bin/paxos_signal_handlers.o ./../bin/scc_signals.o ./../bin/idag_defs.o ./../bin/apps.o ./../bin/my_rtrm.resource_negotiation.o
 	rm -rf ./../scenaria/6x6/paxos_log_files/*
 	rm -rf ./../scenaria/6x6/log_files/*
 	rm -rf ./../scenaria/6x6/app_logs/*

+ 72 - 399
apps.c

@@ -2,384 +2,14 @@
 #include "scc_signals.h"
 #include "libfunctions.h"
 #include "my_rtrm.h"
+#include <time.h>
 
 #define SWAP(a,b) {float tmp; tmp=a; a=b; b=tmp;}
 #define FFT_MAX 136192
 #define PAGE_SIZE 4096
-
-/*
-static float input_vector[25][10] = {
-  {-0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119},
-  {-0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467},
-  {-0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565},
-  {-0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533},
-  {-0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941},
-  {-1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784},
-  {0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575},
-  {0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371},
-  {1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241},
-  {1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752},
-  {-0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115},
-  {-0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876},
-  {-0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559},
-  {-0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523},
-  {1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364},
-  {-0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320},
-  {3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579},
-  {-0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210},
-  {1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734},
-  {-0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990},
-  {-0.632187, -0.629597, -0.560808, -0.439143, -0.550906, -3.344673, -1.389866, 0.268649, 0.664319, 1.150327},
-  {-0.205756, -0.210472, -0.151426, -0.121347, 0.196067, -3.136218, -2.621049, -0.026517, 0.358534, 0.714117},
-  {-0.418011, -0.424854, -0.461205, -0.428858, -0.801747, 1.933860, -0.129047, -0.674498, -0.880092, -0.752953},
-  {-0.625461, -0.633598, -0.651167, -0.621632, -0.312866, -3.908468, -2.380095, -0.118114, 0.233478, 0.722539},
-  {-0.525633, -0.521436, -0.552314, -0.527505, -0.233392, -3.763046, -2.487090, -0.133160, 0.156544, 0.642195},
-};
-*/
-/*
-static float input_vector[2][D_sv] = {
-  {-0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752},
-  {-0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990},
-};
-*/
-/*
-static float input_vector[1][D_sv] = {
-  {-0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990	
-  },
-};
-*/
-/*
-static float input_vector[1][2100] = {
-  {-0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752,
-  -0.664593, -0.687087, -0.075215, 0.583554, 0.927597, 3.671647, 3.835722, 0.694133, -2.007198, -2.345115,
-   -0.343777, -0.344074, -0.221304, -0.153775, -0.494637, 1.743759, -0.590775, -0.413656, -0.389204, -0.221876,
-   -0.159571, -0.163080, -0.513428, -0.775665, -0.891170, -3.118664, -1.247074, 0.913688, 1.009656, 1.170559,
-   -0.761538, -0.755972, -0.773967, -0.674253, -0.978258, 1.514730, -0.145977, -0.620700, -0.857082, -0.765523,
-   1.344641, 1.329151, 1.633256, 2.020196, 1.777348, -1.744907, -5.928727, -4.032057, -0.585966, 1.072364,
-   -0.468882, -0.486856, 0.935241, 2.032263, 2.219547, -0.225632, -3.438104, -4.412505, -0.550391, 2.234320,
-   3.177341, 3.204259, 2.749250, 1.741244, 1.197538, -2.985864, -6.084715, -1.447878, 0.904210, 1.495579,
-   -0.998953, -1.005918, -0.988911, -0.863153, -1.003750, 1.256336, -0.471785, -0.860056, -0.872804, -0.629210,
-   1.957319, 1.966453, 1.840960, 1.405216, 1.313205, -0.956540, -3.535391, -2.280320, -1.179478, -0.458734,
-   -0.326054, -0.331524, -0.134208, -0.218622, -0.158037, 3.128528, 4.020623, -1.129257, -1.524952, -1.377990,
-   -0.390695, -0.381094, -0.341754, -0.272043, -0.588159, 2.297114, -0.116822, -0.507031, -0.563574, -0.534119,
-   -0.250457, -0.240673, -0.210423, -0.217804, -0.453731, 1.784484, -0.142005, -0.230148, -0.339593, -0.298467,
-   -0.177671, -0.183887, -0.191644, -0.205313, -0.441613, 1.599526, 0.023297, -0.322458, -0.539978, -0.457565,
-   -0.149024, -0.140364, -0.142723, -0.066651, -0.344126, 1.830863, 0.154307, -0.171898, -0.343950, -0.379533,
-   -0.155498, -0.154145, -0.181875, -0.189322, -0.122244, -3.037579, -1.476675, -0.089878, 0.004249, 0.169941,
-   -1.786535, -1.809749, -1.445913, -1.050310, -0.095173, 2.964720, 4.706277, -0.649227, -1.362017, -1.447784,
-   0.034026, 0.038159, -0.018497, -0.067303, 0.059710, -2.908602, -1.484229, 0.108804, 0.292757, 0.566575,
-   0.527511, 0.518252, 0.762342, 1.148066, 0.772846, -2.113671, -2.704303, -0.664257, 0.460104, 1.295371,
-   1.370790, 1.383803, 1.340450, 0.634441, -0.596868, -2.427651, -2.352223, 0.454767, 1.405430, 1.838241,
-   1.455314, 1.464866, 2.487861, 2.464788, 1.963237, 0.324097, -1.869693, -2.554004, -2.022594, 1.114752
-  },
-};
-*/
+#define ARTIFICIAL_ROUND_DURATION_SEC 1
+#define ARTIFICIAL_ROUND_DURATION_NSEC 500000000 /* 1 ms */
+ 
 static float **svm_vectors, *svm_coef;
 static int *vector, **matrix;
 static float input_vector[D_sv];
@@ -480,16 +110,39 @@ void execute_workload_fft (int lower_bound, int upper_bound) {
 	FFT1D(1, M, N, x_local, trans, upriv, umain2, work_id, lower_bound, upper_bound, pad_length, P); //HACK node_id - 1 important!!
 }
 
+void execute_workload_artificial (int lower_bound, int upper_bound) {
+	int AppSpeedup = upper_bound - lower_bound;
+	struct timespec ts;
+
+	//if (base_offset == -1) {
+	//	base_offset = cur_agent.my_agent * MAX_ARRAY_SIZE; /* FIXME Why is it always MAX_ARRAY_SIZE */
+	//}
+	
+	ts.tv_sec = 0;
+	ts.tv_nsec = ARTIFICIAL_ROUND_DURATION_NSEC / AppSpeedup;
+	nanosleep(&ts, NULL);
+	/*
+	for (i=lower_bound; i<=upper_bound; i++) {
+		sleep(ARTIFICIAL_ROUND_DURATION_SEC);
+	}
+	*/
+	/*
+	for (i=lower_bound; i<=upper_bound; i++) 
+		manager_result_out[base_offset+i] = -1;
+	*/
+}
+
 void execute_workload (int lower_bound, int upper_bound) {
 	
 	if (executed_app == MATRIX_MUL) {
 		execute_workload_matrix (lower_bound, upper_bound);
 	} else if (executed_app == SVM) {
 		execute_workload_svm (lower_bound, upper_bound);			
-	}	else if (executed_app == FFT) {
+	} else if (executed_app == FFT) {
 		execute_workload_fft (lower_bound, upper_bound);
+	} else if (executed_app == ARTIFICIAL) {
+		execute_workload_artificial (lower_bound, upper_bound);
 	}
-
 }
 
 void init_speedup_structs (void) {
@@ -648,6 +301,8 @@ void init_speedup_structs (void) {
 		Exec_Latencies[5] = 0;
 		Exec_Latencies[6] = 0;
 		Exec_Latencies[7] = 0;
+	} if (executed_app == ARTIFICIAL) {
+
 	}	
 }
 
@@ -671,8 +326,8 @@ void app_init (char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_NUM_SIZE])
 		fprintf(log_file,"matrix file path = %s\n",buf);
 
 		if ((matrix_input = fopen(buf, "r")) == NULL){
-					printf("Cannot open input file with file path = %s ",buf);
-					perror("open matrix_input");
+			printf("Cannot open input file with file path = %s ",buf);
+			perror("open matrix_input");
 		}
 
 		for (i=0; i<cur_agent.array_size; i++) {
@@ -792,7 +447,7 @@ void app_init (char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_NUM_SIZE])
 		fclose(coef_file);
 		fclose(test_vector_file);
 		free(buffer);
-	}	else if (executed_app == FFT) {
+	} else if (executed_app == FFT) {
 		fprintf(log_file,"Initializing FFT application\n");
 		
 		x_local = (float *)malloc(2*(N+rootN*pad_length)*sizeof(float)+PAGE_SIZE);
@@ -842,8 +497,8 @@ void app_init (char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_NUM_SIZE])
 		fprintf(log_file,"umain_file file path = %s\n",buf);
 		
 		if ((umain_file = fopen(buf,"r")) == NULL){
-					printf("Cannot open input file with file path = %s ",buf);
-					perror("open fft_input");
+			printf("Cannot open input file with file path = %s ",buf);
+			perror("open fft_input");
 		}
 		
 		for (i=0; i<2*rootN; i++) {
@@ -863,8 +518,8 @@ void app_init (char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_NUM_SIZE])
 		fprintf(log_file,"umain2_file file path = %s\n",buf);
 		
 		if ((umain2_file = fopen(buf,"r")) == NULL){
-					printf("Cannot open input file with file path = %s ",buf);
-					perror("open umain_file");
+			printf("Cannot open input file with file path = %s ",buf);
+			perror("open umain_file");
 		}
 		
 		//for (i=0; i<2*(N+rootN*pad_length)+PAGE_SIZE; i++) {
@@ -885,8 +540,8 @@ void app_init (char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_NUM_SIZE])
 		fprintf(log_file,"x_local_file file path = %s\n",buf);
 		
 		if ((x_local_file = fopen(buf,"r")) == NULL){
-					printf("Cannot open input file with file path = %s ",buf);
-					perror("open x_local_file");
+			printf("Cannot open input file with file path = %s ",buf);
+			perror("open x_local_file");
 		}
 		
 		//for (i=0;i<2*(N+rootN*pad_length)+PAGE_SIZE;i++) {
@@ -899,7 +554,9 @@ void app_init (char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_NUM_SIZE])
 			upriv[i] = umain[i];
 		}
 		
-	}	
+	} else if (executed_app == MATRIX_MUL) {
+
+	}
 }
 
 int get_max_cores_count(app cur_app){
@@ -919,25 +576,41 @@ int get_max_cores_count(app cur_app){
 #endif	
 }
 
-float Speedup(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;
+float Speedup_Artificial_App(app cur_app, int num_of_cores) {
+	float res=0;
+	
+	if (num_of_cores > 0) {
+		if (cur_app.var < 1.0) {
+			if (num_of_cores == 1) {
+				res = 1;
+			} else if ((num_of_cores > 1) && (num_of_cores < cur_app.A)) {
+				res = (num_of_cores*cur_app.A) / (cur_app.A + (cur_app.var / 2.0*(num_of_cores-1)));			
+			} else if ((num_of_cores >= cur_app.A) && (num_of_cores < 2.0*cur_app.A - 1)) {
+				res = (num_of_cores*cur_app.A) / (cur_app.var*(cur_app.A -0.5) + num_of_cores*(1.0 - 0.5*cur_app.var));
+			} else {
+				res = cur_app.A;
+			}
+		} else {
+			if ((num_of_cores >= 1) && (num_of_cores <= (cur_app.A + cur_app.A*cur_app.var - cur_app.var))) {
+				res = (num_of_cores*cur_app.A*(cur_app.var + 1)) / (cur_app.A + cur_app.var*(num_of_cores-1 + cur_app.A));
+			} else {
+				res = cur_app.A;
+			}
+		}
 	}
 
-	return matr_speedup[type][num_of_cores-1];
-	*/
+	return res;
+}
+
+float Speedup(app cur_app, int num_of_cores) {
 	if ((num_of_cores < 2) || (num_of_cores > get_max_cores_count(cur_app))) {
                 return 0;
         } else {
+#ifndef ARTIFICIAL_APPS_SIM
 		return Exec_Speedup[num_of_cores-2];
+#else
+		return Speedup_Artificial_App(cur_app, num_of_cores-1);	
+#endif
 	}
 }
 

+ 98 - 17
common_core.c

@@ -113,15 +113,24 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 		paxos_node_stats.comp_effort=0;
 		paxos_node_stats.cores_utilized=0;
 		paxos_node_stats.times_accessed=0;
-	
+
+#ifndef ARTIFICIAL_APPS_SIM
 		my_app.array_size=-1;
+#else
+		my_app.var = 0.0;
+		my_app.A = 0.0;
+#endif
 		my_app.workld=-1;
 		my_app.num_of_cores=-1;
-		//my_app.segment_id=-1;
+		
+#ifndef ARTIFICIAL_APPS_SIM
 		init_app.array_size=-1;
+#else
+                init_app.var = 0.0;
+                init_app.A = 0.0;
+#endif
 		init_app.workld=-1;
 		init_app.num_of_cores=-1;
-		//init_app.segment_id=-1;
 		
 		index_bottom[node_id] = 0;
 		
@@ -293,11 +302,12 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 				core_inter_tail[my_idag] = core_inter_tail[my_idag]->next;
 			}
 
+			#ifndef ADAM_SIM
 			core_inter_tail[my_idag]->type = IDAG_FIND_IDAGS_PENDING;
-			core_inter_tail[my_idag]->data.reg.C = node_id-1;
+			core_inter_tail[my_idag]->data.reg.C = node_id-1; /* FIXME Why -1 ??? */
 			core_inter_tail[my_idag]->data.reg.r = Selfopt_Radius;
 			core_inter_tail[my_idag]->next = NULL;
-
+			
 			if (core_inter_head[my_idag]->next == NULL) {
 				//kill(pid_num[my_idag],SIG_IDAG_FIND_IDAGS);
 				scc_kill(my_idag, SIG_IDAG_FIND_IDAGS, core_inter_head[my_idag]);
@@ -306,7 +316,22 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 			} else {
 				fprintf(log_file, "common_core.c: Did not send idag_find_idags with interaction %s no2 %s\n",inter2string(core_inter_head[my_idag]->type),inter2string(core_inter_head[my_idag]->next->type));
 			}
-			
+			#else
+			core_inter_tail[my_idag]->type = IDAG_REQ_DDS_PENDING;
+			core_inter_tail[my_idag]->data.reg.C = node_id-1; /* FIXME Why -1 ??? */
+			core_inter_tail[my_idag]->data.reg.r = Selfopt_Radius;
+			core_inter_tail[my_idag]->next = NULL;
+			init_DDS_idags = 1; /* Necessary to override SIG_FIND_IDAGS */
+
+			if (core_inter_head[my_idag]->next == NULL) {
+				//kill(pid_num[my_idag],SIG_IDAG_FIND_IDAGS);
+				scc_kill(my_idag, SIG_REQ_DDS, core_inter_head[my_idag]);
+				my_stats.msg_count++;
+				my_stats.distance += distance(node_id,my_idag);
+			} else {
+				fprintf(log_file, "Adam common_core.c: Did not send idag_req_dds with interaction %s no2 %s\n",inter2string(core_inter_head[my_idag]->type),inter2string(core_inter_head[my_idag]->next->type));
+			}
+			#endif
 			if (selfopt_time_rem != -1) { 
 				selfopt_time_rem = my_gettimer();
 
@@ -628,7 +653,6 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 			#endif
 			}
 			
-			
 			selfopt_interval = LEAST_SELF_OPT_INTERVAL_MS;
 			nodes_ended_cnt = 0;
 			app_state = RUNNING;
@@ -668,15 +692,23 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 			
 			gettimeofday(&time_val, NULL);
 			cur_t = localtime(&time_val.tv_sec);	
+#ifndef ARTIFICIAL_APPS_SIM			
 			fprintf(app_log_file, "[%d:%d:%d:%ld]: I am agent %d . Init ok!! my_cores_count = %d array_size = %d workld=%d\n",
 				cur_t->tm_hour,cur_t->tm_min,cur_t->tm_sec,time_val.tv_usec,node_id,my_cores_count,my_app.array_size,my_app.workld);
-
+#else
+			fprintf(app_log_file, "[%d:%d:%d:%ld]: I am agent %d . Init ok!! my_cores_count = %d var = %f workld=%d my_Speedup= %.2f\n",
+                                cur_t->tm_hour,cur_t->tm_min,cur_t->tm_sec,time_val.tv_usec,node_id,my_cores_count,my_app.var,my_app.workld,my_Speedup); 
+			/* FIXME printf order is maintained for compatibility with python scrips */
+#endif
 			active_working_cores = my_cores_count - 1;
 			if (my_cores_count > 1) {
-
+#ifndef ARTIFICIAL_APPS_SIM
 				row_reached = 0;
 				per_core_rows = my_app.array_size / (my_cores_count-1);
 				rows_left = my_app.array_size % (my_cores_count-1);
+#else
+				per_core_rows = (int) my_Speedup;
+#endif
 			}
 						
 			fprintf(app_log_file, "my cores are:");
@@ -696,6 +728,7 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 				}
 
 				core_inter_tail[one_core]->type = INIT_WORK_NODE;
+#ifndef ARTIFICIAL_APPS_SIM
 				core_inter_tail[one_core]->data.work_bounds[0] = row_reached; /* 27.6.2016 Added by dimos. If worker fails i have to know the workload given in order to reappoint */
 				tmp_cores_list->workload[0] = row_reached;
 				row_reached += per_core_rows;
@@ -705,6 +738,14 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 				}
 				core_inter_tail[one_core]->data.work_bounds[1] = row_reached-1;
 				tmp_cores_list->workload[1] = row_reached-1; /* 27.6.2016 Added by dimos. If worker fails i have to know the workload given in order to reappoint */
+#else
+				core_inter_tail[one_core]->data.work_bounds[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;
+#endif
+
 				/* 28.6.2016 Scenario where worker fails */
 				#ifdef WORKER
 				if (worker_flag == 0){
@@ -793,7 +834,6 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 				selfopt_DDS_replies = 0;
 				//selfopt_areas_sent = 0;
 				//if (selfopt_man_offers != NULL) printf("selfopt offers list is not NULL\n");
-				fprintf(log_file,"asd1\n");
 				if (selfopt_targets_head != NULL) {
 					//printf("selfopt targets list is not NULL\n");
 					while (selfopt_targets_head != NULL){
@@ -802,7 +842,7 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 						free(tmp_target_list);
 					}
 				}
-				fprintf(log_file,"asd2\n");
+				
 				if (core_inter_head[my_idag] == NULL){
 					core_inter_head[my_idag] = (inter_list *) malloc(sizeof(inter_list));
 					core_inter_tail[my_idag] = core_inter_head[my_idag];
@@ -811,6 +851,7 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 					core_inter_tail[my_idag] = core_inter_tail[my_idag]->next;
 				}
 
+				#ifndef ADAM_SIM
 				core_inter_tail[my_idag]->type = SELFOPT_IDAG_FIND_IDAGS_PENDING;
 				core_inter_tail[my_idag]->data.reg.C = node_id;
 				core_inter_tail[my_idag]->data.reg.r = Selfopt_Radius;
@@ -824,7 +865,24 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 				} else {
 					fprintf(log_file,"common_core.c: Did not send sig_find_idags with inter1 = %s, inter2 = %s\n",inter2string(core_inter_head[my_idag]->type),inter2string(core_inter_head[my_idag]->next->type));
 				}
-					
+				#else
+				core_inter_tail[my_idag]->type = SELFOPT_IDAG_REQ_DDS_PENDING;
+				core_inter_tail[my_idag]->data.reg.C = node_id;
+				core_inter_tail[my_idag]->data.reg.r = Selfopt_Radius;
+				core_inter_tail[my_idag]->next = NULL;
+				selfopt_DDS_idags = 1; /* Necessary to override SIG_FIND_IDAGS */
+
+				if (core_inter_head[my_idag]->next == NULL) {
+					//kill(pid_num[my_idag],SIG_IDAG_FIND_IDAGS);
+					scc_kill(my_idag, SIG_REQ_DDS, core_inter_head[my_idag]);
+					my_stats.msg_count++;
+					my_stats.distance += distance(node_id,my_idag);
+				} else {
+					fprintf(log_file,"Adam common_core.c: Did not send sig_find_idags with inter1 = %s, inter2 = %s\n",inter2string(core_inter_head[my_idag]->type),inter2string(core_inter_head[my_idag]->next->type));
+				}
+				#endif				
+
+	
 				if (selfopt_interval <= Max_SelfOpt_Interval_MS) selfopt_interval = 2 * selfopt_interval;
 				else {
 					selfopt_interval = -1;
@@ -948,8 +1006,12 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 					if (old_cores_cnt == 1) {  
 						//nodes_ended_cnt = 0;
 						row_reached = 0;
+#ifndef ARTIFICIAL_APPS_SIM
 						per_core_rows = my_app.array_size / (my_cores_count - 1);
 						rows_left = my_app.array_size % (my_cores_count - 1);
+#else
+						per_core_rows = (int) my_Speedup; /* Cutting off floating points to have a more constrained Speedup */
+#endif						
 						active_working_cores = my_cores_count - 1;
 
 						fprintf(app_log_file, "In one old core my cores are:");
@@ -964,15 +1026,23 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 
 							if (tmp_inter_list != NULL) {
 								tmp_inter_list->type = INIT_WORK_NODE;
+#ifndef ARTIFICIAL_APPS_SIM
 								tmp_inter_list->data.work_bounds[0] = row_reached;
-								tmp_cores_list->workload[0] = row_reached; /* 27.6.2016 Added by dimos. If worker fails i have to know the workload given in order to reappoint */
+								tmp_cores_list->workload[0] = row_reached; /* 27.6.2016 dimos. If worker fails i have to know the workload given in order to reappoint */
 								row_reached += per_core_rows;
 								if (rows_left > 0) {
 									row_reached++;
 									rows_left--;
 								}
 								tmp_inter_list->data.work_bounds[1] = row_reached-1;
-								tmp_cores_list->workload[1] = row_reached-1; /* 27.6.2016 Added by dimos. If worker fails i have to know the workload given in order to reappoint */
+								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
+								tmp_inter_list->data.work_bounds[0] = 0;
+                                                                tmp_cores_list->workload[0] = 0;                                
+                                
+								tmp_inter_list->data.work_bounds[1] = per_core_rows;
+                                                                tmp_cores_list->workload[1] = per_core_rows;
+#endif
 
 								fprintf(app_log_file,"%d (%d, %d), ",one_core,tmp_inter_list->data.work_bounds[0],
 									tmp_inter_list->data.work_bounds[1]);
@@ -1101,7 +1171,7 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 				my_stats.distance += distance(node_id,cur_agent.my_agent);
 
 				fprintf(log_file, "finished work pending_agent=%d pending_state=%d\n",pending_agent.my_agent,pending_state);
-			}else if (executed_app == SVM) {
+			} else if (executed_app == SVM) {
 				//printf("I enter working state -- executing SVM\n");
 				fprintf(log_file,"I enter working state -- executing SVM\n");
 				execute_workload(cur_agent.work_bounds[0], cur_agent.work_bounds[1]);
@@ -1111,7 +1181,7 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 				my_stats.distance += distance(node_id,cur_agent.my_agent);
 
 				fprintf(log_file, "finished work pending_agent=%d pending_state=%d\n",pending_agent.my_agent,pending_state);
-			}else if (executed_app == FFT) {
+			} else if (executed_app == FFT) {
 				//printf("I enter working state -- executing FFT\n");
 				fprintf(log_file,"I enter working state -- executing FFT\n");
 				execute_workload(cur_agent.work_bounds[0], cur_agent.work_bounds[1]);
@@ -1122,7 +1192,18 @@ void common_node_actions(char scen_directory[SCEN_DIR_SIZE], char scen_num[SCEN_
 				my_stats.distance += distance(node_id,cur_agent.my_agent);
 
 				fprintf(log_file, "finished work pending_agent=%d pending_state=%d\n",pending_agent.my_agent,pending_state);
-			}
+			} else if (executed_app == ARTIFICIAL) {
+                                //printf("I enter working state -- executing FFT\n");
+                                fprintf(log_file,"I enter working state -- executing ARTIFICIAL\n");
+                                execute_workload(cur_agent.work_bounds[0], cur_agent.work_bounds[1]);
+
+                                /*TODO I HAVE TO SEND BACK result TO BE TOTALLY CORRECT */
+                                scc_kill(cur_agent.my_agent, SIG_FINISH, NULL);
+                                my_stats.msg_count++;
+                                my_stats.distance += distance(node_id,cur_agent.my_agent);
+
+                                fprintf(log_file, "finished work pending_agent=%d pending_state=%d\n",pending_agent.my_agent,pending_state);
+                        }
 
 			if (pending_agent.my_agent == -1) { //den exei ginei allagh tou agent
 				/*if (state == WORKING_NODE) state = IDLE_CORE;

+ 21 - 18
my_rtrm.c

@@ -171,7 +171,7 @@ int main(int argc, char *argv[]) {
 		printf("\t-p <paxos_scen>  : <paxos_scen> = File with failure characteristics.\n");
 		printf("\t-x X             : X = X * 6 will be the horizontal dimension of the grid.\n"); 
 		printf("\t-y Y             : Y = Y * 8 will be the vertical dimension of the grid.\n");
-		printf("\t-t <app_type>    : <app_type> M for MATRIX_MUL, S for SVM, F for FFT \n");
+		printf("\t-t <app_type>    : <app_type> M for MATRIX_MUL, S for SVM, F for FFT, A for Artificial \n");
 		printf("\t-r <region_r>    : Selfopt radius \n");
 		printf("\t-u <rounds>	   : Selfopt rounds \n");
 		exit(0);
@@ -234,7 +234,7 @@ int main(int argc, char *argv[]) {
 					printf("Paxos scenario file name %s...\n", paxos_scen);
 				break;
 			case 't':
-				if (!strcmp(optarg,"M")) {
+				if (!strcmp(optarg,"M")) { /* FIXME merge 10.7.2017 executed_app and executed_app_type_number */
 					executed_app = MATRIX_MUL;
 					executed_app_type_number = 0;
 					executed_app_array_size = MATRIX_ARRAY_SIZE;
@@ -249,6 +249,10 @@ int main(int argc, char *argv[]) {
 					executed_app_type_number = 2;
 					executed_app_array_size = FFT_ARRAY_SIZE;
 					//printf("Input application type is FFT\n");
+				} else if (!strcmp(optarg,"A")) {
+					executed_app = ARTIFICIAL;
+					executed_app_type_number = 3;
+					//printf("Input application type is FFT\n");
 				} else {
 					printf("Input application type is wrong. Options are M,S,F\n");
 				}
@@ -288,7 +292,8 @@ int main(int argc, char *argv[]) {
 		RCCE_flag_write(&proposal_number_lock, RCCE_FLAG_UNSET, node_id);
 		sig_array = (int *) RCCE_malloc(MAX_SIGNAL_LIST_LEN * LINE_SIZE * sizeof(int));//NUES * NUES
 		data_array = (int *) RCCE_malloc(MAX_DATA_LIST_LEN * LINE_SIZE * sizeof(int));
-		
+
+		#ifndef ARTIFICIAL_APPS_SIM		
 		if (executed_app == MATRIX_MUL) {
 			num_of_bytes = NUES * MAX_ARRAY_SIZE * sizeof(int);
 		} else if (executed_app == SVM) {
@@ -297,7 +302,8 @@ int main(int argc, char *argv[]) {
 			num_of_bytes = NUES * FFT_ARRAY_SIZE * sizeof(float);
 		}
 		manager_result_out = (volatile int*) RCCE_shmalloc(num_of_bytes);
-		
+		#endif
+
 		num_of_bytes = NUES * sizeof(int);
 		index_bottom = (volatile int*) RCCE_shmalloc(num_of_bytes);
 		
@@ -774,26 +780,18 @@ int main(int argc, char *argv[]) {
 					}
 
 					core_inter_tail[init_core]->type = INIT_APP;
+#ifndef ARTIFICIAL_APPS_SIM
 					/* FIXME scanned for old app inputs compatibility reasons but it is discarded */
 					fscanf(app_input,"%d",&core_inter_tail[init_core]->data.new_app.array_size);
 					core_inter_tail[init_core]->data.new_app.array_size = executed_app_array_size;
+#else
+					fscanf(app_input,"%f",&core_inter_tail[init_core]->data.new_app.var);
+					fscanf(app_input,"%f",&core_inter_tail[init_core]->data.new_app.A);
+#endif					
 					fscanf(app_input,"%d",&core_inter_tail[init_core]->data.new_app.workld);
 					core_inter_tail[init_core]->data.new_app.app_type = executed_app_type_number;
 					/* FIXME for the time being, do not scan for app type. All apps are of the same type, read from argv */
-					/*
-					fscanf(app_input,"%d",&temp_scan);
-					core_inter_tail[init_core]->data.new_app.app_type = temp_scan;
-					if (temp_scan == 0){
-						printf("MATRIX_MUL\n");
-					}
-					else if (temp_scan == 1){
-						printf("SVM\n");
-					}
-					else if (temp_scan == 2){
-						printf("FFT\n");
-					}
-					*/
-		
+							
 					core_inter_tail[init_core]->data.new_app.id = app_cnt++;
 					core_inter_tail[init_core]->data.new_app.num_of_cores = 0;
 					core_inter_tail[init_core]->next = NULL;
@@ -824,8 +822,13 @@ int main(int argc, char *argv[]) {
 
 					init_pending_tail->type = INIT_APP;
 					/* FIXME scanned for old app inputs compatibility reasons but it is discarded */
+#ifndef ARTIFICIAL_APPS_SIM
 					fscanf(app_input,"%d",&init_pending_tail->data.new_app.array_size);
 					init_pending_tail->data.new_app.array_size = executed_app_array_size;
+#else
+					fscanf(app_input,"%f",&init_pending_tail->data.new_app.var);
+					fscanf(app_input,"%f",&init_pending_tail->data.new_app.A);
+#endif
 					fscanf(app_input,"%d",&init_pending_tail->data.new_app.workld);
 					core_inter_tail[init_core]->data.new_app.app_type = executed_app_type_number;
 					/* FIXME for the time being, do not scan for app type. All apps are of the same type, read from argv */

+ 11 - 4
paxos_signal_handlers.c

@@ -1029,8 +1029,10 @@ void sig_LEARN_handler(int sender_id){
 			my_app.id = worker_app_id;
 			my_app.num_of_cores = my_cores_count-1;
 			find_app_info();
+#ifndef ARTIFICIAL_APPS_SIM
 			printf("Found array size = %d\n", my_app.array_size);
 			fprintf(log_file,"Found array size = %d\n", my_app.array_size);
+#endif
 			printf("Found remaining workload = %d\n", my_app.workld);
 			fprintf(log_file,"Found remaining workload = %d\n", my_app.workld);
 			printf("App number of cores = %d\n", my_app.num_of_cores);
@@ -1138,9 +1140,11 @@ void sig_REINIT_APP_handler(int sender_id){
 	core_inter_tail[12]->next = NULL;
 	core_inter_tail[12]->type = INIT_APP;
 	core_inter_tail[12]->data.new_app.id = sig_read_ar[2];
-	core_inter_tail[12]->data.new_app.array_size = sig_read_ar[3];
+	core_inter_tail[12]->data.new_app.num_of_cores = sig_read_ar[3];
 	core_inter_tail[12]->data.new_app.workld = sig_read_ar[4];
-	core_inter_tail[12]->data.new_app.num_of_cores = sig_read_ar[5];
+#ifndef ARTIFICIAL_APPS_SIM
+	core_inter_tail[12]->data.new_app.array_size = sig_read_ar[5];
+#endif
 	if (core_inter_head[12]->next == NULL){
 		scc_kill(12, SIG_INIT_APP, core_inter_head[12]);
 	}
@@ -1175,12 +1179,15 @@ void find_app_info(){
 		}
 		
 		while (fscanf(app_log_file,"%s", buffer) != EOF){
+#ifndef ARTIFICIAL_APPS_SIM
 			if (strcmp(buffer,"array_size") == 0){
 				fscanf(app_log_file,"%s",buffer);
 				fscanf(app_log_file,"%d", &temp);
 				my_app.array_size = temp;
 			}
-			
+#else
+			/* FIXME must locate var and A */
+#endif			
 			if (strcmp(buffer,"workload") == 0){
 				fscanf(app_log_file,"%s",buffer);
 				fscanf(app_log_file,"%d",&temp);
@@ -2104,4 +2111,4 @@ void sig_PAXOS_STATS_REP_handler(int sender_id){
 	fprintf(log_file, "\n\n[%d:%d:%d]: I ended sig_PAXOS_STATS_REP_handler with sender = %d state = %s\n",cur_t->tm_hour,cur_t->tm_min,cur_t->tm_sec,sender_id,id2string(state));
 	
   
-}
+}

+ 53 - 49
scc_signals.c

@@ -61,18 +61,16 @@ int scc_kill(int target_ID, int sig, inter_list *ref_inter_list) {
 			fprintf(log_file,"\t\tI enter here with target_ID %d and sig %s {%d} type = %s\n",target_ID,sig2string(sig), sig_array_local[1], inter2string(ref_inter_list->type));
 		
 		if (ref_inter_list->type == INIT_APP) {
-			/*sig_array_local[2] = ref_inter_list->data.new_app.id;
-			sig_array_local[3] = ref_inter_list->data.new_app.array_size;
-			sig_array_local[4] = ref_inter_list->data.new_app.workld;
-			sig_array_local[5] = ref_inter_list->data.new_app.num_of_cores;
-			sig_array_local[6] = ref_inter_list->data.new_app.app_type;*/
-			
 			sig_array_local[2] = ref_inter_list->data.new_app.id;
-			sig_array_local[3] = ref_inter_list->data.new_app.array_size;
+			sig_array_local[3] = ref_inter_list->data.new_app.app_type;
 			sig_array_local[4] = ref_inter_list->data.new_app.workld;
 			sig_array_local[5] = ref_inter_list->data.new_app.num_of_cores;
-			sig_array_local[6] = ref_inter_list->data.new_app.app_type;
-		
+#ifndef ARTIFICIAL_APPS_SIM
+			sig_array_local[6] = ref_inter_list->data.new_app.array_size;
+#else
+			memcpy(&sig_array_local[6],&ref_inter_list->data.new_app.var,sizeof(int));
+			memcpy(&sig_array_local[7],&ref_inter_list->data.new_app.A,sizeof(int));
+#endif
 			//my_stats.message_size += sizeof(app);
 			//clear = 1;
 		} else if (ref_inter_list->type == IDAG_FIND_IDAGS_PENDING || ref_inter_list->type == SELFOPT_IDAG_FIND_IDAGS_PENDING) {//I am the requesting common node
@@ -117,36 +115,38 @@ int scc_kill(int target_ID, int sig, inter_list *ref_inter_list) {
 			else	
 				sig_array_local[2] = ref_inter_list->data.agents_in_reg[0];
 		} else if (ref_inter_list->type == AGENT_REQ_CORES_PENDING) {
-			//my_stats.message_size += sizeof(app);
 			sig_array_local[2] = init_app.id;
-			sig_array_local[3] = init_app.array_size;
+			sig_array_local[3] = init_app.app_type;
 			sig_array_local[4] = init_app.workld;
 			sig_array_local[5] = init_app.num_of_cores;
-			sig_array_local[6] = init_app.app_type;
-			
-			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); 
-			sig_array_local[6] = ref_inter_list->data.reg_arr.region_arr[0].C;
-			sig_array_local[7] = ref_inter_list->data.reg_arr.region_arr[0].r;
-			//my_stats.message_size += sizeof(region);
-			
-			//ref_inter_list->type = AGENT_REQ_CORES;
+#ifndef ARTIFICIAL_APPS_SIM
+			sig_array_local[6] = init_app.array_size;
+#else
+			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);
 		} else if (ref_inter_list->type == SELFOPT_REQ_CORES_PENDING) {
-			//my_stats.message_size += sizeof(app);
-
 			sig_array_local[2] = my_app.id;
-			sig_array_local[3] = my_app.array_size;
+			sig_array_local[3] = my_app.app_type;
 			sig_array_local[4] = my_app.workld;
 			sig_array_local[5] = my_app.num_of_cores;
-			
-			sig_array_local[6] = ref_inter_list->data.reg_arr.region_arr[0].C;
-			sig_array_local[7] = ref_inter_list->data.reg_arr.region_arr[0].r;
-			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);
-			//my_stats.message_size += sizeof(region);
-
-			//ref_inter_list->type = SELFOPT_REQ_CORES;
+#ifndef ARTIFICIAL_APPS_SIM
+			sig_array_local[6] = my_app.array_size;
+#else
+			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);
 		} else if (ref_inter_list->type == REP_AGENT_REQ_CORES) {//I am the agent
 			/* pre write these info and keep data_array only for cores. Besides, a great amount of offers will be zero */
@@ -169,17 +169,16 @@ int scc_kill(int target_ID, int sig, inter_list *ref_inter_list) {
 				cur_t = localtime(&time_val.tv_sec);
 				//fprintf(app_log_file,"[%d:%d:%d:%ld] I init work to %d\n",cur_t->tm_hour,cur_t->tm_min,cur_t->tm_sec,time_val.tv_usec,target_ID);
 				//fflush(app_log_file);
-				//i=1;
 				
 				/* 2.7.2016 - Changed by dimos - Instead of valid i send the app_id */
 				sig_array_local[2] = my_app.id;
-				
 				sig_array_local[3] = node_id;
-
-				sig_array_local[4] = my_app.array_size;
+				sig_array_local[4] = my_app.app_type;
 				sig_array_local[5] = ref_inter_list->data.work_bounds[0];
 				sig_array_local[6] = ref_inter_list->data.work_bounds[1];
-				sig_array_local[7] = my_app.app_type;
+#ifndef ARTIFICIAL_APPS_SIM
+				sig_array_local[7] = my_app.array_size;
+#endif
 				/********/
 				fprintf(log_file, "work_time1=%d work_time2=%d\n",ref_inter_list->data.work_bounds[0],ref_inter_list->data.work_bounds[1]);
 				fflush(log_file);
@@ -200,10 +199,11 @@ int scc_kill(int target_ID, int sig, inter_list *ref_inter_list) {
 				
 				/* 2.7.2016 - Changed by dimos - Instead of valid i send the app_id */
 				sig_array_local[2] = my_app.id;
+				/* 12.7.2017 Changed the order to be consistent with INIT_WORK_NODE */
+				sig_array_local[4] = my_app.app_type;	
+				sig_array_local[5] = ref_inter_list->data.work_bounds[0];
+				sig_array_local[6] = ref_inter_list->data.work_bounds[1];
 				
-				sig_array_local[3] = ref_inter_list->data.work_bounds[0];
-				sig_array_local[4] = ref_inter_list->data.work_bounds[1];
-				sig_array_local[7] = my_app.app_type;
 				fprintf(log_file, "work_time1=%d work_time2=%d\n",ref_inter_list->data.work_bounds[0],ref_inter_list->data.work_bounds[1]);
 				//my_stats.message_size += 3 * sizeof(int);
 			} else {
@@ -238,8 +238,7 @@ int scc_kill(int target_ID, int sig, inter_list *ref_inter_list) {
 					fflush(log_file);
 				}
 			} else {
-				//I am an idag and i have to send to other idags my original sender
-				
+				//I am an idag and i have to send to other idags my original sender		
 				sig_array_local[3] = ref_inter_list->data.app_cores[ref_inter_list->data.app_cores[0]+1];
 				fprintf(log_file, "orig_sender=%d\n",ref_inter_list->data.app_cores[ref_inter_list->data.app_cores[0]+1]);
 				fflush(log_file);
@@ -356,9 +355,11 @@ int scc_kill(int target_ID, int sig, inter_list *ref_inter_list) {
 		} else if (ref_inter_list-> type == REINIT_APP){
 			paxos_node_stats.msg_count++;
 			sig_array_local[2] = ref_inter_list->data.reappointed_app.id;
-			sig_array_local[3] = ref_inter_list->data.reappointed_app.array_size;
-			sig_array_local[4] = ref_inter_list->data.reappointed_app.workld;
-			sig_array_local[5] = ref_inter_list->data.reappointed_app.num_of_cores;
+			sig_array_local[3] = ref_inter_list->data.reappointed_app.workld;
+			sig_array_local[4] = ref_inter_list->data.reappointed_app.num_of_cores;
+#ifndef ARTIFICIAL_APPS_SIM
+			sig_array_local[5] = ref_inter_list->data.reappointed_app.array_size;	
+#endif
 		} else if (ref_inter_list->type == ADD_TO_DDS){
 			paxos_node_stats.msg_count++;
 			sig_array_local[2] = ref_inter_list->data.workers_info[0];
@@ -387,10 +388,15 @@ int scc_kill(int target_ID, int sig, inter_list *ref_inter_list) {
 			  paxos_node_stats.fd_msg_count++;
 		} else if (ref_inter_list->type == INIT_AGENT){
 			sig_array_local[2] = ref_inter_list->data.one_app.new_app.id;
-			sig_array_local[3] = ref_inter_list->data.one_app.new_app.array_size;
+			sig_array_local[3] = ref_inter_list->data.one_app.new_app.app_type;
 			sig_array_local[4] = ref_inter_list->data.one_app.new_app.workld;
 			sig_array_local[5] = ref_inter_list->data.one_app.new_app.num_of_cores;
-			sig_array_local[6] = ref_inter_list->data.one_app.new_app.app_type;
+#ifndef ARTIFICIAL_APPS_SIM
+			sig_array_local[6] = ref_inter_list->data.one_app.new_app.array_size;
+#else
+			memcpy(&sig_array_local[6],&ref_inter_list->data.one_app.new_app.var,sizeof(int));
+			memcpy(&sig_array_local[7],&ref_inter_list->data.one_app.new_app.A,sizeof(int));
+#endif
 		}
 		/* END*/
 		
@@ -549,7 +555,7 @@ void scc_signals_check(void) {
 			} 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);
+				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) {
@@ -560,8 +566,6 @@ void scc_signals_check(void) {
 				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);
-				//sig_APPOINT_WORK_handler(sender_id);
-				//increase_cnt = 2;
 			} 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) {

+ 333 - 169
signal_handlers.c

@@ -356,15 +356,12 @@ void sig_TERMINATE_handler(int sender_id){
 }
 
 void sig_INIT_APP_handler(int sender_id){
-	
 	inter_list *tmp_inter_list, *tmp_inter_prev;	
 	#ifdef PLAT_SCC
 	int error, str_len;
 	char error_str[64];
 	#endif	
-		
-	
-	
+
 	cur_time = time(NULL);	
 	cur_t = localtime(&cur_time);
 	fprintf(log_file, "\n\n[%d:%d:%d]: I entered sig_INIT_APP_handler with sender=%d state=%s pending_state=%s my_cores_count=%d\n",cur_t->tm_hour,cur_t->tm_min,cur_t->tm_sec,sender_id,id2string(state),id2string(pending_state),my_cores_count);
@@ -445,19 +442,21 @@ void sig_INIT_APP_handler(int sender_id){
 		scc_kill(sender_id, SIG_ACK, NULL);
 		my_stats.msg_count++;
 		my_stats.distance += distance(node_id,sender_id);
-		
-		/*init_app.id = sig_read_ar[2];
-		init_app.array_size = sig_read_ar[3];
-		init_app.workld = sig_read_ar[4];
-		init_app.num_of_cores = sig_read_ar[5];*/
-		
+				
 		init_app.id = sig_read_ar[2];
-		init_app.array_size = sig_read_ar[3];
+		init_app.app_type = sig_read_ar[3];		
 		init_app.workld = sig_read_ar[4];
 		init_app.num_of_cores = sig_read_ar[5];
-		init_app.app_type = sig_read_ar[6];
-		
-		fprintf(log_file,"\t\tMy app is id = %d, array_size = %d, cores = %d, app_type = %d\n",init_app.id,init_app.array_size,init_app.num_of_cores, init_app.app_type);
+#ifndef ARTIFICIAL_APPS_SIM		
+		init_app.array_size = sig_read_ar[6];
+		fprintf(log_file,"\t\tMy app is id = %d, array_size = %d, cores = %d, app_type = %d\n",init_app.id,init_app.array_size,init_app.num_of_cores,init_app.app_type);
+#else
+		memcpy(&init_app.var,&sig_read_ar[6],sizeof(int));
+		memcpy(&init_app.A,&sig_read_ar[7],sizeof(int));
+
+		/* printing order maintained for python scripts compatibility */
+		fprintf(log_file,"\t\tMy app is id = %d, var = %f, cores = %d, app_type = %d, A = %f\n",init_app.id,init_app.var,init_app.num_of_cores,init_app.app_type,init_app.A);
+#endif
 
 		gettimeofday(&time_val, NULL);
 		cur_t = localtime(&time_val.tv_sec);
@@ -691,7 +690,6 @@ void sig_ACK_handler(int sender_id){
 			sem_post(&flag_data_written[sender_id]);
 // 			fprintf(log_file,"I free flag_data_written lock %d\n", sender_id);
 			#endif
-
 	
 			fprintf(log_file, "\t\tnode_id=%d\n",node_id);
 			my_stats.message_size += sizeof(int);
@@ -704,14 +702,10 @@ void sig_ACK_handler(int sender_id){
 			fflush(init_ack_file);
 			my_stats.message_size += sizeof(app);
 		} else if (tmp_inter_list->type == IDAG_FIND_IDAGS_PENDING || tmp_inter_list->type == SELFOPT_IDAG_FIND_IDAGS_PENDING) {//I am the requesting common node
-			if (tmp_inter_list->type == IDAG_FIND_IDAGS_PENDING){
-			  
+			if (tmp_inter_list->type == IDAG_FIND_IDAGS_PENDING) {
 				tmp_inter_list->type = IDAG_FIND_IDAGS;
-				
-			}else if (tmp_inter_list->type == SELFOPT_IDAG_FIND_IDAGS_PENDING){
-			  
+			} else if (tmp_inter_list->type == SELFOPT_IDAG_FIND_IDAGS_PENDING) {
 				tmp_inter_list->type = SELFOPT_IDAG_FIND_IDAGS;
-				
 			}
 
 			my_stats.message_size += sizeof(region);
@@ -719,16 +713,18 @@ void sig_ACK_handler(int sender_id){
 		} else if (core_inter_head[sender_id]->type == IDAG_REQ_DDS_PENDING || core_inter_head[sender_id]->type == SELFOPT_IDAG_REQ_DDS_PENDING || core_inter_head[sender_id]->type == DEBUG_IDAG_REQ_DDS){
 			my_stats.message_size += sizeof(region);
 
-			if (core_inter_head[sender_id]->type == IDAG_REQ_DDS_PENDING) core_inter_head[sender_id]->type = IDAG_REQ_DDS;
-		 	else if (core_inter_head[sender_id]->type == SELFOPT_IDAG_REQ_DDS_PENDING) core_inter_head[sender_id]->type = SELFOPT_IDAG_REQ_DDS;
+			if (core_inter_head[sender_id]->type == IDAG_REQ_DDS_PENDING) {
+				core_inter_head[sender_id]->type = IDAG_REQ_DDS;
+		 	} else if (core_inter_head[sender_id]->type == SELFOPT_IDAG_REQ_DDS_PENDING) {
+				core_inter_head[sender_id]->type = SELFOPT_IDAG_REQ_DDS;
+			}
 
 			clear = 0;
 		} else if (tmp_inter_list->type == REP_IDAG_FIND_IDAGS) {//I am the idag
 			fprintf(log_file, "\t\tnum_of_idags=%d\n",tmp_inter_list->data.idags_in_reg[num_idags]);
 			my_stats.message_size += sizeof(int);
 			my_stats.message_size += tmp_inter_list->data.idags_in_reg[num_idags]*sizeof(int);
-			/* Changed on 12.7.2016 */
-			
+			/* Changed on 12.7.2016 */			
 		} else if (tmp_inter_list->type == REP_IDAG_REQ_DDS) {//I am the idag
 			if (tmp_inter_list->data.agents_in_reg == NULL) {//debugging
 				fprintf(log_file, "\t\tIn null rep_idag_dds with sender %d and DDS_count %d\n",sender_id,DDS_count);
@@ -835,7 +831,6 @@ void sig_ACK_handler(int sender_id){
 				core_inter_head[sender_id]->type = AGENT_OFFER_SENT;
 				clear = 0;
 			
-
 				//fprintf(log_file,"Cores: ");
 				//fflush(log_file);
 				//for (i=0; i<LINE_SIZE; i++)
@@ -865,13 +860,8 @@ void sig_ACK_handler(int sender_id){
 			my_stats.message_size += sizeof(int);
 			free(tmp_inter_list->data.offer_acc_array);	
 		} else if (tmp_inter_list->type == INIT_AGENT) {
-			//data_array_local[0] = tmp_inter_list->data.one_app.new_app.id;
-			//data_array_local[1] = tmp_inter_list->data.one_app.new_app.array_size;
-			//data_array_local[2] = tmp_inter_list->data.one_app.new_app.workld;
-			//data_array_local[3] = tmp_inter_list->data.one_app.new_app.num_of_cores;
-			//fprintf(log_file, "\t\tid=%d array_size=%d workld=%d num_of_cores=%d\n",data_array_local[0],data_array_local[1],data_array_local[2],data_array_local[3]);
-	
 			my_stats.message_size += sizeof(app);
+			
 			for (i=0; i<tmp_inter_list->data.one_app.new_app.num_of_cores; i++){
 				data_array_local[0*LINE_SIZE+i] = tmp_inter_list->data.one_app.new_app_cores[i];
 
@@ -888,9 +878,7 @@ void sig_ACK_handler(int sender_id){
 			data_array_local[1*LINE_SIZE+6] = tmp_inter_list->data.one_app.new_app_times[1].tm_hour;
 			data_array_local[1*LINE_SIZE+7] = tmp_inter_list->data.one_app.new_app_times[1].tm_usec;
 
-			//write_res = write(fd_w, &init_app_times[0], sizeof(my_time_stamp));
 			fprintf(log_file, "\t\tsec=%d min=%d hours=%d\n",init_app_times[0].tm_sec,init_app_times[0].tm_min,init_app_times[0].tm_hour);
-			//write_res = write(fd_w, &init_app_times[1], sizeof(my_time_stamp));
 			fprintf(log_file, "\t\tsec=%d min=%d hours=%d\n",init_app_times[1].tm_sec,init_app_times[1].tm_min,init_app_times[1].tm_hour);
 
 			#ifdef PLAT_SCC
@@ -930,7 +918,6 @@ void sig_ACK_handler(int sender_id){
 			scc_kill(0, SIG_INIT_APP, NULL);
 			my_stats.msg_count++;
 			my_stats.distance += distance(node_id,idag_id_arr[0]);
-
 		} else if (tmp_inter_list->type == IDAG_ADD_CORES_DDS) {
 			
 			//data_array_local[0] = tmp_inter_list->data.app_cores[0];
@@ -1159,40 +1146,6 @@ void sig_IDAG_FIND_IDAGS_handler(int sender_id, int *inc_cnt, int cur_index_top)
 			}
 		} else send_next_signal(core_inter_head[sender_id], sender_id);
 	} else if (core_inter_head[sender_id]->type == IDAG_FIND_IDAGS || core_inter_head[sender_id]->type == SELFOPT_IDAG_FIND_IDAGS) { //I am the requesting common node
-		/*#ifdef PLAT_SCC
-		//kill(info->si_pid, SIG_ACK);
-		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);			
-		my_stats.msg_count++;
-		my_stats.distance += distance(node_id,sender_id);
-				
-		//read(fd_r, &num_of_idags, sizeof(int));
-		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_IDAG_FIND_IDAGS_handler from %d with descr %s\n",node_id,sender_id,error_str);
-		}
-		#else
-		num_of_idags = sig_read_ar[2];
-		
-		while(1){
-			sem_getvalue(&flag_data_written[node_id],&sem_v);
-			if (sem_v == 0){
-				cnt++;
-				if (cnt > 2147483640) {
-				  printf("We are fucked!!!\n");
-				  break;
-				}
-			}else break;
-		}
-		sem_wait(&flag_data_written[node_id]);
-		fprintf(log_file,"After log\n");
-
-		my_RCCE_get(&data_array_local[0], &data_array[0], LINE_SIZE, node_id);
-		fprintf(log_file,"After RCCE\n");
-		#endif*/
 		fprintf(log_file,"4th case\n");
 		scc_kill(sender_id, SIG_ACK, core_inter_head[sender_id]);
 		num_of_idags = sig_read_ar[2];
@@ -1302,7 +1255,9 @@ void sig_REQ_DDS_handler(int sender_id){
 	int error, str_len;
 	char error_str[64];	
 	#endif
-
+	#ifdef ADAM_SIM
+	int cur_max_agent, cur_max_cores, cur_max_occurences, tmp_integer_matrix[NUES];	
+	#endif
 	
 	cur_time = time(NULL);	
 	cur_t = localtime(&cur_time);
@@ -1340,22 +1295,31 @@ void sig_REQ_DDS_handler(int sender_id){
 			}
 		
 			tmp_cores_list = my_cores;
-			while (tmp_cores_list != NULL){
-				if (distance(tmp_cores_list->core_id, cur_reg.C) <= cur_reg.r){
-					if (tmp_cores_list->offered_to == -1) agent_id=node_id;
-					else {
+			while (tmp_cores_list != NULL) {
+				if (distance(tmp_cores_list->core_id, cur_reg.C) <= cur_reg.r) { /* Search inside specific region to identify Managers */
+					if (tmp_cores_list->offered_to == -1) {
+						agent_id=node_id;
+					} else {
 						agent_id=tmp_cores_list->offered_to;	
-						for (tmp_DDS = DDS->next; tmp_DDS!=NULL; tmp_DDS=tmp_DDS->next) if (tmp_DDS->agent_id == agent_id) break;
-						if (tmp_DDS == NULL) agent_id = node_id;
+						for (tmp_DDS = DDS->next; tmp_DDS!=NULL; tmp_DDS=tmp_DDS->next) {
+							if (tmp_DDS->agent_id == agent_id) {
+								break;
+							}
+						}
+
+						if (tmp_DDS == NULL) {
+							agent_id = node_id;
+						}
 					}
 
-					for (i=1; i<=2*DDS_count; i+=2)
+					for (i=1; i<=2*DDS_count; i+=2) {
 						if (core_inter_tail[sender_id]->data.agents_in_reg[i] == agent_id) break;
-						else if (core_inter_tail[sender_id]->data.agents_in_reg[i] == -1){
+						else if (core_inter_tail[sender_id]->data.agents_in_reg[i] == -1) {
 							core_inter_tail[sender_id]->data.agents_in_reg[0]++;
 							core_inter_tail[sender_id]->data.agents_in_reg[i] = agent_id;
 							break;
 						}
+					}
 					core_inter_tail[sender_id]->data.agents_in_reg[i+1]++;
 				}
 
@@ -1363,7 +1327,40 @@ void sig_REQ_DDS_handler(int sender_id){
 			}
 		} else core_inter_tail[sender_id]->data.agents_in_reg = NULL;
  
-		//kill(info->si_pid, SIG_REQ_DDS);
+		#ifdef ADAM_SIM
+		tmp_inter_list = core_inter_tail[sender_id];
+		fprintf(log_file, "\t\tnum_of_agents=%d\n",tmp_inter_list->data.agents_in_reg[0]);
+		
+		cur_max_agent = -1;
+		cur_max_cores = -1;
+		cur_max_occurences = 0; /* Get all agents with maximum cores */
+		
+		for (i=1; i<=2*tmp_inter_list->data.agents_in_reg[0]; i+=2){
+			fprintf(log_file, "\t\tagent=%d cores=%d\n",tmp_inter_list->data.agents_in_reg[i],tmp_inter_list->data.agents_in_reg[i+1]);
+			 
+			if (tmp_inter_list->data.agents_in_reg[i+1] > cur_max_cores) {
+				cur_max_cores = tmp_inter_list->data.agents_in_reg[i+1];
+				cur_max_agent = tmp_inter_list->data.agents_in_reg[i];
+			  	cur_max_occurences = 1;
+				tmp_integer_matrix[cur_max_occurences-1] = tmp_inter_list->data.agents_in_reg[i];
+			} else if (tmp_inter_list->data.agents_in_reg[i+1] == cur_max_cores) {
+				cur_max_occurences++;
+				tmp_integer_matrix[cur_max_occurences-1] = tmp_inter_list->data.agents_in_reg[i];	
+			} else {
+			}
+		}
+	
+		if (cur_max_occurences >= 1) {
+			tmp_inter_list->data.agents_in_reg[0] = cur_max_occurences;
+			for (i=0; i<cur_max_occurences; i++) {
+				tmp_inter_list->data.agents_in_reg[2*i+1] = tmp_integer_matrix[i];
+				tmp_inter_list->data.agents_in_reg[2*i+2] = cur_max_cores;			
+			} 			
+		} else {
+			fprintf(log_file,"Error: cur_max_occurences = %d\n",cur_max_occurences);	
+		}	
+		#endif
+
 		scc_kill(sender_id, SIG_REQ_DDS, core_inter_head[sender_id]);
 		my_stats.msg_count++;
 		my_stats.distance += distance(node_id,sender_id);
@@ -1719,7 +1716,7 @@ void sig_REQ_DDS_handler(int sender_id){
 	return;
 }
 
-void sig_REQ_CORES_handler(int sender_id){
+void sig_REQ_CORES_handler(int sender_id, int *inc_cnt, int cur_index_top) {
 	
 	int i, tmp_int, num_of_offers, j, non_zero_offers=0, cores_util, data_array_local[2 * LINE_SIZE];//num_of_idags, i, one_idag;
 	float req_gain;
@@ -1740,36 +1737,50 @@ void sig_REQ_CORES_handler(int sender_id){
 	fprintf(log_file, "[%d:%d:%d]: I entered sig_REQ_CORES_handler with sender = %d state = %s\n",cur_t->tm_hour,cur_t->tm_min,cur_t->tm_sec,sender_id,id2string(state));
 	fflush(log_file);	
 		
-	if (core_inter_head[sender_id] == NULL && my_cores != NULL) { 
-		/*RCCE_flag_write(&flag_data_written, RCCE_FLAG_UNSET, node_id);
-		scc_kill(sender_id, SIG_ACK);
-
-		RCCE_wait_until(flag_data_written, RCCE_FLAG_SET);
+	if (core_inter_head[sender_id] == NULL && my_cores != NULL) {
+		*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 */
+		#ifdef PLAT_SCC
+		RCCE_acquire_lock(node_id);
+		#else
+		sem_wait(&scc_lock[node_id]);
+		#endif
 	
-		my_stats.msg_count++;
-		my_stats.distance += distance(node_id,sender_id);
-
-		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);
-		}
-
-		req_app.id = data_array_local[0];
-		req_app.array_size = data_array_local[1];
-		req_app.workld = data_array_local[2];
-		req_app.num_of_cores = data_array_local[3];*/
+		#ifdef PLAT_SCC
+			error = RCCE_get((t_vcharp)(&sig_read_ar[LINE_SIZE]), (t_vcharp)(&sig_array[(cur_index_top+1)*LINE_SIZE]), LINE_SIZE * sizeof(int), node_id);
+			RCCE_release_lock(node_id);
+			
+			if (error != RCCE_SUCCESS) {
+				RCCE_error_string(error, error_str, &str_len);
+				fprintf(log_file,"I got an error in get data in sig_ADD_CORES_DDS_handler from %d with descr %s\n",sender_id,error_str);
+				fflush(log_file);
+			}
+		#else
+			/* 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);		
 		my_stats.msg_count++;
 		my_stats.distance += distance(node_id,sender_id);
 		req_app.id = sig_read_ar[2];
-		req_app.array_size = sig_read_ar[3];
+		req_app.app_type = sig_read_ar[3];
 		req_app.workld = sig_read_ar[4];
 		req_app.num_of_cores = sig_read_ar[5];
-		
+#ifndef ARTIFICIAL_APPS_SIM
+		req_app.array_size = sig_read_ar[6];
+
 		fprintf(log_file,"id = %d size = %d workld = %d cores = %d\n",req_app.id,req_app.array_size,req_app.workld,req_app.num_of_cores);
 		fflush(log_file);
+#else
+		memcpy(&req_app.var,&sig_read_ar[6],sizeof(int));
+		memcpy(&req_app.A,&sig_read_ar[7],sizeof(int));
 
+		/* FIXME printing queue maintainted for python scripts compatibility */
+		fprintf(log_file,"id = %d var = %f workld = %d cores = %d A = %f\n",req_app.id,req_app.var,req_app.workld,req_app.num_of_cores,req_app.A);
+		fflush(log_file);
+#endif
 		if (req_app.num_of_cores < 0) {
 			fprintf(log_file,"Num of cores is %d. Changing to 0\n",req_app.num_of_cores);
 			fflush(log_file);
@@ -1785,19 +1796,15 @@ void sig_REQ_CORES_handler(int sender_id){
 		}
 
 		core_inter_tail[sender_id]->type = REP_AGENT_REQ_CORES;
-		/*off_arr.num_of_offers = data_array_local[4];
 		
-		if (off_arr.num_of_offers > 1) {
-			fprintf(log_file,"I got num of offers greater than %d\n",off_arr.num_of_offers);
-			fflush(log_file);
-		}*/
 		off_arr.num_of_offers = 1;
 		off_arr.offer_arr = (offer *) malloc(off_arr.num_of_offers * sizeof(offer));
 		core_inter_tail[sender_id]->next = NULL;
 
-		//for (i=0; i<off_arr.num_of_offers; i++) {
-		cur_reg.C = sig_read_ar[6];
-		cur_reg.r = sig_read_ar[7];
+		cur_reg.C = sig_read_ar[8];
+		cur_reg.r = sig_read_ar[9];
+		fprintf(log_file,"Searching in C = %d r = %d\n",cur_reg.C,cur_reg.r);
+                fflush(log_file);
 	
 		i = 0;
 		if (my_idag == -1) {
@@ -1867,7 +1874,6 @@ void sig_REQ_CORES_handler(int sender_id){
 			}
 
 		if (core_inter_head[sender_id]->next == NULL) {
-			//kill(info->si_pid, SIG_REQ_CORES);
 			scc_kill(sender_id, SIG_REQ_CORES, core_inter_head[sender_id]);
 			my_stats.msg_count++;
 			my_stats.distance += distance(node_id,sender_id);
@@ -2395,21 +2401,21 @@ void sig_INIT_AGENT_handler(int sender_id){
 		my_cores_count = 0;
 	} 
 
-	//read(fd_r, &my_app, sizeof(app));
-	/*my_app.id = data_array_local[0];	
-	memcpy(&my_app.A,&data_array_local[1],sizeof(int));
-	memcpy(&my_app.var,&data_array_local[2],sizeof(int));
-	memcpy(&my_app.workld,&data_array_local[3],sizeof(int));	
-	my_app.num_of_cores = data_array_local[4];*/
 	my_app.id = sig_read_ar[2];
-	my_app.array_size = sig_read_ar[3];
+	my_app.app_type = sig_read_ar[3];
 	my_app.workld = sig_read_ar[4];
 	my_app.num_of_cores = sig_read_ar[5];
-	my_app.app_type = sig_read_ar[6];
-
+#ifndef ARTIFICIAL_APPS_SIM
+	my_app.array_size = sig_read_ar[6];
 	fprintf(log_file, "id=%d array_size=%d workld=%d num_of_cores=%d app_type=%d\n",my_app.id,my_app.array_size,my_app.workld,my_app.num_of_cores,my_app.app_type);
+#else
+	memcpy(&my_app.var,&sig_read_ar[6],sizeof(int));
+	memcpy(&my_app.A,&sig_read_ar[7],sizeof(int));
+
+	/* FIXME printing order maintained for python scripts compatibility */
+	fprintf(log_file, "id=%d var=%f workld=%d num_of_cores=%d app_type=%d A=%f\n",my_app.id,my_app.var,my_app.workld,my_app.num_of_cores,my_app.app_type,my_app.A);
+#endif	
 	fflush(log_file);
-	//req_app.array_size = data_array_local[0];
 	
 	my_cores_count = my_app.num_of_cores;//+1;
 	if (my_cores == NULL) {
@@ -2508,7 +2514,7 @@ void sig_INIT_AGENT_handler(int sender_id){
 	//printf("Init ok!! my_cores_count = %d app_cores=%d app_id=%d\n",my_cores_count,my_app.num_of_cores,my_app.id);
 	cur_time = time(NULL);	
 	cur_t = localtime(&cur_time);
-	fprintf(log_file, "[%d:%d:%d]: Init ok!! my_cores_count = %d app_id=%d\n",cur_t->tm_hour,cur_t->tm_min,cur_t->tm_sec,my_cores_count,my_app.id);
+	fprintf(log_file, "[%d:%d:%d]: Init ok!! my_cores_count = %d app_id=%d my_Speedup= %.2f\n",cur_t->tm_hour,cur_t->tm_min,cur_t->tm_sec,my_cores_count,my_app.id,my_Speedup);
 	fprintf(log_file, "my cores are:");
 	for (tmp_core=my_cores; tmp_core!=NULL; tmp_core=tmp_core->next) fprintf(log_file, " %d", tmp_core->core_id);
 	fprintf(log_file, "\n");
@@ -2562,6 +2568,9 @@ void sig_ADD_CORES_DDS_handler(int sender_id, int *inc_cnt, int cur_index_top){
 	int error, str_len;
 	char error_str[64];
 	#endif
+	#ifdef ADAM_SIM
+	DDS_list *tmp_DDS2;
+	#endif
 
 	cur_time = time(NULL);	
 	cur_t = localtime(&cur_time);
@@ -2678,12 +2687,14 @@ void sig_ADD_CORES_DDS_handler(int sender_id, int *inc_cnt, int cur_index_top){
 				}
 
 				tmp_DDS = DDS;
-				while (tmp_DDS != NULL && tmp_DDS->agent_id != new_agent_id)
+				while (tmp_DDS != NULL && tmp_DDS->agent_id != new_agent_id) {
 					tmp_DDS = tmp_DDS->next;
+				}
 
-				if (tmp_DDS != NULL)
+#ifndef ADAM_SIM
+				if (tmp_DDS != NULL) {
 					tmp_DDS->num_of_cores += nodes_cnt;
-				else {
+				} else {
 					//printf("I am in here DDSing nodes_cnt=%d\n",nodes_cnt);
 					DDS_tail->next = (DDS_list *) malloc(sizeof(DDS_list));
 					DDS_tail = DDS_tail->next;
@@ -2691,7 +2702,45 @@ void sig_ADD_CORES_DDS_handler(int sender_id, int *inc_cnt, int cur_index_top){
 					DDS_tail->num_of_cores = nodes_cnt;
 					DDS_tail->next = NULL;
 					DDS_count++;
-				}	
+				}
+#else
+				if (tmp_DDS != NULL) {
+					tmp_DDS->num_of_cores += nodes_cnt;
+					
+					/* tmp_DDS out */
+					tmp_DDS->prev->next = tmp_DDS->next; /* Remove the link in the list */
+					tmp_DDS->next->prev = tmp_DDS->prev;
+				} else { /* Create new node */
+					tmp_DDS = (DDS_list *) malloc(sizeof(DDS_list));
+					tmp_DDS->agent_id = new_agent_id;
+					tmp_DDS->num_of_cores = nodes_cnt;
+					DDS_count++;
+				}
+				
+				/* Insert sorted */
+				if (tmp_DDS->num_of_cores > DDS->num_of_cores) { /* Check if it must be placed first */
+					tmp_DDS2 = DDS;
+					DDS = tmp_DDS;
+					DDS->next = tmp_DDS2;
+					DDS->prev = NULL;
+					tmp_DDS2->prev = DDS;
+				} else if (tmp_DDS->num_of_cores < DDS_tail->num_of_cores) { /* Check if it must be placed last */
+					DDS_tail->next = tmp_DDS;
+					tmp_DDS->prev = DDS_tail;
+					DDS_tail = DDS_tail->next;
+					DDS_tail->next = NULL;
+				} else {
+					tmp_DDS2 = DDS;
+					while ((tmp_DDS2->next != NULL) && (tmp_DDS->num_of_cores <= tmp_DDS2->next->num_of_cores)) {		
+						/* tmp_DDS in between tmp_DDS2 and tmp_DDS2->next */
+						tmp_DDS->next = tmp_DDS2->next;
+						tmp_DDS2->next->prev = tmp_DDS;
+						
+						tmp_DDS2->next = tmp_DDS;
+						tmp_DDS->prev = tmp_DDS2;	
+					}						
+				}
+#endif		
 			}
 		}
 	} else {
@@ -2789,7 +2838,10 @@ void sig_REM_CORES_DDS_handler(int sender_id, int *inc_cnt, int cur_index_top){
 	int error, str_len;
 	char error_str[64];
 	#endif	
-	
+	#ifdef ADAM_SIM
+	DDS_list *tmp_DDS2;
+	#endif	
+
 	cur_time = time(NULL);	
 	cur_t = localtime(&cur_time);
 	fprintf(log_file, "[%d:%d:%d]: I entered sig_REM_CORES_DDS_handler with sender = %d state = %s\n",cur_t->tm_hour,cur_t->tm_min,cur_t->tm_sec,sender_id,id2string(state));
@@ -3002,20 +3054,58 @@ void sig_REM_CORES_DDS_handler(int sender_id, int *inc_cnt, int cur_index_top){
 			tmp_DDS = tmp_DDS->next;
 		}
 
-		if (tmp_DDS == NULL) printf("Agent does not exist in my DDS\n");
-		else if (tmp_DDS == DDS) printf("I am removing from myself in REM?\n");
-		else {
+		if (tmp_DDS == NULL) {
+			fprintf(log_file,"Agent does not exist in my DDS\n");
+		} else if (tmp_DDS == DDS) {
+			fprintf(log_file,"I am removing from myself in REM?\n");
+		} else {
 			tmp_DDS->num_of_cores -= nodes_cnt;
 
-			if (tmp_DDS->num_of_cores == 0){
+			if (tmp_DDS->num_of_cores == 0) {
 				DDS_count--;
 				if (tmp_DDS == DDS_tail){
 					DDS_tail = tmp_DDS_prev;
 					DDS_tail->next = NULL;
-				} else tmp_DDS_prev->next = tmp_DDS->next;
-
+				} else {
+					tmp_DDS_prev->next = tmp_DDS->next;
+#ifdef ADAM_SIM
+					tmp_DDS->next->prev = tmp_DDS_prev;
+#endif			
+				}
 				free(tmp_DDS);
+			} 
+#ifdef ADAM_SIM
+			else {
+				/* tmp_DDS out */
+				tmp_DDS->prev->next = tmp_DDS->next; /* Remove the link in the list */
+				tmp_DDS->next->prev = tmp_DDS->prev;
+					
+					
+				/* Insert sorted */
+				if (tmp_DDS->num_of_cores > DDS->num_of_cores) { /* Check if it must be placed first */
+					tmp_DDS2 = DDS;
+					DDS = tmp_DDS;
+					DDS->next = tmp_DDS2;
+					DDS->prev = NULL;
+					tmp_DDS2->prev = DDS;
+				} else if (tmp_DDS->num_of_cores < DDS_tail->num_of_cores) { /* Check if it must be placed last */
+					DDS_tail->next = tmp_DDS;
+					tmp_DDS->prev = DDS_tail;
+					DDS_tail = DDS_tail->next;
+					DDS_tail->next = NULL;
+				} else {
+					tmp_DDS2 = DDS;
+					while ((tmp_DDS2->next != NULL) && (tmp_DDS->num_of_cores <= tmp_DDS2->next->num_of_cores)) {		
+						/* tmp_DDS in between tmp_DDS2 and tmp_DDS2->next */
+						tmp_DDS->next = tmp_DDS2->next;
+						tmp_DDS2->next->prev = tmp_DDS;
+							
+						tmp_DDS2->next = tmp_DDS;
+						tmp_DDS->prev = tmp_DDS2;	
+					}						
+				}
 			}
+#endif
 		}	
 	}					
 
@@ -3082,27 +3172,27 @@ void sig_APPOINT_WORK_handler(int sender_id, int *inc_cnt, int cur_index_top){
 		if (valid >= 0) {
 
 			if (cur_agent.my_agent == -1) {
-				cur_agent.my_agent = sig_read_ar[3];//data_array_local[1];//read(fd_r, &my_agent, sizeof(int));// || my_agent != sender_id
-				cur_agent.array_size = sig_read_ar[4];//data_array_local[2];
-				cur_agent.work_bounds[0] = sig_read_ar[5];//data_array_local[3];
-				cur_agent.work_bounds[1] = sig_read_ar[6];//data_array_local[4];
-				cur_agent.app_type = sig_read_ar[7];
-				//cur_agent.segment_id = data_array_local[5];
-
+				cur_agent.my_agent = sig_read_ar[3];
+				cur_agent.app_type = sig_read_ar[4];
+				cur_agent.work_bounds[0] = sig_read_ar[5];
+				cur_agent.work_bounds[1] = sig_read_ar[6];
+#ifndef ARTIFICIAL_APPS_SIM
+				cur_agent.array_size = sig_read_ar[7];
+#endif
 				#ifdef VERBOSE_WORKER
-					printf("I am %d My agent is %d. I have to multiply lines %d through %d\n",node_id,cur_agent.my_agent,cur_agent.work_bounds[0],cur_agent.work_bounds[1]);
-					fflush(stdout);
+				printf("I am %d My agent is %d. I have to multiply lines %d through %d\n",node_id,cur_agent.my_agent,cur_agent.work_bounds[0],cur_agent.work_bounds[1]);
+				fflush(stdout);
 				#endif
 				fprintf(log_file,"My agent is %d. I have to multiply lines %d through %d\n",cur_agent.my_agent,cur_agent.work_bounds[0],cur_agent.work_bounds[1]);
 				fflush(log_file);	
-			} else if (cur_agent.my_agent != sender_id && state != IDLE_CORE) {//(my_agent != sender_id) {
-				pending_agent.my_agent = sig_read_ar[3];//data_array_local[1];//read(fd_r, &my_agent, sizeof(int));// || my_agent != sender_id
-				pending_agent.array_size = sig_read_ar[4];//data_array_local[2];
-				pending_agent.work_bounds[0] = sig_read_ar[5];//data_array_local[3];
-				pending_agent.work_bounds[1] = sig_read_ar[6];//data_array_local[4];
-				pending_agent.app_type = sig_read_ar[7];
-				//cur_agent.segment_id = data_array_local[5];
-
+			} else if (cur_agent.my_agent != sender_id && state != IDLE_CORE) {
+				pending_agent.my_agent = sig_read_ar[3];
+				pending_agent.app_type = sig_read_ar[4];
+				pending_agent.work_bounds[0] = sig_read_ar[5];
+				pending_agent.work_bounds[1] = sig_read_ar[6];
+#ifndef ARTIFICIAL_APPS_SIM
+				pending_agent.array_size = sig_read_ar[7];
+#endif
 				#ifdef VERBOSE_WORKER
 					printf("I am %d My old agent is %d. New agent is %d I have to multiply lines %d through %d\n"
 						,node_id,cur_agent.my_agent,pending_agent.my_agent,pending_agent.work_bounds[0],pending_agent.work_bounds[1]);
@@ -3111,29 +3201,30 @@ void sig_APPOINT_WORK_handler(int sender_id, int *inc_cnt, int cur_index_top){
 				fprintf(log_file,"My old agent is %d. New agent is %d I have to multiply lines %d through %d\n"
 					,cur_agent.my_agent,pending_agent.my_agent,pending_agent.work_bounds[0],pending_agent.work_bounds[1]);
 				fflush(log_file);
-			} else if (cur_agent.my_agent != sender_id) {
-				
-				cur_agent.my_agent = sig_read_ar[3];//data_array_local[1];//read(fd_r, &my_agent, sizeof(int));// || my_agent != sender_id
-				cur_agent.array_size = sig_read_ar[4];//data_array_local[2];
-				cur_agent.work_bounds[0] = sig_read_ar[5];//data_array_local[3];
-				cur_agent.work_bounds[1] = sig_read_ar[6];//data_array_local[4];
-				cur_agent.app_type = sig_read_ar[7];
-
+			} else if (cur_agent.my_agent != sender_id) {				
+				cur_agent.my_agent = sig_read_ar[3];
+				cur_agent.app_type = sig_read_ar[4];
+				cur_agent.work_bounds[0] = sig_read_ar[5];
+				cur_agent.work_bounds[1] = sig_read_ar[6];
+#ifndef ARTIFICIAL_APPS_SIM
+				cur_agent.array_size = sig_read_ar[7];
+#endif
 				base_offset = -1;
 				#ifdef VERBOSE_WORKER
-					printf("I am %d My new agent is %d. I have to multiply lines %d through %d\n",node_id,cur_agent.my_agent,cur_agent.work_bounds[0],cur_agent.work_bounds[1]);
-					fflush(stdout);
+				printf("I am %d My new agent is %d. I have to multiply lines %d through %d\n",node_id,cur_agent.my_agent,cur_agent.work_bounds[0],cur_agent.work_bounds[1]);
+				fflush(stdout);
 				#endif
 				fprintf(log_file,"My new agent is %d. I have to multiply lines %d through %d\n",cur_agent.my_agent,cur_agent.work_bounds[0],cur_agent.work_bounds[1]);
 				fflush(log_file);
 			} else {
-				cur_agent.work_bounds[0] = sig_read_ar[3];//data_array_local[1];
-				cur_agent.work_bounds[1] = sig_read_ar[4];//data_array_local[2];
-				cur_agent.app_type = sig_read_ar[7];
+				/* 12.7.2017 Changed the order to be consistent with INIT_WORK_NODE */
+				cur_agent.app_type = sig_read_ar[4];
+				cur_agent.work_bounds[0] = sig_read_ar[5];
+				cur_agent.work_bounds[1] = sig_read_ar[6];
 		
 				#ifdef VERBOSE_WORKER
-					printf("I am %d My agent is still %d. I have to multiply lines %d through %d\n",node_id,cur_agent.my_agent,cur_agent.work_bounds[0],cur_agent.work_bounds[1]);
-					fflush(stdout);
+				printf("I am %d My agent is still %d. I have to multiply lines %d through %d\n",node_id,cur_agent.my_agent,cur_agent.work_bounds[0],cur_agent.work_bounds[1]);
+				fflush(stdout);
 				#endif
 				fprintf(log_file,"My agent is still %d. I have to multiply lines %d through %d\n",cur_agent.my_agent,cur_agent.work_bounds[0],cur_agent.work_bounds[1]);
 				fflush(log_file);
@@ -3385,8 +3476,12 @@ void sig_FINISH_handler(int sender_id, int *inc_cnt, int cur_index_top){
 
 						if (active_working_cores > 0) {
 							row_reached = 0;
+#ifndef ARTIFICIAL_APPS_SIM
 							per_core_rows = my_app.array_size / active_working_cores;
 							rows_left = my_app.array_size % active_working_cores;
+#else
+							per_core_rows = (int) Speedup(my_app,active_working_cores+1); /* FIXME cutting off floating points -- +1 is because in Speedup calc it is -1*/
+#endif
 						} else if (my_cores_count == 2) { //I have only one working core, I know(?) that i wiil not give him up
                                                 	fprintf(log_file,"Case of only one core\n");
                                                 	fflush(log_file);
@@ -3395,8 +3490,13 @@ void sig_FINISH_handler(int sender_id, int *inc_cnt, int cur_index_top){
                                                 	core_inter_tail[one_core]->next = (inter_list *) malloc(sizeof(inter_list));
                                                 	core_inter_tail[one_core] = core_inter_tail[one_core]->next;
                                                 	core_inter_tail[one_core]->type = APPOINT_WORK_NODE;
+							/* FIXME I maintained that on 11.7.2017 - It seems to be useless because in a few lines it is re-appointed */
                                                 	core_inter_tail[one_core]->data.work_bounds[0] = 0;
+#ifndef ARTIFICIAL_APPS_SIM
                                                 	core_inter_tail[one_core]->data.work_bounds[1] = my_app.array_size-1;
+#else
+							core_inter_tail[one_core]->data.work_bounds[1] = 1;
+#endif
                                                 	core_inter_tail[one_core]->next = NULL;
                                         	}
 				
@@ -3427,17 +3527,26 @@ void sig_FINISH_handler(int sender_id, int *inc_cnt, int cur_index_top){
 								*/
 							}
 
-							//core_inter_tail[one_core]->type = APPOINT_WORK_NODE;
+							/* FIXME why is it core_inter_here */
 							if (core_inter_tail[one_core]->type == APPOINT_WORK_NODE || core_inter_tail[one_core]->type == INIT_WORK_NODE) {
+								/* FIXME have row_reached etc been defined if my_cores_count = 2 */
+#ifndef ARTIFICIAL_APPS_SIM
 								core_inter_tail[one_core]->data.work_bounds[0] = row_reached;
-								tmp_cores_list->workload[0] = row_reached; /* 27.6.2016 Added by dimos. If worker fails i have to know the workload given in order to reappoint */
+								tmp_cores_list->workload[0] = row_reached; /* 27.6.2016 dimos. If worker fails i have to know the workload given in order to reappoint */
 								row_reached += per_core_rows;
 								if (rows_left > 0) {
 									row_reached++;
 									rows_left--;
 								}
 								core_inter_tail[one_core]->data.work_bounds[1] = row_reached-1;
-								tmp_cores_list->workload[1] = row_reached-1; /* 27.6.2016 Added by dimos. If worker fails i have to know the workload given in order to reappoint */
+								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								
+								core_inter_tail[one_core]->data.work_bounds[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;
+#endif								
 								core_inter_tail[one_core]->next = NULL;
 
 								if (core_inter_head[one_core]->next == NULL) {
@@ -3639,7 +3748,7 @@ void sig_FINISH_handler(int sender_id, int *inc_cnt, int cur_index_top){
 		for (i=0; i<tmp_cnt; i++)
 			fprintf(log_file," %d",tmp_list[i]);
 		fprintf(log_file,"\n");
-		
+#ifndef ADAM_SIM	
 		/*Actual removal her */
 		for (i=0; i<tmp_cnt; i++) {
 			for (tmp_cores_list = my_cores->next; tmp_cores_list != NULL; tmp_cores_list = tmp_cores_list->next) 
@@ -3674,7 +3783,62 @@ void sig_FINISH_handler(int sender_id, int *inc_cnt, int cur_index_top){
 			}
 		  	fflush(log_file);
 		}
-		
+#else
+		prev_DDS = DDS;
+                tmp_DDS = DDS->next;
+                while (tmp_DDS != NULL && tmp_DDS->agent_id != old_agent_id) {
+                        prev_DDS = tmp_DDS;
+                        tmp_DDS = tmp_DDS->next;
+                }
+	                
+		/* tmp_DDS out */
+                tmp_DDS->prev->next = tmp_DDS->next; /* Remove the link in the list */
+                tmp_DDS->next->prev = tmp_DDS->prev;
+
+		if (tmp_DDS != NULL) {
+                        DDS_count--;
+                        prev_DDS->next = tmp_DDS->next;
+                        if (tmp_DDS->next == NULL) DDS_tail = prev_DDS;
+                        free(tmp_DDS);
+                } else {
+                        printf("--%d-- Fuck agent %d that finished is not in my DDS\n", node_id, old_agent_id);
+
+                        fprintf(log_file,"Fuck agent %d that finished is not in my DDS\n", old_agent_id);
+                        fprintf(log_file,"My current DDS list:\n");
+                        tmp_DDS = DDS;
+                        while (tmp_DDS != NULL){
+                                fprintf(log_file,"Agend_id : %d | Cores in my cluster : %d\n",tmp_DDS->agent_id,tmp_DDS->num_of_cores);
+                                tmp_DDS = tmp_DDS->next;
+                        }
+                        fflush(log_file);
+                }
+
+
+		 /* Insert sorted */
+                 if (tmp_DDS->num_of_cores > DDS->num_of_cores) { /* Check if it must be placed first */
+                 	tmp_DDS2 = DDS;
+                        DDS = tmp_DDS;
+                        DDS->next = tmp_DDS2;
+                        DDS->prev = NULL;
+                        tmp_DDS2->prev = DDS;
+                 } else if (tmp_DDS->num_of_cores < DDS_tail->num_of_cores) { /* Check if it must be placed last */
+                 	DDS_tail->next = tmp_DDS;
+                        tmp_DDS->prev = DDS_tail;
+                        DDS_tail = DDS_tail->next;
+                        DDS_tail->next = NULL;
+                 } else {
+                        tmp_DDS2 = DDS;
+                        while ((tmp_DDS2->next != NULL) && (tmp_DDS->num_of_cores <= tmp_DDS2->next->num_of_cores)) {
+                        	/* tmp_DDS in between tmp_DDS2 and tmp_DDS2->next */
+                                tmp_DDS->next = tmp_DDS2->next;
+                                tmp_DDS2->next->prev = tmp_DDS;
+
+                                tmp_DDS2->next = tmp_DDS;
+                                tmp_DDS->prev = tmp_DDS2;
+                        }
+                 }
+
+#endif		
 		free(tmp_list);  
 		fprintf(log_file,"My removal of agent complete node_id = %d sender_id=%d\n",node_id,sender_id);
 		fprintf(log_file,"Number of agents in region = %d\n",DDS_count);	
@@ -3931,7 +4095,7 @@ void sig_REJECT_handler(int sender_id){
 				pending_workload[1] = tmp_core_list->workload[1];
 			}
 		}
-	}else {
+	} else {
 		printf("I am %d in sig_reject and i have interaction with sender %d interaction = %d\n",node_id,sender_id,core_inter_head[sender_id]->type);
 		fprintf(log_file,"I am in sig_reject and i have interaction with sender interaction = %d\n",core_inter_head[sender_id]->type);
 		fflush(log_file);

+ 1 - 1
signal_handlers.h

@@ -14,7 +14,7 @@ void sig_TERMINATE_handler(int sender_id);
 void sig_INIT_APP_handler(int sender_id);
 void sig_IDAG_FIND_IDAGS_handler(int sender_id, int *inc_cnt, int cur_index_top);
 void sig_REQ_DDS_handler(int sender_id);
-void sig_REQ_CORES_handler(int sender_id);
+void sig_REQ_CORES_handler(int sender_id, int *inc_cnt, int cur_index_top);
 void sig_REJECT_handler(int sender_id);
 void sig_REP_OFFERS_handler(int sender_id);
 void sig_INIT_AGENT_handler(int sender_id);

+ 11 - 3
structs.h

@@ -57,7 +57,8 @@ typedef enum available_app_states {
 typedef enum available_exec_apps{
 	MATRIX_MUL,
 	SVM,
-	FFT
+	FFT,
+	ARTIFICIAL
 } app_exec;
 
 typedef enum interaction_types {
@@ -129,11 +130,15 @@ typedef struct app_tag app;
 
 struct app_tag {
 	int id;
-	int array_size; // 0 = 1024, 1= 2048, 3= 4096
 	int workld;
 	int num_of_cores;
 	int app_type;
-	//int segment_id;
+#ifndef ARTIFICIAL_APPS_SIM
+	int array_size; // 0 = 1024, 1= 2048, 3= 4096
+#else
+	float var;	
+	float A;
+#endif
 };
 typedef struct region_tag region;
 
@@ -235,6 +240,9 @@ struct DDS_tag {
 	int agent_id;
 	int num_of_cores;
 	DDS_list *next;
+#ifdef ADAM_SIM
+	DDS_list *prev;
+#endif
 };
 
 typedef struct coworkers_list_tag coworkers_list;