X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0f5e8daaa6e9f74521068aa75837200bcd182ea6..cc01c6a871dbbfd0cc84e26eb9f94aeb539e613e:/examples/amok/alnem/alnem.c diff --git a/examples/amok/alnem/alnem.c b/examples/amok/alnem/alnem.c index 720318f3e5..9bcb87f682 100644 --- a/examples/amok/alnem/alnem.c +++ b/examples/amok/alnem/alnem.c @@ -14,7 +14,7 @@ #include -#include /* alvin's graph toolbox (+ reconstruction algorithm) */ +#include /* alvin's graph toolbox (+ reconstruction algorithm) */ /* ********************************************************************** * Sensor code @@ -26,14 +26,17 @@ typedef struct { } sensor_data_t; /* Function prototypes */ -int sensor (int argc,char *argv[]); +int sensor(int argc, char *argv[]); -int sensor (int argc,char *argv[]) { +int sensor(int argc, char *argv[]) +{ xbt_error_t errcode; - sensor_data_t *g=gras_userdata_new(sensor_data_t); + sensor_data_t *g = gras_userdata_new(sensor_data_t); - if ((errcode=gras_sock_server_open(4000,4000,&(g->sock)))) { - fprintf(stderr,"Sensor: Error %s encountered while opening the server socket\n",xbt_error_name(errcode)); + if ((errcode = gras_sock_server_open(4000, 4000, &(g->sock)))) { + fprintf(stderr, + "Sensor: Error %s encountered while opening the server socket\n", + xbt_error_name(errcode)); return 1; } @@ -43,13 +46,13 @@ int sensor (int argc,char *argv[]) { } while (1) { - if ((errcode=gras_msg_handle(3600.0)) && errcode != timeout_error) { - fprintf(stderr,"Sensor: Error '%s' while handling message\n", - xbt_error_name(errcode)); + if ((errcode = gras_msg_handle(3600.0)) && errcode != timeout_error) { + fprintf(stderr, "Sensor: Error '%s' while handling message\n", + xbt_error_name(errcode)); } } - gras_sleep(5,0); + gras_sleep(5, 0); return gras_sock_close(g->sock); } @@ -63,7 +66,7 @@ typedef struct { } maestro_data_t; /* Function prototypes */ -int maestro (int argc,char *argv[]); +int maestro(int argc, char *argv[]); #define MAXHOSTS 100 @@ -73,33 +76,38 @@ int maestro (int argc,char *argv[]); TBX_Graph_nodeSearch(graph,b),\ TBX_Graph_nodeSearch(graph,v)) -int maestro(int argc,char *argv[]) { - int bufSize=32 * 1024; - int expSize= 1024 * 1024; - int msgSize=expSize; - int satSize=msgSize * 100; - double dummy,beginSim; +int maestro(int argc, char *argv[]) +{ + int bufSize = 32 * 1024; + int expSize = 1024 * 1024; + int msgSize = expSize; + int satSize = msgSize * 100; + double dummy, beginSim; xbt_error_t errcode; - maestro_data_t *g=gras_userdata_new(maestro_data_t); + maestro_data_t *g = gras_userdata_new(maestro_data_t); double bw[MAXHOSTS][MAXHOSTS]; double bw_sat[MAXHOSTS][MAXHOSTS]; - int a,b,c,d,begin; + int a, b, c, d, begin; - TBX_Graph_t graph = TBX_Graph_newGraph("Essai",0,NULL); /* a dummy graph containing all hosts */ + TBX_Graph_t graph = TBX_Graph_newGraph("Essai", 0, NULL); /* a dummy graph containing all hosts */ TBX_FIFO_t host_fifo = TBX_FIFO_newFIFO(); - TBX_InterfTable_t interf = NULL; /* the measured interferences */ - TBX_Graph_t builded_graph = NULL; /* the graph builded from the interferences */ + TBX_InterfTable_t interf = NULL; /* the measured interferences */ + TBX_Graph_t builded_graph = NULL; /* the graph builded from the interferences */ /* basics setups */ - if (argc>MAXHOSTS) { - fprintf(stderr,"You gave more than %d sensors for this experiment. Increase the MAX HOSTS constant in alnem code to be bigger than this number.\n",argc); + if (argc > MAXHOSTS) { + fprintf(stderr, + "You gave more than %d sensors for this experiment. Increase the MAX HOSTS constant in alnem code to be bigger than this number.\n", + argc); return 1; } - if ((errcode=gras_sock_server_open(4000,5000,&(g->sock)))) { - fprintf(stderr,"MAESTRO: Error %s encountered while opening the server socket\n",xbt_error_name(errcode)); + if ((errcode = gras_sock_server_open(4000, 5000, &(g->sock)))) { + fprintf(stderr, + "MAESTRO: Error %s encountered while opening the server socket\n", + xbt_error_name(errcode)); return 1; } @@ -108,109 +116,125 @@ int maestro(int argc,char *argv[]) { return 1; } - for (a=1; a %f (%f vs %f)%s\n", - gras_time(), - argv[c],argv[d],argv[a],argv[b], - bw_sat[c][d]/bw[c][d],bw[c][d],bw_sat[c][d], - - (bw_sat[c][d]/bw[c][d] < 0.75) ? " THERE IS SOME INTERFERENCE !!!":""); - INTERF(graph,interf,argv[c],argv[d],argv[a],argv[b])= - (bw_sat[c][d]/bw[c][d] < 0.75) ? 1 : 0; - } + gras_sleep(1, 0); + + begin = time(NULL); + beginSim = gras_time(); + for (c = 1; c < argc; c++) { + if (a == c || b == c) + continue; + + for (d = 1; d < argc; d++) { + if (a == d || b == d || c == d) + continue; + + if ((errcode = + grasbw_request(argv[c], 4000, argv[d], 4000, bufSize, + expSize, msgSize, &dummy, + &(bw_sat[c][d])))) { + fprintf(stderr, "MAESTRO: Error %s encountered in test\n", + xbt_error_name(errcode)); + return 1; + } + fprintf(stderr, + "MAESTRO[%.2f sec]: SATURATED BW XP(%s %s // %s %s) => %f (%f vs %f)%s\n", + gras_time(), argv[c], argv[d], argv[a], argv[b], + bw_sat[c][d] / bw[c][d], bw[c][d], bw_sat[c][d], + (bw_sat[c][d] / bw[c][d] < + 0.75) ? " THERE IS SOME INTERFERENCE !!!" : ""); + INTERF(graph, interf, argv[c], argv[d], argv[a], argv[b]) = + (bw_sat[c][d] / bw[c][d] < 0.75) ? 1 : 0; + } } - if ((errcode=grasbw_saturate_stop(argv[a],4000,argv[b],4000))) { - fprintf(stderr,"MAESTRO: Error %s encountered while stopping saturation\n", - xbt_error_name(errcode)); - return -1; + if ((errcode = grasbw_saturate_stop(argv[a], 4000, argv[b], 4000))) { + fprintf(stderr, + "MAESTRO: Error %s encountered while stopping saturation\n", + xbt_error_name(errcode)); + return -1; } - fprintf(stderr,"Did an iteration on saturation pair in %ld sec (%.2f simulated sec)\n", - time(NULL)-begin, gras_time()-beginSim); + fprintf(stderr, + "Did an iteration on saturation pair in %ld sec (%.2f simulated sec)\n", + time(NULL) - begin, gras_time() - beginSim); } } /* reconstruct the graph */ TBX_Graph_interferenceTableDump(interf); - TBX_Graph_interferenceTableSave(interf,"interference.dat"); - begin=time(NULL); + TBX_Graph_interferenceTableSave(interf, "interference.dat"); + begin = time(NULL); fprintf(stderr, "MAESTRO: Reconstruct the graph... "); builded_graph = TBX_Graph_exploreInterference(interf); TBX_Graph_exportToGraphViz(builded_graph, "toto.dot"); - fprintf(stderr, "done (took %d sec)",(int)time(NULL)); + fprintf(stderr, "done (took %d sec)", (int) time(NULL)); /* end */ - TBX_Graph_freeGraph(graph,NULL,NULL,NULL); - TBX_Graph_freeGraph(builded_graph,NULL,NULL,NULL); + TBX_Graph_freeGraph(graph, NULL, NULL, NULL); + TBX_Graph_freeGraph(builded_graph, NULL, NULL, NULL); TBX_Graph_freeInterfTable(interf); - gras_sleep(5,0); - exit(0); /* FIXME: There is a bug in MSG preventing me from terminating this server properly */ + gras_sleep(5, 0); + exit(0); /* FIXME: There is a bug in MSG preventing me from terminating this server properly */ return gras_sock_close(g->sock); }