A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Don't let field unitialized.
[simgrid.git]
/
examples
/
msg
/
cloud-capping
/
cloud-capping.c
diff --git
a/examples/msg/cloud-capping/cloud-capping.c
b/examples/msg/cloud-capping/cloud-capping.c
index
aef3626
..
73b3eda
100644
(file)
--- a/
examples/msg/cloud-capping/cloud-capping.c
+++ b/
examples/msg/cloud-capping/cloud-capping.c
@@
-55,53
+55,50
@@
static int worker_busy_loop_main(int argc, char *argv[])
{
msg_task_t *task = MSG_process_get_data(MSG_process_self());
MSG_task_execute(*task);
+ MSG_task_destroy(*task);
return 0;
}
-/* FIXME: */
#define DOUBLE_MAX 1e11
static void test_dynamic_change(void)
{
- xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
- msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t);
+ msg_host_t pm0 = MSG_host_by_name("Fafard");
- msg_
host
_t vm0 = MSG_vm_create_core(pm0, "VM0");
- msg_
host
_t vm1 = MSG_vm_create_core(pm0, "VM1");
+ msg_
vm
_t vm0 = MSG_vm_create_core(pm0, "VM0");
+ msg_
vm
_t vm1 = MSG_vm_create_core(pm0, "VM1");
MSG_vm_start(vm0);
MSG_vm_start(vm1);
msg_task_t task0 = MSG_task_create("Task0", DOUBLE_MAX, 0, NULL);
msg_task_t task1 = MSG_task_create("Task1", DOUBLE_MAX, 0, NULL);
- MSG_process_create("worker0", worker_busy_loop_main, &task0, vm0);
- MSG_process_create("worker1", worker_busy_loop_main, &task1, vm1);
+ MSG_process_create("worker0", worker_busy_loop_main, &task0,
(msg_host_t)
vm0);
+ MSG_process_create("worker1", worker_busy_loop_main, &task1,
(msg_host_t)
vm1);
double task0_remain_prev = MSG_task_get_flops_amount(task0);
double task1_remain_prev = MSG_task_get_flops_amount(task1);
- {
- const double cpu_speed = MSG_host_get_speed(pm0);
- int i = 0;
- for (i = 0; i < 10; i++) {
- double new_bound = (cpu_speed / 10) * i;
- XBT_INFO("set bound of VM1 to %f", new_bound);
- MSG_vm_set_bound(vm1, new_bound);
- MSG_process_sleep(100);
+ const double cpu_speed = MSG_host_get_speed(pm0);
+ for (int i = 0; i < 10; i++) {
+ double new_bound = (cpu_speed / 10) * i;
+ XBT_INFO("set bound of VM1 to %f", new_bound);
+ MSG_vm_set_bound(vm1, new_bound);
+ MSG_process_sleep(100);
-
double task0_remain_now = MSG_task_get_flops_amount(task0);
-
double task1_remain_now = MSG_task_get_flops_amount(task1);
+ double task0_remain_now = MSG_task_get_flops_amount(task0);
+ double task1_remain_now = MSG_task_get_flops_amount(task1);
-
double task0_flops_per_sec = task0_remain_prev - task0_remain_now;
-
double task1_flops_per_sec = task1_remain_prev - task1_remain_now;
+ double task0_flops_per_sec = task0_remain_prev - task0_remain_now;
+ double task1_flops_per_sec = task1_remain_prev - task1_remain_now;
-
XBT_INFO("Task0@VM0: %f flops/s", task0_flops_per_sec / 100);
-
XBT_INFO("Task1@VM1: %f flops/s", task1_flops_per_sec / 100);
+ XBT_INFO("Task0@VM0: %f flops/s", task0_flops_per_sec / 100);
+ XBT_INFO("Task1@VM1: %f flops/s", task1_flops_per_sec / 100);
- task0_remain_prev = task0_remain_now;
- task1_remain_prev = task1_remain_now;
- }
+ task0_remain_prev = task0_remain_now;
+ task1_remain_prev = task1_remain_now;
}
+
MSG_process_sleep(2000); // let the tasks end
MSG_vm_destroy(vm0);
@@
-195,9
+192,8
@@
static void test_two_tasks(msg_host_t hostA, msg_host_t hostB)
static int master_main(int argc, char *argv[])
{
- xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
- msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t);
- msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t);
+ msg_host_t pm0 = MSG_host_by_name("Fafard");
+ msg_host_t pm1 = MSG_host_by_name("Fafard");
XBT_INFO("# 1. Put a single task on a PM. ");
test_one_task(pm0);
@@
-207,15
+203,15
@@
static int master_main(int argc, char *argv[])
test_two_tasks(pm0, pm0);
XBT_INFO(" ");
- msg_
host
_t vm0 = MSG_vm_create_core(pm0, "VM0");
+ msg_
vm
_t vm0 = MSG_vm_create_core(pm0, "VM0");
MSG_vm_start(vm0);
XBT_INFO("# 3. Put a single task on a VM. ");
- test_one_task(vm0);
+ test_one_task(
(msg_host_t)
vm0);
XBT_INFO(" ");
XBT_INFO("# 4. Put two tasks on a VM.");
- test_two_tasks(
vm0,
vm0);
+ test_two_tasks(
(msg_host_t)vm0, (msg_host_t)
vm0);
XBT_INFO(" ");
MSG_vm_destroy(vm0);
@@
-224,7
+220,7
@@
static int master_main(int argc, char *argv[])
MSG_vm_start(vm0);
XBT_INFO("# 6. Put a task on a PM and a task on a VM.");
- test_two_tasks(pm0, vm0);
+ test_two_tasks(pm0,
(msg_host_t)
vm0);
XBT_INFO(" ");
MSG_vm_destroy(vm0);
@@
-235,15
+231,15
@@
static int master_main(int argc, char *argv[])
MSG_vm_start(vm0);
XBT_INFO("# 7. Put a single task on the VM capped by 10%%.");
- test_one_task(vm0);
+ test_one_task(
(msg_host_t)
vm0);
XBT_INFO(" ");
XBT_INFO("# 8. Put two tasks on the VM capped by 10%%.");
- test_two_tasks(
vm0,
vm0);
+ test_two_tasks(
(msg_host_t)vm0, (msg_host_t)
vm0);
XBT_INFO(" ");
XBT_INFO("# 9. Put a task on a PM and a task on the VM capped by 10%%.");
- test_two_tasks(pm0, vm0);
+ test_two_tasks(pm0,
(msg_host_t)
vm0);
XBT_INFO(" ");
MSG_vm_destroy(vm0);
@@
-253,7
+249,7
@@
static int master_main(int argc, char *argv[])
s_vm_params_t params;
memset(¶ms, 0, sizeof(params));
params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
- MSG_
host
_set_params(vm0, ¶ms);
+ MSG_
vm
_set_params(vm0, ¶ms);
MSG_vm_start(vm0);
cpu_speed = MSG_host_get_speed(pm0);
@@
-263,13
+259,13
@@
static int master_main(int argc, char *argv[])
const double computation_amount = cpu_speed * 10;
XBT_INFO("# 10. (a) Put a task on a VM without any bound.");
- launch_worker(vm0, "worker0", computation_amount, 0, 0);
+ launch_worker(
(msg_host_t)
vm0, "worker0", computation_amount, 0, 0);
MSG_process_sleep(1000);
XBT_INFO(" ");
XBT_INFO("# 10. (b) set 10%% bound to the VM, and then put a task on the VM.");
MSG_vm_set_bound(vm0, cpu_speed / 10);
- launch_worker(vm0, "worker0", computation_amount, 0, 0);
+ launch_worker(
(msg_host_t)
vm0, "worker0", computation_amount, 0, 0);
MSG_process_sleep(1000);
XBT_INFO(" ");
@@
-278,7
+274,7
@@
static int master_main(int argc, char *argv[])
XBT_INFO(" ");
XBT_INFO("# 10. (d) Put a task again on the VM.");
- launch_worker(vm0, "worker0", computation_amount, 0, 0);
+ launch_worker(
(msg_host_t)
vm0, "worker0", computation_amount, 0, 0);
MSG_process_sleep(1000);
XBT_INFO(" ");
@@
-310,8
+306,7
@@
int main(int argc, char *argv[])
MSG_create_environment(argv[1]);
- xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar();
- msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t);
+ msg_host_t pm0 = MSG_host_by_name("Fafard");
launch_master(pm0);
int res = MSG_main();