4 /* Create a log channel to have nice outputs. */
6 #include "xbt/asserts.h"
8 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"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);
22 double task_comm_size=0.0;
24 #define FINALIZE ((void*)221297) /* a magic number to tell people to stop working */
27 int master(int argc, char *argv[]){
28 char *slavename = NULL;
34 xbt_assert1(0, "Invalid number of arguments in master process, expected 4 got %d\n", argc);
38 xbt_assert1(sscanf(argv[1],"%lg", &task_comm_size),
39 "Invalid argument %s\n", argv[1]);
40 INFO1("task_comm_size : %f\n", task_comm_size);
47 char sprintf_buffer[64] = "Task_0";
48 todo = MSG_task_create(sprintf_buffer, 0, task_comm_size, NULL);
50 /* Process organisation */
51 slave = MSG_get_host_by_name(slavename);
53 /* Time measurement */
54 time = MSG_get_clock();
56 a = MSG_task_put(todo, slave, PORT_22);
57 xbt_assert0(!a,"MSG_task_put failure");
63 /** Receiver function */
64 int slave(int argc, char *argv[])
69 a = MSG_task_get(&(task), PORT_22);
70 xbt_assert0(!a, "MSG_task_get failure");
73 time = MSG_get_clock() - time;
75 INFO1("Total transmission time: %f", time);
76 INFO1("Hockney estimated bandwidth: %f", ((task_comm_size*8)/time)/1000);
78 MSG_task_destroy(task);
86 MSG_error_t test_all(const char *platform_file,
87 const char *application_file){
88 MSG_error_t res = MSG_OK;
90 /* Simulation setting */
91 MSG_set_channel_number(MAX_CHANNEL);
92 MSG_paje_output("msg_test.trace");
93 MSG_create_environment(platform_file);
95 /* Application deployment */
96 MSG_function_register("master", master);
97 MSG_function_register("slave", slave);
98 MSG_launch_application(application_file);
102 } /* end_of_test_all */
106 int main(int argc, char *argv[]){
107 MSG_error_t res = MSG_OK;
109 MSG_global_init(&argc,argv);
111 printf ("Usage: %s platform_file deployment_file\n",argv[0]);
114 res = test_all(argv[1],argv[2]);
118 if(res==MSG_OK) return 0;