Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
merge conflict resolved
[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_create_environment(platform_file);
41   }
42   {                             /*   Application deployment */
43     MSG_function_register("node", node);
44     MSG_launch_application(application_file);
45   }
46   res = MSG_main();
47
48   XBT_INFO("Simulation time %g", MSG_get_clock());
49   return res;
50 }                               /* end_of_test_all */
51
52
53 /** Main function */
54 int main(int argc, char *argv[])
55 {
56   MSG_error_t res = MSG_OK;
57
58   MSG_global_init(&argc, argv);
59   if (argc < 3) {
60     printf("Usage: %s platform_file deployment_file\n", argv[0]);
61     printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
62     exit(1);
63   }
64   res = test_all(argv[1], argv[2]);
65   MSG_clean();
66
67   if (res == MSG_OK)
68     return 0;
69   else
70     return 1;
71 }                               /* end_of_main */