X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5f81ae8d6ee53f418eaaceb76430117ddc580869..23d88402ad47199eaf7e3b084c5af4b7f3344f55:/tools/gras/stub_generator.c diff --git a/tools/gras/stub_generator.c b/tools/gras/stub_generator.c index 1e666558c6..87c3e98d9b 100644 --- a/tools/gras/stub_generator.c +++ b/tools/gras/stub_generator.c @@ -280,7 +280,6 @@ const char *SIM_PREEMBULE = const char *SIM_MAIN_POSTEMBULE = "\n" "\n" -#ifdef USE_SIMIX " gras_launch_application(argv[2]);\n" "\n" " /* Run the simulation */\n" @@ -288,15 +287,6 @@ const char *SIM_MAIN_POSTEMBULE = "\n" "\n" " /* cleanup the place */\n" " gras_clean();\n" -#else -" MSG_launch_application(argv[2]);\n" -"\n" -" /* Run the simulation */\n" -" MSG_main();\n" -"\n" -" /* cleanup the place */\n" -" MSG_clean();\n" -#endif " if (gras_log)\n" " free(gras_log);\n" " return 0;\n" @@ -319,17 +309,16 @@ typedef struct s_process_t { static void s_process_free(void *process) { + s_process_t*p = (s_process_t*)process; int i; - for(i=0;i<((s_process_t*)process)->argc; i++) - free(((s_process_t*)process)->argv[i]); - free(((s_process_t*)process)->host); + for (i=0; iargc ; i++) + free(p->argv[i]); + free(p->argv); + free(p->host); } static s_process_t process; -/* - * Création de deux dictionnaires - */ static void parse_process_init(void) { xbt_dict_set(process_function_set, A_surfxml_process_function, NULL, NULL); @@ -354,105 +343,66 @@ static void parse_process_finalize(void) /*VERB1("Function: %s",process.argv[0]);*/ } -static void generate_sim(char *project) -{ - xbt_dict_cursor_t cursor=NULL; - char *key = NULL; - void *data = NULL; - char *filename = NULL; - FILE *OUT = NULL; - - /* - * Creation d'un fichier nommé : _simulator.c - */ - - - filename = xbt_new(char,strlen(project) + strlen(SIM_SOURCENAME)); - sprintf(filename,SIM_SOURCENAME,project); - - OUT=fopen(filename,"w"); - - - xbt_assert1(OUT, "Unable to open %s for writing",filename); - - /* - * Ecriture du message d'avertissement. - */ - fprintf(OUT, "%s\n",warning); - - /* - * Ecriture du préambule (inclusion de certains fichiers d'en-tête - */ - fprintf(OUT, "%s", SIM_PREEMBULE); - - /* - * Déclaration des fonction int (int argc,char *argv[]); - */ - xbt_dict_foreach(process_function_set,cursor,key,data) { - fprintf(OUT,"int %s(int argc,char *argv[]);\n",key); - } - - fprintf(OUT,"\n"); - - /* - * Déclaration des fonction int launch_(int argc,char *argv[]); - */ - xbt_dict_foreach(process_function_set,cursor,key,data) { - fprintf(OUT,"int launch_%s(int argc,char *argv[]);\n",key); - } - - /* - * Ecriture du message d'avertissement. - */ - fprintf(OUT, "\n%s\n",warning); - - xbt_dict_foreach(process_function_set,cursor,key,data) { - fprintf(OUT,SIM_LAUNCH_FUNC,key,key); - } - fprintf(OUT, "\n%s\n",warning); - - fprintf(OUT,"%s", "/* specific to Borland Compiler */\n" - "#ifdef __BORLANDDC__\n" - "#pragma argsused\n" - "#endif\n\n"); - - fprintf(OUT, "%s", "int main (int argc,char *argv[]) {\n" - "\n" - " /* Simulation setup */\n" -#ifdef USE_SIMIX - " gras_global_init(&argc,argv);\n" -#else - " MSG_global_init(&argc,argv);\n" -#endif - " if (argc != 3) {\n" - " fprintf(stderr, \"Usage: %s platform.xml deployment.xml [--gras-log=...]\\n\",argv[0]);\n" - " exit(1);\n" - " }\n" - "\n"); - fprintf(OUT, -#ifdef USE_SIMIX - " gras_create_environment(argv[1]);\n" - "\n" - " /* Application deployment */\n" - ); -#else - " MSG_paje_output(\"%s.trace\");\n" - " MSG_set_channel_number(XBT_MAX_CHANNEL); /* Using at most 10 channel (ports) per host. Change it here if needed */\n" - " MSG_create_environment(argv[1]);\n" - "\n" - " /* Application deployment */\n", - project); -#endif - xbt_dict_foreach(process_function_set,cursor,key,data) { -#ifdef USE_SIMIX - fprintf(OUT," gras_function_register(\"%s\", launch_%s);\n",key,key); -#else - fprintf(OUT," MSG_function_register(\"%s\", launch_%s);\n",key,key); -#endif - } - fprintf(OUT, "%s", SIM_MAIN_POSTEMBULE); - fclose(OUT); - free(filename); +static void generate_sim(char *project) { + xbt_dict_cursor_t cursor=NULL; + char *key = NULL; + void *data = NULL; + char *filename = NULL; + FILE *OUT = NULL; + + /* Output file: _simulator.c */ + filename = xbt_new(char,strlen(project) + strlen(SIM_SOURCENAME)); + sprintf(filename,SIM_SOURCENAME,project); + + OUT=fopen(filename,"w"); + + xbt_assert1(OUT, "Unable to open %s for writing",filename); + + fprintf(OUT, "%s\n",warning); + fprintf(OUT, "%s", SIM_PREEMBULE); + + xbt_dict_foreach(process_function_set,cursor,key,data) { + fprintf(OUT,"int %s(int argc,char *argv[]);\n",key); + } + + fprintf(OUT,"\n"); + + xbt_dict_foreach(process_function_set,cursor,key,data) { + fprintf(OUT,"int launch_%s(int argc,char *argv[]);\n",key); + } + + fprintf(OUT, "\n%s\n",warning); + + xbt_dict_foreach(process_function_set,cursor,key,data) { + fprintf(OUT,SIM_LAUNCH_FUNC,key,key); + } + fprintf(OUT, "\n%s\n",warning); + + fprintf(OUT,"%s", "/* specific to Borland Compiler */\n" + "#ifdef __BORLANDDC__\n" + "#pragma argsused\n" + "#endif\n\n"); + + fprintf(OUT, "%s", "int main (int argc,char *argv[]) {\n" + "\n" + " /* Simulation setup */\n" + " gras_global_init(&argc,argv);\n" + " if (argc != 3) {\n" + " fprintf(stderr, \"Usage: %s platform.xml deployment.xml [--gras-log=...]\\n\",argv[0]);\n" + " exit(1);\n" + " }\n" + "\n"); + fprintf(OUT, + " gras_create_environment(argv[1]);\n" + "\n" + " /* Application deployment */\n" + ); + xbt_dict_foreach(process_function_set,cursor,key,data) { + fprintf(OUT," gras_function_register(\"%s\", launch_%s);\n",key,key); + } + fprintf(OUT, "%s", SIM_MAIN_POSTEMBULE); + fclose(OUT); + free(filename); } /**********************************************/ @@ -786,77 +736,6 @@ static void generate_makefile_remote(char *project, char *deployment) fclose(OUT); } - -static void generate_deployment(char *project, char *deployment) -{ - xbt_dict_cursor_t cursor=NULL; - char *key = NULL; - void *data = NULL; - char *filename = NULL; - FILE *OUT = NULL; - - int cpt,i; - s_process_t proc; - - filename = xbt_new(char,strlen(project) + strlen(DEPLOYMENT)); - sprintf(filename,DEPLOYMENT, project); - - OUT=fopen(filename,"w"); - xbt_assert1(OUT, "Unable to open %s for writing",filename); - - fprintf(OUT, "#!/bin/sh\n"); - fprintf(OUT, "############ DEPLOYMENT FILE #########\n"); - fprintf(OUT, - "if test \"${MACHINES+set}\" != set; then \n" - " export MACHINES='"); - xbt_dict_foreach(machine_set,cursor,key,data) { - fprintf(OUT, "%s ",key); - } - fprintf(OUT, - "';\n" - "fi\n" - "if test \"${INSTALL_PATH+set}\" != set; then \n" - " export INSTALL_PATH='`echo $HOME`/tmp/src'\n" - "fi\n" - "if test \"${GRAS_ROOT+set}\" != set; then \n" - " export GRAS_ROOT='`echo $INSTALL_PATH`'\n" - "fi\n" - "if test \"${SRCDIR+set}\" != set; then \n" - " export SRCDIR=./\n" - "fi\n" - "if test \"${SIMGRID_URL+set}\" != set; then \n" - " export SIMGRID_URL=http://gcl.ucsd.edu/simgrid/dl/\n" - "fi\n" - "if test \"${SIMGRID_VERSION+set}\" != set; then \n" - " export SIMGRID_VERSION=2.91\n" - "fi\n" - "if test \"${GRAS_PROJECT+set}\" != set; then \n" - " export GRAS_PROJECT=%s\n" - "fi\n" - "if test \"${GRAS_PROJECT_URL+set}\" != set; then \n" - " export GRAS_PROJECT_URL=http://www-id.imag.fr/Laboratoire/Membres/Legrand_Arnaud/gras_test/\n" - "fi\n" - "\n" - "test -e runlogs/ || mkdir -p runlogs/\n", - project); - - fprintf(OUT, - "cmd_prolog=\"env INSTALL_PATH=$INSTALL_PATH GRAS_ROOT=$GRAS_ROOT \\\n" - " SIMGRID_URL=$SIMGRID_URL SIMGRID_VERSION=$SIMGRID_VERSION GRAS_PROJECT=$GRAS_PROJECT \\\n" - " GRAS_PROJECT_URL=$GRAS_PROJECT_URL LD_LIBRARY_PATH=$GRAS_ROOT/lib/ sh -c \";\n"); - - xbt_dynar_foreach (process_list,cpt,proc) { - fprintf(OUT,"cmd=\"\\$INSTALL_PATH/gras-%s/"RL_BINARYNAME" ",project,project,proc.argv[0]); - for(i=1;i&1'\" > runlogs/%s_%d.log &\n",proc.host,proc.host,cpt); - } - - fclose(OUT); -} - static void print(void *p) { printf("%p",p); @@ -879,15 +758,33 @@ int main(int argc, char *argv[]) int i; surf_init(&argc, argv); + process_function_set = xbt_dict_new(); + process_list = xbt_dynar_new(sizeof(s_process_t),s_process_free); + machine_set = xbt_dict_new(); + for (i=1; i