7 /* Create a log channel to have nice outputs. */
9 #include "xbt/asserts.h"
11 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
13 int master(int argc, char *argv[]);
14 int slave(int argc, char *argv[]);
15 MSG_error_t test_all(const char *platform_file, const char *application_file);
22 #define FINALIZE ((void*)221297) /* a magic number to tell people to stop working */
25 int master(int argc, char *argv[])
27 char *slavename = NULL;
28 double task_comm_size = 0;
33 xbt_assert1(sscanf(argv[1],"%lg", &task_comm_size),
34 "Invalid argument %s\n", argv[1]);
39 { /* Task creation. */
40 char sprintf_buffer[64] = "Task_0";
41 todo = MSG_task_create(sprintf_buffer, 0, task_comm_size, NULL);
44 { /* Process organisation */
45 slave = MSG_get_host_by_name(slavename);
48 /* time measurement */
49 double start_time = MSG_get_clock();
50 MSG_task_put(todo, slave, PORT_22);
51 double end_time = MSG_get_clock();
52 INFO3("Send completed (to %s). Transfer time: %f\t Agregate bandwidth: %f\n",
53 slave->name, (end_time - start_time), task_comm_size/(end_time-start_time));
54 printf("Completed peer: %s time: %f\n", slave->name, (end_time-start_time));
55 MSG_task_put(MSG_task_create("finalize", 0, 0, FINALIZE),
61 /** Receiver function */
62 int slave(int argc, char *argv[])
67 a = MSG_task_get(&(task), PORT_22);
69 if(MSG_task_get_data(task)==FINALIZE) {
70 MSG_task_destroy(task);
73 MSG_task_destroy(task);
75 INFO0("Hey?! What's up?");
76 xbt_assert0(0,"Unexpected behavior.");
83 MSG_error_t test_all(const char *platform_file,
84 const char *application_file)
86 MSG_error_t res = MSG_OK;
88 /* MSG_config("workstation_model", "GTNETS"); */
89 /* MSG_config("workstation_model","KCCFLN05"); */
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[])
108 MSG_error_t res = MSG_OK;
110 MSG_global_init(&argc,argv);
112 printf ("Usage: %s platform_file deployment_file\n",argv[0]);
115 res = test_all(argv[1],argv[2]);
119 if(res==MSG_OK) return 0;