5 #include "xbt/asserts.h"
7 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
8 "Messages specific for this msg example");
10 int master(int argc, char *argv[]);
11 int slave(int argc, char *argv[]);
12 MSG_error_t test_all(const char *platform_file, const char *application_file);
19 //keep a pointer to all surf running tasks.
22 double start_time, end_time, elapsed_time;
23 double gl_data_size[NTASKS];
24 m_task_t gl_task_array[NTASKS];
25 const char *slavenames[NTASKS];
26 const char *masternames[NTASKS];
27 int gl_task_array_id = 0;
29 #define FINALIZE ((void*)221297) /* a magic number to tell people to stop working */
32 int master(int argc, char *argv[])
34 char *slavename = NULL;
35 double task_comm_size = 0;
39 //unique id to control statistics
43 INFO1("Strange number of arguments expected 3 got %d", argc - 1);
47 xbt_assert1(sscanf(argv[1], "%lg", &task_comm_size),
48 "Invalid argument %s\n", argv[1]);
53 sprintf(id_alias, "%d", id);
54 slavenames[id] = slavename;
56 masternames[id] = MSG_host_get_name(MSG_host_self());
58 { /* Task creation. */
59 char sprintf_buffer[64] = "Task_0";
60 todo = MSG_task_create(sprintf_buffer, 0, task_comm_size, NULL);
61 //keep track of running tasks
62 gl_task_array[id] = todo;
63 gl_data_size[id] = task_comm_size;
66 { /* Process organisation */
67 slave = MSG_get_host_by_name(slavename);
70 /* time measurement */
71 start_time = MSG_get_clock();
72 MSG_task_send(todo, id_alias);
73 end_time = MSG_get_clock();
76 ("===> Estimated Bw of FLOW[%d] : %f ; message from %s to %s with remaining : %f",
77 id + 1, task_comm_size / (end_time - start_time), masternames[id],
84 /** Receiver function */
85 int slave(int argc, char *argv[])
94 INFO1("Strange number of arguments expected 1 got %d", argc - 1);
97 sprintf(id_alias, "%d", id);
99 a = MSG_task_receive(&(task), id_alias);
104 MSG_error_t test_all(const char *platform_file, const char *application_file)
106 MSG_error_t res = MSG_OK;
107 MSG_set_channel_number(MAX_CHANNEL);
108 MSG_create_environment(platform_file);
109 MSG_function_register("master", master);
110 MSG_function_register("slave", slave);
111 MSG_launch_application(application_file);
114 } /* end_of_test_all */
117 int main(int argc, char *argv[])
119 MSG_error_t res = MSG_OK;
122 MSG_global_init(&argc, argv);
124 printf("Usage: %s platform_file deployment_file\n", argv[0]);
127 res = test_all(argv[1], argv[2]);