Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Code is now modular and tidy
[simgrid.git] / examples / msg / kadeploy / kadeploy.c
1 /* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
2  * Copyright (c) 2012. Maximiliano Geier.
3  * All rights reserved.                                                     */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10
11 #include "msg/msg.h"            /* Yeah! If you want to use msg, you need to include msg/msg.h */
12 #include "xbt/sysdep.h"         /* calloc */
13
14 /* Create a log channel to have nice outputs. */
15 #include "xbt/log.h"
16 #include "xbt/asserts.h"
17
18 #include "iterator.h"
19 #include "messages.h"
20 #include "broadcaster.h"
21 #include "peer.h"
22
23 /** @addtogroup MSG_examples
24  * 
25  *  - <b>kadeploy/kadeploy.c: Kadeploy implementation</b>.
26  */
27
28
29 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kadeploy,
30                              "Messages specific for kadeploy");
31
32 /*
33  Data structures
34  */
35
36 /* Initialization stuff */
37 msg_error_t test_all(const char *platform_file,
38                      const char *application_file);
39
40
41 /** Test function */
42 msg_error_t test_all(const char *platform_file,
43                      const char *application_file)
44 {
45
46   msg_error_t res = MSG_OK;
47
48
49
50   XBT_INFO("test_all");
51
52   /*  Simulation setting */
53   MSG_create_environment(platform_file);
54
55   /* Trace categories */
56   TRACE_category_with_color("host0", "0 0 1");
57   TRACE_category_with_color("host1", "0 1 0");
58   TRACE_category_with_color("host2", "0 1 1");
59   TRACE_category_with_color("host3", "1 0 0");
60   TRACE_category_with_color("host4", "1 0 1");
61   TRACE_category_with_color("host5", "1 1 0");
62
63   /*   Application deployment */
64   MSG_function_register("broadcaster", broadcaster);
65   MSG_function_register("peer", peer);
66
67   MSG_launch_application(application_file);
68
69   res = MSG_main();
70
71   return res;
72 }                               /* end_of_test_all */
73
74
75 /** Main function */
76 int main(int argc, char *argv[])
77 {
78   msg_error_t res = MSG_OK;
79
80 #ifdef _MSC_VER
81   unsigned int prev_exponent_format =
82       _set_output_format(_TWO_DIGIT_EXPONENT);
83 #endif
84
85   MSG_init(&argc, argv);
86
87   /*if (argc <= 3) {
88     XBT_CRITICAL("Usage: %s platform_file deployment_file <model>\n",
89               argv[0]);
90     XBT_CRITICAL
91         ("example: %s msg_platform.xml msg_deployment.xml KCCFLN05_Vegas\n",
92          argv[0]);
93     exit(1);
94   }*/
95
96   /* Options for the workstation/model:
97
98      KCCFLN05              => for maxmin
99      KCCFLN05_proportional => for proportional (Vegas)
100      KCCFLN05_Vegas        => for TCP Vegas
101      KCCFLN05_Reno         => for TCP Reno
102    */
103   //MSG_config("workstation/model", argv[3]);
104
105   res = test_all(argv[1], argv[2]);
106
107   XBT_INFO("Total simulation time: %le", MSG_get_clock());
108
109   MSG_clean();
110
111 #ifdef _MSC_VER
112   _set_output_format(prev_exponent_format);
113 #endif
114
115   if (res == MSG_OK)
116     return 0;
117   else
118     return 1;
119 }                               /* end_of_main */