Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] updating tesh to contain new tracing options
[simgrid.git] / examples / msg / actions / actions.c
1 /* Copyright (c) 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "msg/msg.h"            /* Yeah! If you want to use msg, you need to include msg/msg.h */
10 #include "simix/simix.h"        /* semaphores for the barrier */
11 #include "xbt.h"                /* calloc, printf */
12 #include "simgrid_config.h"     /* getline */
13 #include "instr/instr_private.h"
14
15 XBT_LOG_NEW_DEFAULT_CATEGORY(actions,
16                              "Messages specific for this msg example");
17 int communicator_size = 0;
18
19 static void action_Isend(xbt_dynar_t action);
20
21 typedef struct  {
22   int last_Irecv_sender_id;
23   int bcast_counter;
24   int reduce_counter;
25   int allReduce_counter;
26   xbt_dynar_t isends;
27 } s_process_globals_t, *process_globals_t;
28
29 /* Helper function */
30 static double parse_double(const char *string)
31 {
32   double value;
33   char *endptr;
34
35   value = strtod(string, &endptr);
36   if (*endptr != '\0')
37     THROW1(unknown_error, 0, "%s is not a double", string);
38   return value;
39 }
40
41 static int get_rank (const char *process_name)
42 {
43   return atoi(&(process_name[1]));
44
45
46 static void asynchronous_cleanup(void) {
47   process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self());
48
49   /* Destroy any isend which correspond to completed communications */
50   int found;
51   msg_comm_t comm;
52   while ((found = MSG_comm_testany(globals->isends)) != -1) {
53     xbt_dynar_remove_at(globals->isends,found,&comm);
54     MSG_comm_destroy(comm);
55   }
56 }
57
58 /* My actions */
59 static int spawned_send(int argc, char *argv[])
60 {
61   DEBUG3("%s: Sending %s on %s", MSG_process_get_name(MSG_process_self()),
62          argv[1], argv[0]);
63   MSG_task_send(MSG_task_create(argv[0], 0, parse_double(argv[1]), NULL),
64                 argv[0]);
65   return 0;
66 }
67
68 static void action_send(xbt_dynar_t action)
69 {
70   char *name = NULL;
71   char to[250];
72   char *size_str = xbt_dynar_get_as(action, 3, char *);
73   double size=parse_double(size_str);
74   double clock = MSG_get_clock(); /* this "call" is free thanks to inlining */
75
76   sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()),
77           xbt_dynar_get_as(action, 2, char *));
78   //  char *to =  xbt_dynar_get_as(action, 2, char *);
79
80   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
81     name = xbt_str_join(action, " ");
82
83 #ifdef HAVE_TRACING
84   int rank = get_rank(MSG_process_get_name(MSG_process_self()));
85   int dst_traced = get_rank(xbt_dynar_get_as(action, 2, char *));
86   TRACE_smpi_ptp_in(rank, rank, dst_traced, "send");
87   TRACE_smpi_send(rank, rank, dst_traced);
88 #endif
89
90   DEBUG2("Entering Send: %s (size: %lg)", name, size);
91    if (size<65536) {
92      action_Isend(action);
93    } else {
94      MSG_task_send(MSG_task_create(name, 0, size, NULL), to);
95    }
96    
97    VERB2("%s %f", name, MSG_get_clock() - clock);
98
99   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
100     free(name);
101
102 #ifdef HAVE_TRACING
103   TRACE_smpi_ptp_out(rank, rank, dst_traced, "send");
104 #endif
105
106   asynchronous_cleanup();
107 }
108
109 static void action_Isend(xbt_dynar_t action)
110 {
111   char to[250];
112   //  char *to = xbt_dynar_get_as(action, 2, char *);
113   char *size = xbt_dynar_get_as(action, 3, char *);
114   double clock = MSG_get_clock();
115   process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self());
116
117
118   sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()),
119           xbt_dynar_get_as(action, 2, char *));
120
121   msg_comm_t comm =
122       MSG_task_isend( MSG_task_create(to,0,parse_double(size),NULL), to);
123   xbt_dynar_push(globals->isends,&comm);
124
125   DEBUG1("Isend on %s", MSG_process_get_name(MSG_process_self()));
126   VERB2("%s %f", xbt_str_join(action, " "), MSG_get_clock() - clock);
127
128   asynchronous_cleanup();
129 }
130
131
132 static void action_recv(xbt_dynar_t action)
133 {
134   char *name = NULL;
135   char mailbox_name[250];
136   m_task_t task = NULL;
137   double clock = MSG_get_clock();
138   //FIXME: argument of action ignored so far; semantic not clear
139   //char *from=xbt_dynar_get_as(action,2,char*);
140   sprintf(mailbox_name, "%s_%s", xbt_dynar_get_as(action, 2, char *),
141           MSG_process_get_name(MSG_process_self()));
142
143   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
144     name = xbt_str_join(action, " ");
145
146 #ifdef HAVE_TRACING
147   int rank = get_rank(MSG_process_get_name(MSG_process_self()));
148   int src_traced = get_rank(xbt_dynar_get_as(action, 2, char *));
149   TRACE_smpi_ptp_in(rank, src_traced, rank, "recv");
150 #endif
151
152   DEBUG1("Receiving: %s", name);
153   MSG_task_receive(&task, mailbox_name);
154   //  MSG_task_receive(&task, MSG_process_get_name(MSG_process_self()));
155   VERB2("%s %f", name, MSG_get_clock() - clock);
156   MSG_task_destroy(task);
157
158   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
159     free(name);
160 #ifdef HAVE_TRACING
161   TRACE_smpi_ptp_out(rank, src_traced, rank, "recv");
162   TRACE_smpi_recv(rank, src_traced, rank);
163 #endif
164
165   asynchronous_cleanup();
166 }
167
168 static int spawned_recv(int argc, char *argv[])
169 {
170   m_task_t task = NULL;
171   DEBUG1("Receiving on %s", argv[0]);
172   MSG_task_receive(&task, argv[0]);
173   DEBUG1("Received %s", MSG_task_get_name(task));
174   DEBUG1("waiter on %s", MSG_process_get_name(MSG_process_self()));
175   MSG_task_send(MSG_task_create("waiter", 0, 0, NULL),
176                 MSG_process_get_name(MSG_process_self()));
177
178   MSG_task_destroy(task);
179   return 0;
180 }
181
182
183 static void action_Irecv(xbt_dynar_t action)
184 {
185   char *name;
186   m_process_t comm_helper;
187   char mailbox_name[250];
188   char **myargv;
189   double clock = MSG_get_clock();
190
191   DEBUG1("Irecv on %s: spawn process ",
192          MSG_process_get_name(MSG_process_self()));
193 #ifdef HAVE_TRACING
194   int rank = get_rank(MSG_process_get_name(MSG_process_self()));
195   int src_traced = get_rank(xbt_dynar_get_as(action, 2, char *));
196   process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self());
197   counters->last_Irecv_sender_id = src_traced;
198   MSG_process_set_data(MSG_process_self(), (void *) counters);
199
200   TRACE_smpi_ptp_in(rank, src_traced, rank, "Irecv");
201 #endif
202
203   sprintf(mailbox_name, "%s_%s", xbt_dynar_get_as(action, 2, char *),
204           MSG_process_get_name(MSG_process_self()));
205   name = bprintf("%s_wait", MSG_process_get_name(MSG_process_self()));
206   myargv = (char **) calloc(2, sizeof(char *));
207
208   myargv[0] = xbt_strdup(mailbox_name);
209   myargv[1] = NULL;
210   comm_helper = MSG_process_create_with_arguments(name, spawned_recv,
211                                                   NULL, MSG_host_self(),
212                                                   1, myargv);
213
214   VERB2("%s %f", xbt_str_join(action, " "), MSG_get_clock() - clock);
215
216   free(name);
217 #ifdef HAVE_TRACING
218   TRACE_smpi_ptp_out(rank, src_traced, rank, "Irecv");
219 #endif
220
221   asynchronous_cleanup();
222 }
223
224
225 static void action_wait(xbt_dynar_t action)
226 {
227   char *name = NULL;
228   char task_name[80];
229   m_task_t task = NULL;
230   double clock = MSG_get_clock();
231
232   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
233     name = xbt_str_join(action, " ");
234 #ifdef HAVE_TRACING
235   process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self());
236   int src_traced = counters->last_Irecv_sender_id;
237   int rank = get_rank(MSG_process_get_name(MSG_process_self()));
238   TRACE_smpi_ptp_in(rank, src_traced, rank, "wait");
239 #endif
240
241   DEBUG1("Entering %s", name);
242   sprintf(task_name, "%s_wait", MSG_process_get_name(MSG_process_self()));
243   DEBUG1("wait: %s", task_name);
244   MSG_task_receive(&task, task_name);
245   MSG_task_destroy(task);
246   VERB2("%s %f", name, MSG_get_clock() - clock);
247   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
248     free(name);
249 #ifdef HAVE_TRACING
250   TRACE_smpi_ptp_out(rank, src_traced, rank, "wait");
251   TRACE_smpi_recv(rank, src_traced, rank);
252 #endif
253
254 }
255
256 /* FIXME: that's a poor man's implementation: we should take the message exchanges into account */
257 static void action_barrier(xbt_dynar_t action)
258 {
259   char *name = NULL;
260   static smx_mutex_t mutex = NULL;
261   static smx_cond_t cond = NULL;
262   static int processes_arrived_sofar=0;
263
264   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
265     name = xbt_str_join(action, " ");
266
267   if (mutex == NULL) {       // first arriving on the barrier
268     mutex = SIMIX_req_mutex_init();
269     cond = SIMIX_req_cond_init();
270     processes_arrived_sofar=0;
271   }
272   DEBUG2("Entering barrier: %s (%d already there)", name,processes_arrived_sofar);
273
274   SIMIX_req_mutex_lock(mutex);
275   if (++processes_arrived_sofar == communicator_size) {
276     SIMIX_req_cond_broadcast(cond);
277     SIMIX_req_mutex_unlock(mutex);
278   } else {
279     SIMIX_req_cond_wait(cond,mutex);
280     SIMIX_req_mutex_unlock(mutex);
281   }
282
283   DEBUG1("Exiting barrier: %s", name);
284
285   processes_arrived_sofar--;
286   if (!processes_arrived_sofar) {
287     SIMIX_req_cond_destroy(cond);
288     SIMIX_req_mutex_destroy(mutex);
289     mutex=NULL;
290   }
291
292   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
293     free(name);
294
295 }
296
297 static void action_reduce(xbt_dynar_t action)
298 {
299   int i;
300   char *name;
301   char task_name[80];
302   char spawn_name[80];
303   char **myargv;
304   char *comm_size = xbt_dynar_get_as(action, 2, char *);
305   char *comp_size = xbt_dynar_get_as(action, 3, char *);
306   m_process_t comm_helper = NULL;
307   m_task_t task = NULL, comp_task = NULL;
308   const char *process_name;
309   double clock = MSG_get_clock();
310
311   process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self());
312
313   xbt_assert0(communicator_size, "Size of Communicator is not defined"
314               ", can't use collective operations");
315
316   process_name = MSG_process_get_name(MSG_process_self());
317
318   name = bprintf("reduce_%d", counters->reduce_counter++);
319
320   if (!strcmp(process_name, "p0")) {
321     DEBUG2("%s: %s is the Root", name, process_name);
322     for (i = 1; i < communicator_size; i++) {
323       sprintf(spawn_name, "%s_p%d_%s", name, i,
324               MSG_process_get_name(MSG_process_self()));
325       sprintf(task_name, "%s_wait", spawn_name);
326       myargv = (char **) calloc(2, sizeof(char *));
327
328       myargv[0] = xbt_strdup(spawn_name);
329       myargv[1] = NULL;
330
331       comm_helper =
332           MSG_process_create_with_arguments(task_name, spawned_recv,
333                                             NULL, MSG_host_self(),
334                                             1, myargv);
335     }
336
337     for (i = 1; i < communicator_size; i++) {
338       sprintf(task_name, "%s_p%d_p0_wait", name, i);
339       MSG_task_receive(&task, task_name);
340       MSG_task_destroy(task);
341       task = NULL;
342     }
343
344     comp_task =
345         MSG_task_create("reduce_comp", parse_double(comp_size), 0, NULL);
346     DEBUG1("%s: computing 'reduce_comp'", name);
347     MSG_task_execute(comp_task);
348     MSG_task_destroy(comp_task);
349     DEBUG1("%s: computed", name);
350   } else {
351     DEBUG2("%s: %s sends", name, process_name);
352     sprintf(task_name, "%s_%s_p0", name, process_name);
353     DEBUG1("put on %s", task_name);
354     MSG_task_send(MSG_task_create(name, 0, parse_double(comm_size), NULL),
355                   task_name);
356   }
357
358   MSG_process_set_data(MSG_process_self(), (void *) counters);
359   VERB2("%s %f", xbt_str_join(action, " "), MSG_get_clock() - clock);
360   free(name);
361 }
362
363 static void action_bcast(xbt_dynar_t action)
364 {
365   int i;
366   char *name;
367   const char *process_name;
368   char task_name[80];
369   char spawn_name[80];
370   char **myargv;
371   m_process_t comm_helper = NULL;
372   m_task_t task = NULL;
373   char *size = xbt_dynar_get_as(action, 2, char *);
374   process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self());
375   double clock = MSG_get_clock();
376
377   xbt_assert0(communicator_size, "Size of Communicator is not defined"
378               ", can't use collective operations");
379
380
381   process_name = MSG_process_get_name(MSG_process_self());
382
383   name = bprintf("bcast_%d", counters->bcast_counter++);
384   if (!strcmp(process_name, "p0")) {
385     DEBUG2("%s: %s is the Root", name, process_name);
386
387     for (i = 1; i < communicator_size; i++) {
388       myargv = (char **) calloc(3, sizeof(char *));
389       myargv[0] = xbt_strdup(name);
390       myargv[1] = xbt_strdup(size);
391       myargv[2] = NULL;
392
393       sprintf(spawn_name, "%s_%d", myargv[0], i);
394       comm_helper =
395           MSG_process_create_with_arguments(spawn_name, spawned_send,
396                                             NULL, MSG_host_self(), 2,
397                                             myargv);
398     }
399
400     for (i = 1; i < communicator_size; i++) {
401       sprintf(task_name, "p%d_wait", i);
402       DEBUG1("get on %s", task_name);
403       MSG_task_receive(&task, task_name);
404       MSG_task_destroy(task);
405       task = NULL;
406     }
407     DEBUG2("%s: all messages sent by %s have been received",
408            name, process_name);
409   } else {
410     DEBUG2("%s: %s receives", name, process_name);
411     MSG_task_receive(&task, name);
412     MSG_task_destroy(task);
413     DEBUG2("%s: %s has received", name, process_name);
414     sprintf(task_name, "%s_wait", process_name);
415     DEBUG1("put on %s", task_name);
416     MSG_task_send(MSG_task_create("waiter", 0, 0, NULL), task_name);
417   }
418
419   MSG_process_set_data(MSG_process_self(), (void *) counters);
420   VERB2("%s %f", xbt_str_join(action, " "), MSG_get_clock() - clock);
421   free(name);
422 }
423
424
425 static void action_sleep(xbt_dynar_t action)
426 {
427   char *name = NULL;
428   char *duration = xbt_dynar_get_as(action, 2, char *);
429   double clock = MSG_get_clock();
430
431   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
432     name = xbt_str_join(action, " ");
433
434   DEBUG1("Entering %s", name);
435   MSG_process_sleep(parse_double(duration));
436   VERB2("%s %f ", name, MSG_get_clock() - clock);
437
438   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
439     free(name);
440 }
441
442 static void action_allReduce(xbt_dynar_t action)
443 {
444   int i;
445   char *name;
446   char task_name[80];
447   char spawn_name[80];
448   char **myargv;
449   char *comm_size = xbt_dynar_get_as(action, 2, char *);
450   char *comp_size = xbt_dynar_get_as(action, 3, char *);
451   m_process_t comm_helper = NULL;
452   m_task_t task = NULL, comp_task = NULL;
453   const char *process_name;
454   double clock = MSG_get_clock();
455
456   process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self());
457
458   xbt_assert0(communicator_size, "Size of Communicator is not defined"
459               ", can't use collective operations");
460
461   process_name = MSG_process_get_name(MSG_process_self());
462
463   name = bprintf("allReduce_%d", counters->allReduce_counter++);
464
465   if (!strcmp(process_name, "p0")) {
466     DEBUG2("%s: %s is the Root", name, process_name);
467     for (i = 1; i < communicator_size; i++) {
468       sprintf(spawn_name, "%s_p%d_%s", name, i,
469               MSG_process_get_name(MSG_process_self()));
470       sprintf(task_name, "%s_wait", spawn_name);
471       myargv = (char **) calloc(2, sizeof(char *));
472
473       myargv[0] = xbt_strdup(spawn_name);
474       myargv[1] = NULL;
475
476       comm_helper =
477           MSG_process_create_with_arguments(task_name, spawned_recv,
478                                             NULL, MSG_host_self(),
479                                             1, myargv);
480     }
481
482     for (i = 1; i < communicator_size; i++) {
483       sprintf(task_name, "%s_p%d_p0_wait", name, i);
484       MSG_task_receive(&task, task_name);
485       MSG_task_destroy(task);
486       task = NULL;
487     }
488
489     comp_task =
490         MSG_task_create("allReduce_comp", parse_double(comp_size), 0,
491                         NULL);
492     DEBUG1("%s: computing 'reduce_comp'", name);
493     MSG_task_execute(comp_task);
494     MSG_task_destroy(comp_task);
495     DEBUG1("%s: computed", name);
496
497     for (i = 1; i < communicator_size; i++) {
498       myargv = (char **) calloc(3, sizeof(char *));
499       myargv[0] = xbt_strdup(name);
500       myargv[1] = xbt_strdup(comm_size);
501       myargv[2] = NULL;
502
503       sprintf(spawn_name, "%s_%d", myargv[0], i);
504       comm_helper =
505           MSG_process_create_with_arguments(spawn_name, spawned_send,
506                                             NULL, MSG_host_self(), 2,
507                                             myargv);
508     }
509
510     for (i = 1; i < communicator_size; i++) {
511       sprintf(task_name, "p%d_wait", i);
512       DEBUG1("get on %s", task_name);
513       MSG_task_receive(&task, task_name);
514       MSG_task_destroy(task);
515       task = NULL;
516     }
517     DEBUG2("%s: all messages sent by %s have been received",
518            name, process_name);
519
520   } else {
521     DEBUG2("%s: %s sends", name, process_name);
522     sprintf(task_name, "%s_%s_p0", name, process_name);
523     DEBUG1("put on %s", task_name);
524     MSG_task_send(MSG_task_create(name, 0, parse_double(comm_size), NULL),
525                   task_name);
526
527     MSG_task_receive(&task, name);
528     MSG_task_destroy(task);
529     DEBUG2("%s: %s has received", name, process_name);
530     sprintf(task_name, "%s_wait", process_name);
531     DEBUG1("put on %s", task_name);
532     MSG_task_send(MSG_task_create("waiter", 0, 0, NULL), task_name);
533
534   }
535
536   MSG_process_set_data(MSG_process_self(), (void *) counters);
537   VERB2("%s %f", xbt_str_join(action, " "), MSG_get_clock() - clock);
538   free(name);
539 }
540
541 static void action_comm_size(xbt_dynar_t action)
542 {
543   char *name = NULL;
544   char *size = xbt_dynar_get_as(action, 2, char *);
545   double clock = MSG_get_clock();
546
547   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
548     name = xbt_str_join(action, " ");
549   communicator_size = parse_double(size);
550   VERB2("%s %f", name, MSG_get_clock() - clock);
551   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
552     free(name);
553 }
554
555 static void action_compute(xbt_dynar_t action)
556 {
557   char *name = NULL;
558   char *amout = xbt_dynar_get_as(action, 2, char *);
559   m_task_t task = MSG_task_create(name, parse_double(amout), 0, NULL);
560   double clock = MSG_get_clock();
561
562   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
563     name = xbt_str_join(action, " ");
564   DEBUG1("Entering %s", name);
565   MSG_task_execute(task);
566   MSG_task_destroy(task);
567   VERB2("%s %f", name, MSG_get_clock() - clock);
568   if (XBT_LOG_ISENABLED(actions, xbt_log_priority_verbose))
569     free(name);
570 }
571
572 static void action_init(xbt_dynar_t action)
573
574 #ifdef HAVE_TRACING
575   TRACE_smpi_init(get_rank(MSG_process_get_name(MSG_process_self())));
576 #endif
577   DEBUG0("Initialize the counters");
578   process_globals_t globals = (process_globals_t) calloc(1, sizeof(s_process_globals_t));
579   globals->isends = xbt_dynar_new(sizeof(msg_comm_t),NULL);
580   MSG_process_set_data(MSG_process_self(),globals);
581
582 }
583
584 static void action_finalize(xbt_dynar_t action)
585 {
586 #ifdef HAVE_TRACING
587   TRACE_smpi_finalize(get_rank(MSG_process_get_name(MSG_process_self())));
588 #endif
589   process_globals_t counters = (process_globals_t) MSG_process_get_data(MSG_process_self());
590   if (counters)
591           free(counters);
592 }
593
594 /** Main function */
595 int main(int argc, char *argv[])
596 {
597   MSG_error_t res = MSG_OK;
598
599   /* Check the given arguments */
600   MSG_global_init(&argc, argv);
601   if (argc < 3) {
602     printf("Usage: %s platform_file deployment_file [action_files]\n",
603            argv[0]);
604     printf
605         ("example: %s msg_platform.xml msg_deployment.xml actions # if all actions are in the same file\n",
606          argv[0]);
607     printf
608         ("example: %s msg_platform.xml msg_deployment.xml # if actions are in separate files, specified in deployment\n",
609          argv[0]);
610     exit(1);
611   }
612
613   /*  Simulation setting */
614   MSG_create_environment(argv[1]);
615
616   /* No need to register functions as in classical MSG programs: the actions get started anyway */
617   MSG_launch_application(argv[2]);
618
619   /*   Action registration */
620   MSG_action_register("init",     action_init);
621   MSG_action_register("finalize", action_finalize);
622   MSG_action_register("comm_size",action_comm_size);
623   MSG_action_register("send",     action_send);
624   MSG_action_register("Isend",    action_Isend);
625   MSG_action_register("recv",     action_recv);
626   MSG_action_register("Irecv",    action_Irecv);
627   MSG_action_register("wait",     action_wait);
628   MSG_action_register("barrier",  action_barrier);
629   MSG_action_register("bcast",    action_bcast);
630   MSG_action_register("reduce",   action_reduce);
631   MSG_action_register("allReduce",action_allReduce);
632   MSG_action_register("sleep",    action_sleep);
633   MSG_action_register("compute",  action_compute);
634
635
636   /* Actually do the simulation using MSG_action_trace_run */
637   res = MSG_action_trace_run(argv[3]);  // it's ok to pass a NULL argument here
638
639   INFO1("Simulation time %g", MSG_get_clock());
640   MSG_clean();
641
642   if (res == MSG_OK)
643     return 0;
644   else
645     return 1;
646 }                               /* end_of_main */