1 /* Copyright (c) 2007-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/msg.h"
8 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
10 static int computation_fun(int argc, char* argv[])
12 msg_task_t task = MSG_task_create("Task", 100000000, 0, NULL);
14 double clock_sta = MSG_get_clock();
15 MSG_task_execute(task);
16 double clock_end = MSG_get_clock();
18 XBT_INFO("Task took %gs to execute", clock_end - clock_sta);
20 MSG_task_destroy(task);
25 static int master_main(int argc, char* argv[])
27 msg_host_t pm0 = MSG_host_by_name("node-0.acme.org");
28 msg_host_t pm1 = MSG_host_by_name("node-1.acme.org");
29 xbt_assert(pm0, "Host node-0.acme.org does not seem to exist");
31 XBT_INFO("## Test 1 (started): check computation on normal PMs");
33 XBT_INFO("### Put a task on a PM");
34 MSG_process_create("compute", computation_fun, NULL, pm0);
37 XBT_INFO("### Put two tasks on a PM");
38 MSG_process_create("compute", computation_fun, NULL, pm0);
39 MSG_process_create("compute", computation_fun, NULL, pm0);
42 XBT_INFO("### Put a task on each PM");
43 MSG_process_create("compute", computation_fun, NULL, pm0);
44 MSG_process_create("compute", computation_fun, NULL, pm1);
47 XBT_INFO("## Test 1 (ended)");
49 XBT_INFO("## Test 2 (started): check impact of running a task inside a VM (there is no degradation for the moment)");
51 XBT_INFO("### Put a VM on a PM, and put a task to the VM");
52 msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
54 MSG_process_create("compute", computation_fun, NULL, vm0);
58 XBT_INFO("## Test 2 (ended)");
61 "## Test 3 (started): check impact of running a task collocated with a VM (there is no VM noise for the moment)");
63 XBT_INFO("### Put a VM on a PM, and put a task to the PM");
64 vm0 = MSG_vm_create_core(pm0, "VM0");
66 MSG_process_create("compute", computation_fun, NULL, pm0);
70 XBT_INFO("## Test 3 (ended)");
72 XBT_INFO("## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for"
73 " the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1");
75 XBT_INFO("### Put two VMs on a PM, and put a task to each VM");
76 vm0 = MSG_vm_create_core(pm0, "VM0");
77 msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1");
80 MSG_process_create("compute", computation_fun, NULL, vm0);
81 MSG_process_create("compute", computation_fun, NULL, vm1);
86 XBT_INFO("### Put a VM on each PM, and put a task to each VM");
87 vm0 = MSG_vm_create_core(pm0, "VM0");
88 vm1 = MSG_vm_create_core(pm1, "VM1");
91 MSG_process_create("compute", computation_fun, NULL, vm0);
92 MSG_process_create("compute", computation_fun, NULL, vm1);
96 XBT_INFO("## Test 4 (ended)");
101 int main(int argc, char* argv[])
103 /* Get the arguments */
104 MSG_init(&argc, argv);
106 /* load the platform file */
107 const char* platform = "../../platforms/cluster.xml";
110 MSG_create_environment(platform);
112 msg_host_t pm0 = MSG_host_by_name("node-0.acme.org");
113 xbt_assert(pm0, "Host 'node-0.acme.org' not found");
114 MSG_process_create("master", master_main, NULL, pm0);
116 return MSG_main() != MSG_OK;