Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Start working on a trace replayer in GRAS (to replay it on real platforms)
[simgrid.git] / examples / gras / replay / replay.c
1 /* Copyright (c) 2009 Da SimGrid Team.  All rights reserved.                */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 /* This example replays a trace as produced by examples/simdag/dax, or other means
7  * This is mainly interesting when run on real platforms, to validate the results
8  * given in the simulator when running SimDag.
9  */
10
11 #include "xbt/ex.h"
12 #include "xbt/log.h"
13 #include "xbt/str.h"
14 #include "xbt/dynar.h"
15 #include "workload.h"
16 #include "gras.h"
17 #include "amok/peermanagement.h"
18 #include <stdio.h>
19
20 int master(int argc,char *argv[]);
21 int worker(int argc,char *argv[]);
22
23 XBT_LOG_NEW_DEFAULT_CATEGORY(replay, "Messages specific to this example");
24
25 static void declare_msg() {
26   gras_datadesc_type_t command_assignment_type;
27
28
29 }
30
31 int master(int argc,char *argv[]) {
32   gras_init(&argc,argv);
33   amok_pm_init();
34
35   xbt_assert0(argc==3,"usage: replay_master tracefile port");
36   gras_socket_server(atoi(argv[2])); /* open my master socket, even if I don't use it */
37   xbt_dynar_t peers = amok_pm_group_new("replay");            /* group of slaves */
38   xbt_dynar_t cmds = xbt_workload_parse_file(argv[1]);
39   xbt_workload_sort_who_date(cmds);
40   unsigned int cursor;
41   xbt_workload_elm_t cmd;
42
43   xbt_dynar_foreach(cmds,cursor,cmd) {
44     char *str = xbt_workload_elm_to_string(cmd);
45     INFO1("%s",str);
46     free(str);
47   }
48
49   /* friends, we're ready. Come and play */
50   INFO0("Wait for peers for 5 sec");
51   gras_msg_handleall(5);
52   INFO1("Got %ld pals", xbt_dynar_length(peers));
53
54
55   /* Done, exiting */
56   xbt_dynar_free(&cmds);
57   gras_exit();
58   return 0;
59 }
60
61 int worker(int argc,char *argv[]) {
62   gras_init(&argc,argv);
63   amok_pm_init();
64
65   gras_exit();
66   return 0;
67 }