3 /* Copyright (c) 2002,2003,2004 Arnaud Legrand. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */
10 #include "xbt/sysdep.h" /* calloc, printf */
12 /* Create a log channel to have nice outputs. */
14 #include "xbt/asserts.h"
15 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,"Messages specific for this msg example");
17 int test(int argc, char *argv[]);
18 MSG_error_t test_all(const char *platform_file);
20 /** Emitter function */
21 int test(int argc, char *argv[])
24 m_host_t *slaves = NULL;
25 double task_comp_size = 100000;
26 double task_comm_size = 10000;
27 double *computation_amount = NULL;
28 double *communication_amount = NULL;
29 m_task_t ptask = NULL;
32 slaves_count = MSG_get_host_number();
33 slaves = MSG_get_host_table();
35 computation_amount = xbt_new0(double,slaves_count);
36 communication_amount = xbt_new0(double,slaves_count*slaves_count);
38 for(i=0;i<slaves_count;i++)
39 computation_amount[i]=task_comp_size;
41 for(i=0;i<slaves_count;i++)
42 for(j=i+1;j<slaves_count;j++)
43 communication_amount[i*slaves_count+j]=task_comm_size;
45 ptask = MSG_parallel_task_create("parallel task",
50 MSG_parallel_task_execute(ptask);
53 INFO0("Goodbye now!");
54 free(communication_amount);
55 free(computation_amount);
61 MSG_error_t test_all(const char *platform_file)
63 MSG_error_t res = MSG_OK;
65 /* MSG_config("workstation_model","KCCFLN05"); */
66 MSG_set_channel_number(1);
67 MSG_create_environment(platform_file);
69 MSG_process_create("test",test,NULL,MSG_get_host_table()[0]);
72 INFO1("Simulation time %g",MSG_get_clock());
76 int main(int argc, char *argv[])
78 MSG_error_t res = MSG_OK;
80 MSG_global_init(&argc,argv);
82 printf ("Usage: %s platform_file\n",argv[0]);
83 printf ("example: %s msg_platform.xml\n",argv[0]);
86 res = test_all(argv[1]);