Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use new style logging macros.
[simgrid.git] / examples / msg / parallel_contexts / pcontexts.c
1 #include <msg/msg.h>
2 /* Create a log channel to have nice outputs. */
3 #include "xbt/log.h"
4
5 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
6                              "Messages specific for this msg example");
7 #define MAX_ITER 200000
8 #define WORK 100000
9
10 int node(int argc, char **argv);
11 MSG_error_t test_all(const char *, const char *);
12 int main(int argc, char *argv[]);
13
14 int node(int argc, char** argv)
15 {
16   int i,j;
17   m_task_t task;
18
19   for(i=0; i < MAX_ITER; i++){
20     task = MSG_task_create("test", 100000000, 1, NULL);
21
22     for(j=0; j < WORK; j++);
23
24     MSG_task_execute(task);
25     XBT_INFO("Task successfully executed");
26     MSG_task_destroy(task);
27   }
28
29   return 0;
30 }
31
32 /** Test function */
33 MSG_error_t test_all(const char *platform_file,
34                      const char *application_file)
35 {
36   MSG_error_t res = MSG_OK;
37
38   /* MSG_config("workstation/model","KCCFLN05"); */
39   {                             /*  Simulation setting */
40     MSG_set_channel_number(0);
41     MSG_create_environment(platform_file);
42   }
43   {                             /*   Application deployment */
44     MSG_function_register("node", node);
45     MSG_launch_application(application_file);
46   }
47   res = MSG_main();
48
49   XBT_INFO("Simulation time %g", MSG_get_clock());
50   return res;
51 }                               /* end_of_test_all */
52
53
54 /** Main function */
55 int main(int argc, char *argv[])
56 {
57   MSG_error_t res = MSG_OK;
58
59   MSG_global_init(&argc, argv);
60   if (argc < 3) {
61     printf("Usage: %s platform_file deployment_file\n", argv[0]);
62     printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
63     exit(1);
64   }
65   res = test_all(argv[1], argv[2]);
66   MSG_clean();
67
68   if (res == MSG_OK)
69     return 0;
70   else
71     return 1;
72 }                               /* end_of_main */