Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
05a336dfc84d7d78557a7f164af07ab2c97472ac
[simgrid.git] / examples / msg / chainsend / chainsend.c
1 /* Copyright (c) 2007-2010, 2012-2014. 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
10 #include "simgrid/msg.h"        /* Yeah! If you want to use msg, you need to include simgrid/msg.h */
11 #include "xbt/sysdep.h"         /* calloc */
12
13 /* Create a log channel to have nice outputs. */
14 #include "xbt/log.h"
15 #include "xbt/asserts.h"
16
17 #include "iterator.h"
18 #include "messages.h"
19 #include "broadcaster.h"
20 #include "peer.h"
21
22 /** @addtogroup MSG_examples
23  * 
24  *  - <b>chainsend/chainsend.c: Chainsend implementation</b>.
25  */
26
27
28 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_chainsend,
29                              "Messages specific for chainsend");
30
31 /*
32  Data structures
33  */
34
35 /* Initialization stuff */
36 msg_error_t test_all(const char *platform_file,
37                      const char *application_file);
38
39
40 /** Test function */
41 msg_error_t test_all(const char *platform_file,
42                      const char *application_file)
43 {
44
45   msg_error_t res = MSG_OK;
46
47
48
49   XBT_DEBUG("test_all");
50
51   /*  Simulation setting */
52   MSG_create_environment(platform_file);
53
54   /* Trace categories */
55   TRACE_category_with_color("host0", "0 0 1");
56   TRACE_category_with_color("host1", "0 1 0");
57   TRACE_category_with_color("host2", "0 1 1");
58   TRACE_category_with_color("host3", "1 0 0");
59   TRACE_category_with_color("host4", "1 0 1");
60   TRACE_category_with_color("host5", "0 0 0");
61   TRACE_category_with_color("host6", "1 1 0");
62   TRACE_category_with_color("host7", "1 1 1");
63   TRACE_category_with_color("host8", "0 1 0");
64
65   /*   Application deployment */
66   MSG_function_register("broadcaster", broadcaster);
67   MSG_function_register("peer", peer);
68
69   MSG_launch_application(application_file);
70
71   res = MSG_main();
72
73   return res;
74 }                               /* end_of_test_all */
75
76
77 /** Main function */
78 int main(int argc, char *argv[])
79 {
80   msg_error_t res = MSG_OK;
81
82 #ifdef _MSC_VER
83   unsigned int prev_exponent_format =
84       _set_output_format(_TWO_DIGIT_EXPONENT);
85 #endif
86
87   MSG_init(&argc, argv);
88
89   /*if (argc <= 3) {
90     XBT_CRITICAL("Usage: %s platform_file deployment_file <model>\n",
91               argv[0]);
92     XBT_CRITICAL
93         ("example: %s msg_platform.xml msg_deployment.xml KCCFLN05_Vegas\n",
94          argv[0]);
95     exit(1);
96   }*/
97
98   /* Options for the workstation/model:
99
100      KCCFLN05              => for maxmin
101      KCCFLN05_proportional => for proportional (Vegas)
102      KCCFLN05_Vegas        => for TCP Vegas
103      KCCFLN05_Reno         => for TCP Reno
104    */
105   //MSG_config("workstation/model", argv[3]);
106
107   res = test_all(argv[1], argv[2]);
108
109   XBT_INFO("Total simulation time: %e", MSG_get_clock());
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 */