From: Frederic Suter Date: Mon, 4 Apr 2016 20:34:48 +0000 (+0200) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid X-Git-Tag: v3_13~187 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f05224ef57c30ee1e71be443a160a236f7fe121a?hp=08835cc95982fa241576ee7b09006d5f97914584 Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid --- diff --git a/.gitignore b/.gitignore index 9d1bf7e3f9..f998fdbe04 100644 --- a/.gitignore +++ b/.gitignore @@ -124,10 +124,10 @@ examples/msg/async-waitany/async-waitany examples/msg/bittorrent/bittorrent examples/msg/bittorrent/bittorrent_platfgen examples/msg/chainsend/chainsend -examples/msg/cloud/bound -examples/msg/cloud/master_worker_vm -examples/msg/cloud/migrate_vm -examples/msg/cloud/multicore +examples/msg/cloud-capping/cloud-capping +examples/msg/cloud-masterworker/cloud-masterworker +examples/msg/cloud-migration/cloud-migration +examples/msg/cloud-multicore/cloud-multicore examples/msg/cloud/scale examples/msg/cloud/simple_vm examples/msg/cloud/two_tasks_vm diff --git a/examples/msg/CMakeLists.txt b/examples/msg/CMakeLists.txt index 1021e691bc..3304d35adb 100644 --- a/examples/msg/CMakeLists.txt +++ b/examples/msg/CMakeLists.txt @@ -1,4 +1,5 @@ -foreach(x actions-mpi actions-storage async-wait async-waitall async-waitany dht-chord dht-pastry exception +foreach(x actions-mpi actions-storage async-wait async-waitall async-waitany + cloud-capping cloud-masterworker cloud-migration cloud-multicore dht-chord dht-pastry exception energy-consumption energy-onoff energy-pstate energy-ptask energy-vm failures io-file io-file-unlink io-remote io-storage masterworker masterworker-mailbox pmm task-priority process-kill process-migration process-suspend properties sendrecv set-maestro process-startkilltime synchro token_ring trace-categories @@ -82,7 +83,8 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-mpi/action ${CMAKE_CURRENT_SOURCE_DIR}/process-startkilltime/start_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/process-startkilltime/start_kill_d.xml PARENT_SCOPE) -foreach(x actions-mpi actions-storage async-wait async-waitall async-waitany bittorrent chainsend dht-chord dht-kademlia +foreach(x actions-mpi actions-storage async-wait async-waitall async-waitany bittorrent chainsend + cloud-capping cloud-masterworker cloud-migration dht-chord dht-kademlia failures io-file io-file-unlink io-remote io-storage masterworker masterworker-mailbox task-priority process-kill process-migration process-suspend properties sendrecv synchro process-startkilltime token_ring) ADD_TESH_FACTORIES(msg-${x} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/${x} ${x}.tesh) diff --git a/examples/msg/cloud/bound.c b/examples/msg/cloud-capping/cloud-capping.c similarity index 100% rename from examples/msg/cloud/bound.c rename to examples/msg/cloud-capping/cloud-capping.c diff --git a/examples/msg/cloud-capping/cloud-capping.tesh b/examples/msg/cloud-capping/cloud-capping.tesh new file mode 100644 index 0000000000..75aeb14b19 --- /dev/null +++ b/examples/msg/cloud-capping/cloud-capping.tesh @@ -0,0 +1,213 @@ +$ $SG_TEST_EXENV ${bindir:=.}/cloud-capping ${srcdir:=.}/small_platform.xml --log=no_loc "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +> [ 0.000000] (1:master_@Fafard) # 1. Put a single task on a PM. +> [ 0.000000] (1:master_@Fafard) ### Test: with/without MSG_task_set_bound +> [ 0.000000] (1:master_@Fafard) ### Test: no bound for Task1@Fafard +> [ 10.000000] (2:worker0@Fafard) not bound => duration 10.000000 (76296000.000000 flops/s) +> [1000.000000] (1:master_@Fafard) ### Test: 50% for Task1@Fafard +> [1020.000000] (3:worker0@Fafard) bound to 38148000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [2000.000000] (1:master_@Fafard) ### Test: 33% for Task1@Fafard +> [2030.000000] (4:worker0@Fafard) bound to 25432000.000000 => duration 30.000000 (25432000.000000 flops/s) +> [3000.000000] (1:master_@Fafard) ### Test: zero for Task1@Fafard (i.e., unlimited) +> [3000.000000] (5:worker0@Fafard) bound == 0 means no capping (i.e., unlimited). +> [3010.000000] (5:worker0@Fafard) bound to 0.000000 => duration 10.000000 (76296000.000000 flops/s) +> [4000.000000] (1:master_@Fafard) ### Test: 200% for Task1@Fafard (i.e., meaningless) +> [4010.000000] (6:worker0@Fafard) bound to 152592000.000000 => duration 10.000000 (76296000.000000 flops/s) +> [5000.000000] (1:master_@Fafard) +> [5000.000000] (1:master_@Fafard) # 2. Put two tasks on a PM. +> [5000.000000] (1:master_@Fafard) ### Test: no bound for Task1@Fafard, no bound for Task2@Fafard +> [5020.000000] (8:worker1@Fafard) not bound => duration 20.000000 (38148000.000000 flops/s) +> [5020.000000] (7:worker0@Fafard) not bound => duration 20.000000 (38148000.000000 flops/s) +> [6000.000000] (1:master_@Fafard) ### Test: 0 for Task1@Fafard, 0 for Task2@Fafard (i.e., unlimited) +> [6000.000000] (9:worker0@Fafard) bound == 0 means no capping (i.e., unlimited). +> [6000.000000] (10:worker1@Fafard) bound == 0 means no capping (i.e., unlimited). +> [6020.000000] (10:worker1@Fafard) bound to 0.000000 => duration 20.000000 (38148000.000000 flops/s) +> [6020.000000] (9:worker0@Fafard) bound to 0.000000 => duration 20.000000 (38148000.000000 flops/s) +> [7000.000000] (1:master_@Fafard) ### Test: 50% for Task1@Fafard, 50% for Task2@Fafard +> [7020.000000] (12:worker1@Fafard) bound to 38148000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [7020.000000] (11:worker0@Fafard) bound to 38148000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [8000.000000] (1:master_@Fafard) ### Test: 25% for Task1@Fafard, 25% for Task2@Fafard +> [8040.000000] (14:worker1@Fafard) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [8040.000000] (13:worker0@Fafard) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [9000.000000] (1:master_@Fafard) ### Test: 75% for Task1@Fafard, 100% for Task2@Fafard +> [9020.000000] (16:worker1@Fafard) bound to 76296000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [9020.000000] (15:worker0@Fafard) bound to 57222000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [10000.000000] (1:master_@Fafard) ### Test: no bound for Task1@Fafard, 25% for Task2@Fafard +> [10013.333333] (17:worker0@Fafard) not bound => duration 13.333333 (57221999.999997 flops/s) +> [10040.000000] (18:worker1@Fafard) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [11000.000000] (1:master_@Fafard) ### Test: 75% for Task1@Fafard, 25% for Task2@Fafard +> [11013.333333] (19:worker0@Fafard) bound to 57222000.000000 => duration 13.333333 (57221999.999997 flops/s) +> [11040.000000] (20:worker1@Fafard) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [12000.000000] (1:master_@Fafard) +> [12000.000000] (1:master_@Fafard) # 3. Put a single task on a VM. +> [12000.000000] (1:master_@Fafard) ### Test: with/without MSG_task_set_bound +> [12000.000000] (1:master_@Fafard) ### Test: no bound for Task1@VM0 +> [12010.000000] (21:worker0@VM0) not bound => duration 10.000000 (76296000.000000 flops/s) +> [13000.000000] (1:master_@Fafard) ### Test: 50% for Task1@VM0 +> [13020.000000] (22:worker0@VM0) bound to 38148000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [14000.000000] (1:master_@Fafard) ### Test: 33% for Task1@VM0 +> [14030.000000] (23:worker0@VM0) bound to 25432000.000000 => duration 30.000000 (25432000.000000 flops/s) +> [15000.000000] (1:master_@Fafard) ### Test: zero for Task1@VM0 (i.e., unlimited) +> [15000.000000] (24:worker0@VM0) bound == 0 means no capping (i.e., unlimited). +> [15010.000000] (24:worker0@VM0) bound to 0.000000 => duration 10.000000 (76296000.000000 flops/s) +> [16000.000000] (1:master_@Fafard) ### Test: 200% for Task1@VM0 (i.e., meaningless) +> [16010.000000] (25:worker0@VM0) bound to 152592000.000000 => duration 10.000000 (76296000.000000 flops/s) +> [17000.000000] (1:master_@Fafard) +> [17000.000000] (1:master_@Fafard) # 4. Put two tasks on a VM. +> [17000.000000] (1:master_@Fafard) ### Test: no bound for Task1@VM0, no bound for Task2@VM0 +> [17020.000000] (27:worker1@VM0) not bound => duration 20.000000 (38148000.000000 flops/s) +> [17020.000000] (26:worker0@VM0) not bound => duration 20.000000 (38148000.000000 flops/s) +> [18000.000000] (1:master_@Fafard) ### Test: 0 for Task1@VM0, 0 for Task2@VM0 (i.e., unlimited) +> [18000.000000] (28:worker0@VM0) bound == 0 means no capping (i.e., unlimited). +> [18000.000000] (29:worker1@VM0) bound == 0 means no capping (i.e., unlimited). +> [18020.000000] (29:worker1@VM0) bound to 0.000000 => duration 20.000000 (38148000.000000 flops/s) +> [18020.000000] (28:worker0@VM0) bound to 0.000000 => duration 20.000000 (38148000.000000 flops/s) +> [19000.000000] (1:master_@Fafard) ### Test: 50% for Task1@VM0, 50% for Task2@VM0 +> [19020.000000] (31:worker1@VM0) bound to 38148000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [19020.000000] (30:worker0@VM0) bound to 38148000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [20000.000000] (1:master_@Fafard) ### Test: 25% for Task1@VM0, 25% for Task2@VM0 +> [20040.000000] (33:worker1@VM0) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [20040.000000] (32:worker0@VM0) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [21000.000000] (1:master_@Fafard) ### Test: 75% for Task1@VM0, 100% for Task2@VM0 +> [21020.000000] (35:worker1@VM0) bound to 76296000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [21020.000000] (34:worker0@VM0) bound to 57222000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [22000.000000] (1:master_@Fafard) ### Test: no bound for Task1@VM0, 25% for Task2@VM0 +> [22013.333333] (36:worker0@VM0) not bound => duration 13.333333 (57222000.000005 flops/s) +> [22040.000000] (37:worker1@VM0) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [23000.000000] (1:master_@Fafard) ### Test: 75% for Task1@VM0, 25% for Task2@VM0 +> [23013.333333] (38:worker0@VM0) bound to 57222000.000000 => duration 13.333333 (57222000.000005 flops/s) +> [23040.000000] (39:worker1@VM0) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [24000.000000] (1:master_@Fafard) +> [24000.000000] (1:master_@Fafard) # 6. Put a task on a PM and a task on a VM. +> [24000.000000] (1:master_@Fafard) ### Test: no bound for Task1@Fafard, no bound for Task2@VM0 +> [24020.000000] (40:worker0@Fafard) not bound => duration 20.000000 (38148000.000000 flops/s) +> [24020.000000] (41:worker1@VM0) not bound => duration 20.000000 (38148000.000000 flops/s) +> [25000.000000] (1:master_@Fafard) ### Test: 0 for Task1@Fafard, 0 for Task2@VM0 (i.e., unlimited) +> [25000.000000] (42:worker0@Fafard) bound == 0 means no capping (i.e., unlimited). +> [25000.000000] (43:worker1@VM0) bound == 0 means no capping (i.e., unlimited). +> [25020.000000] (42:worker0@Fafard) bound to 0.000000 => duration 20.000000 (38148000.000000 flops/s) +> [25020.000000] (43:worker1@VM0) bound to 0.000000 => duration 20.000000 (38148000.000000 flops/s) +> [26000.000000] (1:master_@Fafard) ### Test: 50% for Task1@Fafard, 50% for Task2@VM0 +> [26020.000000] (44:worker0@Fafard) bound to 38148000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [26020.000000] (45:worker1@VM0) bound to 38148000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [27000.000000] (1:master_@Fafard) ### Test: 25% for Task1@Fafard, 25% for Task2@VM0 +> [27040.000000] (46:worker0@Fafard) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [27040.000000] (47:worker1@VM0) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [28000.000000] (1:master_@Fafard) ### Test: 75% for Task1@Fafard, 100% for Task2@VM0 +> [28020.000000] (48:worker0@Fafard) bound to 57222000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [28020.000000] (49:worker1@VM0) bound to 76296000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [29000.000000] (1:master_@Fafard) ### Test: no bound for Task1@Fafard, 25% for Task2@VM0 +> [29020.000000] (50:worker0@Fafard) not bound => duration 20.000000 (38148000.000000 flops/s) +> [29040.000000] (51:worker1@VM0) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [30000.000000] (1:master_@Fafard) ### Test: 75% for Task1@Fafard, 25% for Task2@VM0 +> [30020.000000] (52:worker0@Fafard) bound to 57222000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [30040.000000] (53:worker1@VM0) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [31000.000000] (1:master_@Fafard) +> [31000.000000] (1:master_@Fafard) # 7. Put a single task on the VM capped by 10%. +> [31000.000000] (1:master_@Fafard) ### Test: with/without MSG_task_set_bound +> [31000.000000] (1:master_@Fafard) ### Test: no bound for Task1@VM0 +> [31100.000000] (54:worker0@VM0) not bound => duration 100.000000 (7629600.000000 flops/s) +> [32000.000000] (1:master_@Fafard) ### Test: 50% for Task1@VM0 +> [32100.000000] (55:worker0@VM0) bound to 38148000.000000 => duration 100.000000 (7629600.000000 flops/s) +> [33000.000000] (1:master_@Fafard) ### Test: 33% for Task1@VM0 +> [33100.000000] (56:worker0@VM0) bound to 25432000.000000 => duration 100.000000 (7629600.000000 flops/s) +> [34000.000000] (1:master_@Fafard) ### Test: zero for Task1@VM0 (i.e., unlimited) +> [34000.000000] (57:worker0@VM0) bound == 0 means no capping (i.e., unlimited). +> [34100.000000] (57:worker0@VM0) bound to 0.000000 => duration 100.000000 (7629600.000000 flops/s) +> [35000.000000] (1:master_@Fafard) ### Test: 200% for Task1@VM0 (i.e., meaningless) +> [35100.000000] (58:worker0@VM0) bound to 152592000.000000 => duration 100.000000 (7629600.000000 flops/s) +> [36000.000000] (1:master_@Fafard) +> [36000.000000] (1:master_@Fafard) # 8. Put two tasks on the VM capped by 10%. +> [36000.000000] (1:master_@Fafard) ### Test: no bound for Task1@VM0, no bound for Task2@VM0 +> [36200.000000] (60:worker1@VM0) not bound => duration 200.000000 (3814800.000000 flops/s) +> [36200.000000] (59:worker0@VM0) not bound => duration 200.000000 (3814800.000000 flops/s) +> [37000.000000] (1:master_@Fafard) ### Test: 0 for Task1@VM0, 0 for Task2@VM0 (i.e., unlimited) +> [37000.000000] (61:worker0@VM0) bound == 0 means no capping (i.e., unlimited). +> [37000.000000] (62:worker1@VM0) bound == 0 means no capping (i.e., unlimited). +> [37200.000000] (62:worker1@VM0) bound to 0.000000 => duration 200.000000 (3814800.000000 flops/s) +> [37200.000000] (61:worker0@VM0) bound to 0.000000 => duration 200.000000 (3814800.000000 flops/s) +> [38000.000000] (1:master_@Fafard) ### Test: 50% for Task1@VM0, 50% for Task2@VM0 +> [38200.000000] (64:worker1@VM0) bound to 38148000.000000 => duration 200.000000 (3814800.000000 flops/s) +> [38200.000000] (63:worker0@VM0) bound to 38148000.000000 => duration 200.000000 (3814800.000000 flops/s) +> [39000.000000] (1:master_@Fafard) ### Test: 25% for Task1@VM0, 25% for Task2@VM0 +> [39200.000000] (66:worker1@VM0) bound to 19074000.000000 => duration 200.000000 (3814800.000000 flops/s) +> [39200.000000] (65:worker0@VM0) bound to 19074000.000000 => duration 200.000000 (3814800.000000 flops/s) +> [40000.000000] (1:master_@Fafard) ### Test: 75% for Task1@VM0, 100% for Task2@VM0 +> [40200.000000] (68:worker1@VM0) bound to 76296000.000000 => duration 200.000000 (3814800.000000 flops/s) +> [40200.000000] (67:worker0@VM0) bound to 57222000.000000 => duration 200.000000 (3814800.000000 flops/s) +> [41000.000000] (1:master_@Fafard) ### Test: no bound for Task1@VM0, 25% for Task2@VM0 +> [41200.000000] (70:worker1@VM0) bound to 19074000.000000 => duration 200.000000 (3814800.000000 flops/s) +> [41200.000000] (69:worker0@VM0) not bound => duration 200.000000 (3814800.000000 flops/s) +> [42000.000000] (1:master_@Fafard) ### Test: 75% for Task1@VM0, 25% for Task2@VM0 +> [42200.000000] (72:worker1@VM0) bound to 19074000.000000 => duration 200.000000 (3814800.000000 flops/s) +> [42200.000000] (71:worker0@VM0) bound to 57222000.000000 => duration 200.000000 (3814800.000000 flops/s) +> [43000.000000] (1:master_@Fafard) +> [43000.000000] (1:master_@Fafard) # 9. Put a task on a PM and a task on the VM capped by 10%. +> [43000.000000] (1:master_@Fafard) ### Test: no bound for Task1@Fafard, no bound for Task2@VM0 +> [43011.111111] (73:worker0@Fafard) not bound => duration 11.111111 (68666400.000010 flops/s) +> [43100.000000] (74:worker1@VM0) not bound => duration 100.000000 (7629600.000000 flops/s) +> [44000.000000] (1:master_@Fafard) ### Test: 0 for Task1@Fafard, 0 for Task2@VM0 (i.e., unlimited) +> [44000.000000] (75:worker0@Fafard) bound == 0 means no capping (i.e., unlimited). +> [44000.000000] (76:worker1@VM0) bound == 0 means no capping (i.e., unlimited). +> [44011.111111] (75:worker0@Fafard) bound to 0.000000 => duration 11.111111 (68666400.000010 flops/s) +> [44100.000000] (76:worker1@VM0) bound to 0.000000 => duration 100.000000 (7629600.000000 flops/s) +> [45000.000000] (1:master_@Fafard) ### Test: 50% for Task1@Fafard, 50% for Task2@VM0 +> [45020.000000] (77:worker0@Fafard) bound to 38148000.000000 => duration 20.000000 (38148000.000000 flops/s) +> [45100.000000] (78:worker1@VM0) bound to 38148000.000000 => duration 100.000000 (7629600.000000 flops/s) +> [46000.000000] (1:master_@Fafard) ### Test: 25% for Task1@Fafard, 25% for Task2@VM0 +> [46040.000000] (79:worker0@Fafard) bound to 19074000.000000 => duration 40.000000 (19074000.000000 flops/s) +> [46100.000000] (80:worker1@VM0) bound to 19074000.000000 => duration 100.000000 (7629600.000000 flops/s) +> [47000.000000] (1:master_@Fafard) ### Test: 75% for Task1@Fafard, 100% for Task2@VM0 +> [47013.333333] (81:worker0@Fafard) bound to 57222000.000000 => duration 13.333333 (57221999.999990 flops/s) +> [47100.000000] (82:worker1@VM0) bound to 76296000.000000 => duration 100.000000 (7629600.000000 flops/s) +> [48000.000000] (1:master_@Fafard) ### Test: no bound for Task1@Fafard, 25% for Task2@VM0 +> [48011.111111] (83:worker0@Fafard) not bound => duration 11.111111 (68666400.000010 flops/s) +> [48100.000000] (84:worker1@VM0) bound to 19074000.000000 => duration 100.000000 (7629600.000000 flops/s) +> [49000.000000] (1:master_@Fafard) ### Test: 75% for Task1@Fafard, 25% for Task2@VM0 +> [49013.333333] (85:worker0@Fafard) bound to 57222000.000000 => duration 13.333333 (57221999.999990 flops/s) +> [49100.000000] (86:worker1@VM0) bound to 19074000.000000 => duration 100.000000 (7629600.000000 flops/s) +> [50000.000000] (1:master_@Fafard) +> [50000.000000] (1:master_@Fafard) # 10. Test migration +> [50000.000000] (1:master_@Fafard) # 10. (a) Put a task on a VM without any bound. +> [50010.000000] (87:worker0@VM0) not bound => duration 10.000000 (76296000.000000 flops/s) +> [51000.000000] (1:master_@Fafard) +> [51000.000000] (1:master_@Fafard) # 10. (b) set 10% bound to the VM, and then put a task on the VM. +> [51100.000000] (88:worker0@VM0) not bound => duration 100.000000 (7629600.000000 flops/s) +> [52000.000000] (1:master_@Fafard) +> [52000.000000] (1:master_@Fafard) # 10. (c) migrate +> [52000.000000] (90:__pr_mig_tx:VM0(Fafard-Fafard)@Fafard) use the default max_downtime value 30ms +> [52002.070722] (1:master_@Fafard) +> [52002.070722] (1:master_@Fafard) # 10. (d) Put a task again on the VM. +> [52102.070722] (91:worker0@VM0) not bound => duration 100.000000 (7629600.000000 flops/s) +> [53002.070722] (1:master_@Fafard) +> [53002.070722] (1:master_@Fafard) # 11. Change a bound dynamically. +> [53002.070722] (1:master_@Fafard) set bound of VM1 to 0.000000 +> [53102.070722] (1:master_@Fafard) Task0@VM0: 38148000.000000 flops/s +> [53102.070722] (1:master_@Fafard) Task1@VM1: 38148000.000000 flops/s +> [53102.070722] (1:master_@Fafard) set bound of VM1 to 7629600.000000 +> [53202.070722] (1:master_@Fafard) Task0@VM0: 68666400.000000 flops/s +> [53202.070722] (1:master_@Fafard) Task1@VM1: 7629600.000000 flops/s +> [53202.070722] (1:master_@Fafard) set bound of VM1 to 15259200.000000 +> [53302.070722] (1:master_@Fafard) Task0@VM0: 61036800.000000 flops/s +> [53302.070722] (1:master_@Fafard) Task1@VM1: 15259200.000000 flops/s +> [53302.070722] (1:master_@Fafard) set bound of VM1 to 22888800.000000 +> [53402.070722] (1:master_@Fafard) Task0@VM0: 53407200.000000 flops/s +> [53402.070722] (1:master_@Fafard) Task1@VM1: 22888800.000000 flops/s +> [53402.070722] (1:master_@Fafard) set bound of VM1 to 30518400.000000 +> [53502.070722] (1:master_@Fafard) Task0@VM0: 45777600.000000 flops/s +> [53502.070722] (1:master_@Fafard) Task1@VM1: 30518400.000000 flops/s +> [53502.070722] (1:master_@Fafard) set bound of VM1 to 38148000.000000 +> [53602.070722] (1:master_@Fafard) Task0@VM0: 38148000.000000 flops/s +> [53602.070722] (1:master_@Fafard) Task1@VM1: 38148000.000000 flops/s +> [53602.070722] (1:master_@Fafard) set bound of VM1 to 45777600.000000 +> [53702.070722] (1:master_@Fafard) Task0@VM0: 38148000.000000 flops/s +> [53702.070722] (1:master_@Fafard) Task1@VM1: 38148000.000000 flops/s +> [53702.070722] (1:master_@Fafard) set bound of VM1 to 53407200.000000 +> [53802.070722] (1:master_@Fafard) Task0@VM0: 38148000.000000 flops/s +> [53802.070722] (1:master_@Fafard) Task1@VM1: 38148000.000000 flops/s +> [53802.070722] (1:master_@Fafard) set bound of VM1 to 61036800.000000 +> [53902.070722] (1:master_@Fafard) Task0@VM0: 38148000.000000 flops/s +> [53902.070722] (1:master_@Fafard) Task1@VM1: 38148000.000000 flops/s +> [53902.070722] (1:master_@Fafard) set bound of VM1 to 68666400.000000 +> [54002.070722] (1:master_@Fafard) Task0@VM0: 38148000.000000 flops/s +> [54002.070722] (1:master_@Fafard) Task1@VM1: 38148000.000000 flops/s +> [56002.070722] (0:maestro@) Bye (simulation time 56002.1) diff --git a/examples/msg/cloud/master_worker_vm.c b/examples/msg/cloud-masterworker/cloud-masterworker.c similarity index 100% rename from examples/msg/cloud/master_worker_vm.c rename to examples/msg/cloud-masterworker/cloud-masterworker.c diff --git a/examples/msg/cloud/master_worker_vm.tesh b/examples/msg/cloud-masterworker/cloud-masterworker.tesh similarity index 97% rename from examples/msg/cloud/master_worker_vm.tesh rename to examples/msg/cloud-masterworker/cloud-masterworker.tesh index 9187794b29..d4b71a5b48 100644 --- a/examples/msg/cloud/master_worker_vm.tesh +++ b/examples/msg/cloud-masterworker/cloud-masterworker.tesh @@ -2,7 +2,7 @@ p Testing the Cloud API with a simple master/workers -$ $SG_TEST_EXENV ${bindir:=.}/master_worker_vm$EXEEXT --log=no_loc ${srcdir:=.}/../../platforms/platform.xml +$ $SG_TEST_EXENV ${bindir:=.}/cloud-masterworker$EXEEXT --log=no_loc ${srcdir:=.}/platform.xml > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] # Launch 2 VMs > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] create VM00 on PM(Intel) > [Jacquelin:master:(1) 0.000000] [msg_test/INFO] put a process (WRK00) on VM00 diff --git a/examples/msg/cloud/migrate_vm.c b/examples/msg/cloud-migration/cloud-migration.c similarity index 100% rename from examples/msg/cloud/migrate_vm.c rename to examples/msg/cloud-migration/cloud-migration.c diff --git a/examples/msg/cloud-migration/cloud-migration.tesh b/examples/msg/cloud-migration/cloud-migration.tesh new file mode 100644 index 0000000000..c66bb02e63 --- /dev/null +++ b/examples/msg/cloud-migration/cloud-migration.tesh @@ -0,0 +1,24 @@ +$ $SG_TEST_EXENV ${bindir:=.}/cloud-migration ${srcdir:=.}/small_platform.xml --log=no_loc "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +> [ 0.000000] (1:master_@Fafard) Test: Migrate a VM with 1000 Mbytes RAM +> [ 0.000000] (3:__pr_mig_tx:VM0(Fafard-Tremblay)@Fafard) use the default max_downtime value 30ms +> [132.740093] (0:maestro@) FIXME: may need a proper handling, 1 +> [132.765801] (1:master_@Fafard) VM0 migrated: Fafard->Tremblay in 132.766 s +> [132.765801] (1:master_@Fafard) Test: Migrate a VM with 100 Mbytes RAM +> [132.765801] (5:__pr_mig_tx:VM0(Fafard-Tremblay)@Fafard) use the default max_downtime value 30ms +> [146.086085] (0:maestro@) FIXME: may need a proper handling, 1 +> [146.111793] (1:master_@Fafard) VM0 migrated: Fafard->Tremblay in 13.346 s +> [146.111793] (1:master_@Fafard) Test: Migrate two VMs at once from PM0 to PM1 +> [146.111793] (9:__pr_mig_tx:VM0(Fafard-Tremblay)@Fafard) use the default max_downtime value 30ms +> [146.111793] (11:__pr_mig_tx:VM1(Fafard-Tremblay)@Fafard) use the default max_downtime value 30ms +> [411.540563] (0:maestro@) FIXME: may need a proper handling, 1 +> [411.540563] (0:maestro@) FIXME: may need a proper handling, 1 +> [411.566271] (7:mig_wrk@Fafard) VM1 migrated: Fafard->Tremblay in 265.454 s +> [411.566271] (6:mig_wrk@Fafard) VM0 migrated: Fafard->Tremblay in 265.454 s +> [10146.111793] (1:master_@Fafard) Test: Migrate two VMs at once to different PMs +> [10146.111793] (15:__pr_mig_tx:VM0(Fafard-Tremblay)@Fafard) use the default max_downtime value 30ms +> [10146.111793] (17:__pr_mig_tx:VM1(Fafard-Bourassa)@Fafard) use the default max_downtime value 30ms +> [10362.613818] (0:maestro@) FIXME: may need a proper handling, 1 +> [10362.620589] (13:mig_wrk@Fafard) VM1 migrated: Fafard->Bourassa in 216.509 s +> [10411.521626] (0:maestro@) FIXME: may need a proper handling, 1 +> [10411.547334] (12:mig_wrk@Fafard) VM0 migrated: Fafard->Tremblay in 265.436 s +> [20146.111793] (0:maestro@) Bye (simulation time 20146.1) diff --git a/examples/msg/cloud/multicore.c b/examples/msg/cloud-multicore/cloud-multicore.c similarity index 100% rename from examples/msg/cloud/multicore.c rename to examples/msg/cloud-multicore/cloud-multicore.c diff --git a/examples/msg/cloud-multicore/cloud-multicore.tesh b/examples/msg/cloud-multicore/cloud-multicore.tesh new file mode 100644 index 0000000000..ae23645e46 --- /dev/null +++ b/examples/msg/cloud-multicore/cloud-multicore.tesh @@ -0,0 +1,14 @@ +#! ./tesh + +$ $SG_TEST_EXENV ${bindir:=.}/cloud-multicore$EXEEXT --log=no_loc ${srcdir:=.}/three_multicore_hosts.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +> [ 0.000000] (0:maestro@) PM0: 1 core(s), 100000000.000000 flops/s per each +> [ 0.000000] (0:maestro@) PM1: 2 core(s), 100000000.000000 flops/s per each +> [ 0.000000] (0:maestro@) PM2: 4 core(s), 100000000.000000 flops/s per each +> [ 0.000000] (1:master@PM0) === Test PM (set affinity) === +> [ 0.000000] (1:master@PM0) ## 1. start 4 tasks on PM1 (2 cores) +> [ 10.000000] (1:master@PM0) Task1: 50000000.000000 fops/s +> [ 10.000000] (1:master@PM0) Task2: 50000000.000000 fops/s +> [ 10.000000] (1:master@PM0) Task3: 50000000.000000 fops/s +> [ 10.000000] (1:master@PM0) Task4: 50000000.000000 fops/s +> [ 10.000000] (1:master@PM0) ## 2. pin all tasks to CPU0 +> [ 10.000000] (1:master@PM0) set affinity(0x0001@PM1) for Task1 diff --git a/examples/msg/cloud/CMakeLists.txt b/examples/msg/cloud/CMakeLists.txt index 9e15831b07..bf9d37bbd5 100644 --- a/examples/msg/cloud/CMakeLists.txt +++ b/examples/msg/cloud/CMakeLists.txt @@ -1,15 +1,12 @@ -foreach (example master_worker_vm simple_vm migrate_vm bound scale multicore two_tasks_vm) +foreach (example simple_vm scale two_tasks_vm) add_executable (${example} ${example}.c) target_link_libraries(${example} simgrid) set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${example}.c) endforeach() -ADD_TESH_FACTORIES(msg-cloud-master-worker-vm "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/cloud/ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/ --cd ${CMAKE_BINARY_DIR}/examples/msg/cloud/ ${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/master_worker_vm.tesh) ADD_TESH_FACTORIES(msg-cloud-two-tasks-vm "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/cloud/ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/ --cd ${CMAKE_BINARY_DIR}/examples/msg/cloud/ ${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/two_tasks_vm.tesh) ADD_TESH_FACTORIES(msg-cloud-simple-vm "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/cloud/ --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/ --cd ${CMAKE_BINARY_DIR}/examples/msg/cloud/ ${CMAKE_HOME_DIRECTORY}/examples/msg/cloud/simple_vm.tesh) set(examples_src ${examples_src} PARENT_SCOPE) -set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/master_worker_vm.tesh - ${CMAKE_CURRENT_SOURCE_DIR}/two_tasks_vm.tesh +set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/two_tasks_vm.tesh ${CMAKE_CURRENT_SOURCE_DIR}/simple_vm.tesh PARENT_SCOPE) -set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/multicore_plat.xml PARENT_SCOPE) diff --git a/examples/msg/cloud/multicore_plat.xml b/examples/platforms/three_multicore_hosts.xml similarity index 65% rename from examples/msg/cloud/multicore_plat.xml rename to examples/platforms/three_multicore_hosts.xml index 23e705132e..7372bf946f 100644 --- a/examples/msg/cloud/multicore_plat.xml +++ b/examples/platforms/three_multicore_hosts.xml @@ -2,11 +2,11 @@ - - - + + + - + diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 4c0fd124f1..c3e5db0bc4 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -393,8 +393,7 @@ void SIMIX_execution_set_affinity(smx_synchro_t synchro, sg_host_t host, unsigne if (synchro->execution.surf_exec) { /* just a double check to confirm that this host is the host where this task is running. */ xbt_assert(synchro->execution.host == host); - static_cast(synchro->execution.surf_exec) - ->setAffinity(host->pimpl_cpu, mask); + static_cast(synchro->execution.surf_exec)->setAffinity(host->pimpl_cpu, mask); } } diff --git a/src/surf/maxmin.cpp b/src/surf/maxmin.cpp index e40a1ab08a..0598653c25 100644 --- a/src/surf/maxmin.cpp +++ b/src/surf/maxmin.cpp @@ -13,8 +13,7 @@ #include #include /* sprintf */ #include -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_maxmin, surf, - "Logging specific to SURF (maxmin)"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_maxmin, surf, "Logging specific to SURF (maxmin)"); typedef struct s_dyn_light { int *data; @@ -28,15 +27,13 @@ double sg_surf_precision = 0.00001; static void *lmm_variable_mallocator_new_f(void); static void lmm_variable_mallocator_free_f(void *var); #define lmm_variable_mallocator_reset_f ((void_f_pvoid_t)NULL) -static void lmm_update_modified_set(lmm_system_t sys, - lmm_constraint_t cnst); +static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst); static void lmm_remove_all_modified_set(lmm_system_t sys); static int Global_debug_id = 1; static int Global_const_debug_id = 1; static void lmm_var_free(lmm_system_t sys, lmm_variable_t var); -static inline void lmm_cnst_free(lmm_system_t sys, - lmm_constraint_t cnst); +static inline void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst); static void lmm_on_disabled_var(lmm_system_t sys, lmm_constraint_t cnstr); static void lmm_enable_var(lmm_system_t sys, lmm_variable_t var); @@ -64,15 +61,15 @@ inline void lmm_decrease_concurrency(lmm_element_t elem) { } inline void lmm_increase_concurrency(lmm_element_t elem) { - elem->constraint->concurrency_current+= lmm_element_concurrency(elem); lmm_constraint_t cnstr=elem->constraint; - + if(cnstr->concurrency_current > cnstr->concurrency_maximum) cnstr->concurrency_maximum= cnstr->concurrency_current; - xbt_assert(cnstr->concurrency_limit<0 || cnstr->concurrency_current<=cnstr->concurrency_limit,"Concurrency limit overflow!"); + xbt_assert(cnstr->concurrency_limit<0 || cnstr->concurrency_current<=cnstr->concurrency_limit, + "Concurrency limit overflow!"); } lmm_system_t lmm_system_new(int selective_update) @@ -87,23 +84,16 @@ lmm_system_t lmm_system_new(int selective_update) l->selective_update_active = selective_update; l->visited_counter = 1; - XBT_DEBUG("Setting selective_update_active flag to %d", - l->selective_update_active); + XBT_DEBUG("Setting selective_update_active flag to %d", l->selective_update_active); - xbt_swag_init(&(l->variable_set), - xbt_swag_offset(var, variable_set_hookup)); - xbt_swag_init(&(l->constraint_set), - xbt_swag_offset(cnst, constraint_set_hookup)); + xbt_swag_init(&(l->variable_set), xbt_swag_offset(var, variable_set_hookup)); + xbt_swag_init(&(l->constraint_set), xbt_swag_offset(cnst, constraint_set_hookup)); - xbt_swag_init(&(l->active_constraint_set), - xbt_swag_offset(cnst, active_constraint_set_hookup)); + xbt_swag_init(&(l->active_constraint_set), xbt_swag_offset(cnst, active_constraint_set_hookup)); - xbt_swag_init(&(l->modified_constraint_set), - xbt_swag_offset(cnst, modified_constraint_set_hookup)); - xbt_swag_init(&(l->saturated_variable_set), - xbt_swag_offset(var, saturated_variable_set_hookup)); - xbt_swag_init(&(l->saturated_constraint_set), - xbt_swag_offset(cnst, saturated_constraint_set_hookup)); + xbt_swag_init(&(l->modified_constraint_set), xbt_swag_offset(cnst, modified_constraint_set_hookup)); + xbt_swag_init(&(l->saturated_variable_set), xbt_swag_offset(var, saturated_variable_set_hookup)); + xbt_swag_init(&(l->saturated_constraint_set), xbt_swag_offset(cnst, saturated_constraint_set_hookup)); l->variable_mallocator = xbt_mallocator_new(65536, lmm_variable_mallocator_new_f, @@ -136,15 +126,16 @@ static inline void lmm_variable_remove(lmm_system_t sys, lmm_variable_t var) { int i; int nelements; - + lmm_element_t elem = NULL; - + XBT_IN("(sys=%p, var=%p)", sys, var); sys->modified = 1; - //TODOLATER Can do better than that by leaving only the variable in only one enabled_element_set, call lmm_update_modified_set, and then remove it.. + //TODOLATER Can do better than that by leaving only the variable in only one enabled_element_set, call + //lmm_update_modified_set, and then remove it.. if(var->cnsts_number) - lmm_update_modified_set(sys, var->cnsts[0].constraint); + lmm_update_modified_set(sys, var->cnsts[0].constraint); for (i = 0; i < var->cnsts_number; i++) { elem = &var->cnsts[i]; @@ -160,39 +151,35 @@ static inline void lmm_variable_remove(lmm_system_t sys, lmm_variable_t var) else lmm_on_disabled_var(sys,elem->constraint); } - + //Check if we can enable new variables going through the constraints where var was. - //Do it after removing all elements, so he first disabled variables get priority over those with smaller - //requirement + //Do it after removing all elements, so he first disabled variables get priority over those with smaller requirement for (i = 0; i < var->cnsts_number; i++) { elem = &var->cnsts[i]; if(xbt_swag_size(&(elem->constraint->disabled_element_set))) - lmm_on_disabled_var(sys,elem->constraint); + lmm_on_disabled_var(sys,elem->constraint); } - + var->cnsts_number = 0; lmm_check_concurrency(sys); - + XBT_OUT(); } static void lmm_var_free(lmm_system_t sys, lmm_variable_t var) { - lmm_variable_remove(sys, var); xbt_mallocator_release(sys->variable_mallocator, var); } -static inline void lmm_cnst_free(lmm_system_t sys, - lmm_constraint_t cnst) +static inline void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst) { make_constraint_inactive(sys, cnst); free(cnst); } -lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id, - double bound_value) +lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id, double bound_value) { lmm_constraint_t cnst = NULL; s_lmm_element_t elem; @@ -200,12 +187,9 @@ lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id, cnst = xbt_new0(s_lmm_constraint_t, 1); cnst->id = id; cnst->id_int = Global_const_debug_id++; - xbt_swag_init(&(cnst->enabled_element_set), - xbt_swag_offset(elem, enabled_element_set_hookup)); - xbt_swag_init(&(cnst->disabled_element_set), - xbt_swag_offset(elem, disabled_element_set_hookup)); - xbt_swag_init(&(cnst->active_element_set), - xbt_swag_offset(elem, active_element_set_hookup)); + xbt_swag_init(&(cnst->enabled_element_set), xbt_swag_offset(elem, enabled_element_set_hookup)); + xbt_swag_init(&(cnst->disabled_element_set), xbt_swag_offset(elem, disabled_element_set_hookup)); + xbt_swag_init(&(cnst->active_element_set), xbt_swag_offset(elem, active_element_set_hookup)); cnst->bound = bound_value; cnst->concurrency_maximum=0; @@ -226,7 +210,9 @@ int lmm_constraint_concurrency_limit_get(lmm_constraint_t cnst) void lmm_constraint_concurrency_limit_set(lmm_constraint_t cnst, int concurrency_limit) { - xbt_assert(concurrency_limit<0 || cnst->concurrency_maximum<=concurrency_limit,"New concurrency limit should be larger than observed concurrency maximum. Maybe you want to call lmm_constraint_concurrency_maximum_reset() to reset the maximum?"); + xbt_assert(concurrency_limit<0 || cnst->concurrency_maximum<=concurrency_limit, + "New concurrency limit should be larger than observed concurrency maximum. Maybe you want to call" + " lmm_constraint_concurrency_maximum_reset() to reset the maximum?"); cnst->concurrency_limit = concurrency_limit; } @@ -237,7 +223,8 @@ void lmm_constraint_concurrency_maximum_reset(lmm_constraint_t cnst) int lmm_constraint_concurrency_maximum_get(lmm_constraint_t cnst) { - xbt_assert(cnst->concurrency_limit<0 || cnst->concurrency_maximum<=cnst->concurrency_limit,"Very bad: maximum observed concurrency is higher than limit. This is a bug of SURF, please report it."); + xbt_assert(cnst->concurrency_limit<0 || cnst->concurrency_maximum<=cnst->concurrency_limit, + "Very bad: maximum observed concurrency is higher than limit. This is a bug of SURF, please report it."); return cnst->concurrency_maximum; } @@ -255,10 +242,9 @@ int lmm_constraint_sharing_policy(lmm_constraint_t cnst) /* @brief Remove a constraint * Currently this is dead code, but it is exposed in maxmin.h * Apparently, this call was designed assuming that constraint would no more have elements in it. - * If this is not the case, assertion will fail, and you need to add calls e.g. to lmm_shrink before effectively removing it. + * If not the case, assertion will fail, and you need to add calls e.g. to lmm_shrink before effectively removing it. */ -inline void lmm_constraint_free(lmm_system_t sys, - lmm_constraint_t cnst) +inline void lmm_constraint_free(lmm_system_t sys,lmm_constraint_t cnst) { xbt_assert(!xbt_swag_size(&(cnst->active_element_set)),"Removing constraint but it still has active elements"); xbt_assert(!xbt_swag_size(&(cnst->enabled_element_set)),"Removing constraint but it still has enabled elements"); @@ -280,15 +266,12 @@ static void lmm_variable_mallocator_free_f(void *var) xbt_free(var); } -lmm_variable_t lmm_variable_new(lmm_system_t sys, void *id, - double weight, - double bound, int number_of_constraints) +lmm_variable_t lmm_variable_new(lmm_system_t sys, void *id, double weight, double bound, int number_of_constraints) { lmm_variable_t var = NULL; int i; - XBT_IN("(sys=%p, id=%p, weight=%f, bound=%f, num_cons =%d)", - sys, id, weight, bound, number_of_constraints); + XBT_IN("(sys=%p, id=%p, weight=%f, bound=%f, num_cons =%d)", sys, id, weight, bound, number_of_constraints); var = (lmm_variable_t) xbt_mallocator_get(sys->variable_mallocator); var->id = id; @@ -344,7 +327,6 @@ double lmm_variable_getvalue(lmm_variable_t var) return (var->value); } - void lmm_variable_concurrency_share_set(lmm_variable_t var, short int concurrency_share) { var->concurrency_share=concurrency_share; @@ -355,8 +337,7 @@ double lmm_variable_getbound(lmm_variable_t var) return (var->bound); } -void lmm_shrink(lmm_system_t sys, lmm_constraint_t cnst, - lmm_variable_t var) +void lmm_shrink(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var) { lmm_element_t elem = NULL; int found = 0; @@ -377,15 +358,16 @@ void lmm_shrink(lmm_system_t sys, lmm_constraint_t cnst, sys->modified = 1; - XBT_DEBUG("remove elem(value %f, cnst %p, var %p) in var %p", - elem->value, elem->constraint, elem->variable, var); + XBT_DEBUG("remove elem(value %f, cnst %p, var %p) in var %p", elem->value, elem->constraint, elem->variable, var); /* We are going to change the constraint object and the variable object. - * Propagate this change to other objects. Calling here before removing variable from not active elements (inactive elements are not visited) + * Propagate this change to other objects. Calling here before removing variable from not active elements + * (inactive elements are not visited) */ lmm_update_modified_set(sys, cnst); //Useful in case var was already removed from the constraint - lmm_update_modified_set(sys, var->cnsts[0].constraint); // will look up enabled_element_set of this constraint, and then each var in the enabled_element_set, and each var->cnsts[i]. + lmm_update_modified_set(sys, var->cnsts[0].constraint); // will look up enabled_element_set of this constraint, and + //then each var in the enabled_element_set, and each var->cnsts[i]. if(xbt_swag_remove(elem, &(elem->constraint->enabled_element_set))) lmm_decrease_concurrency(elem); @@ -408,14 +390,12 @@ void lmm_shrink(lmm_system_t sys, lmm_constraint_t cnst, lmm_check_concurrency(sys); } -void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, - lmm_variable_t var, double value) +void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value) { lmm_element_t elem = NULL; double weight; int i,current_share; - - + sys->modified = 1; //Check if this variable already has an active element in this constraint @@ -423,14 +403,14 @@ void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, current_share=0; if(var->concurrency_share>1){ for( i=0; icnsts_number;i++){ - if(var->cnsts[i].constraint==cnst && xbt_swag_belongs(&var->cnsts[i],&(var->cnsts[i].constraint->enabled_element_set))) - current_share+=lmm_element_concurrency(&(var->cnsts[i])); + if(var->cnsts[i].constraint==cnst && + xbt_swag_belongs(&var->cnsts[i],&(var->cnsts[i].constraint->enabled_element_set))) + current_share+=lmm_element_concurrency(&(var->cnsts[i])); } } //Check if we need to disable the variable - if(var->weight>0 && var->concurrency_share-current_share>lmm_concurrency_slack(cnst)) - { + if(var->weight>0 && var->concurrency_share-current_share>lmm_concurrency_slack(cnst)) { weight=var->weight; lmm_disable_var(sys,var); for (i = 0; i < var->cnsts_number; i++) @@ -448,12 +428,10 @@ void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, elem->constraint = cnst; elem->variable = var; - if (var->weight){ xbt_swag_insert_at_head(elem, &(elem->constraint->enabled_element_set)); lmm_increase_concurrency(elem); - } - else + } else xbt_swag_insert_at_tail(elem, &(elem->constraint->disabled_element_set)); if(!sys->selective_update_active) { @@ -469,17 +447,15 @@ void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_check_concurrency(sys); } -void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, - lmm_variable_t var, double value) +void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value) { int i,j; double weight; sys->modified = 1; - + lmm_check_concurrency(sys); - //BEWARE: In case you have multiple elements in one constraint, this will always - //add value to the first element. + //BEWARE: In case you have multiple elements in one constraint, this will always add value to the first element. for (i = 0; i < var->cnsts_number; i++) if (var->cnsts[i].constraint == cnst) break; @@ -496,16 +472,15 @@ void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, //We need to check that increasing value of the element does not cross the concurrency limit if (var->weight){ if(lmm_concurrency_slack(cnst)cnsts[i])){ - weight=var->weight; - lmm_disable_var(sys,var); - for (j = 0; j < var->cnsts_number; j++) - lmm_on_disabled_var(sys,var->cnsts[j].constraint); - var->staged_weight=weight; - xbt_assert(!var->weight); + weight=var->weight; + lmm_disable_var(sys,var); + for (j = 0; j < var->cnsts_number; j++) + lmm_on_disabled_var(sys,var->cnsts[j].constraint); + var->staged_weight=weight; + xbt_assert(!var->weight); } lmm_increase_concurrency(&var->cnsts[i]); } - lmm_update_modified_set(sys, cnst); } else lmm_expand(sys, cnst, var, value); @@ -513,9 +488,7 @@ void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_check_concurrency(sys); } -lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t /*sys*/, - lmm_variable_t var, - int num) +lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t /*sys*/, lmm_variable_t var, int num) { if (num < var->cnsts_number) return (var->cnsts[num].constraint); @@ -523,9 +496,7 @@ lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t /*sys*/, return NULL; } -double lmm_get_cnst_weight_from_var(lmm_system_t /*sys*/, - lmm_variable_t var, - int num) +double lmm_get_cnst_weight_from_var(lmm_system_t /*sys*/, lmm_variable_t var, int num) { if (num < var->cnsts_number) return (var->cnsts[num].value); @@ -533,29 +504,26 @@ double lmm_get_cnst_weight_from_var(lmm_system_t /*sys*/, return 0.0; } -int lmm_get_number_of_cnst_from_var(lmm_system_t /*sys*/, - lmm_variable_t var) +int lmm_get_number_of_cnst_from_var(lmm_system_t /*sys*/, lmm_variable_t var) { return (var->cnsts_number); } -lmm_variable_t lmm_get_var_from_cnst(lmm_system_t /*sys*/, - lmm_constraint_t cnst, - lmm_element_t * elem) +lmm_variable_t lmm_get_var_from_cnst(lmm_system_t /*sys*/, lmm_constraint_t cnst, lmm_element_t * elem) { - if (!(*elem)) { - //That is the first call, pick the first element among enabled_element_set (or disabled_element_set if enabled_element_set is empty) + // That is the first call, pick the first element among enabled_element_set (or disabled_element_set if + // enabled_element_set is empty) *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->enabled_element_set)); if (!(*elem)) *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set)); - } else { + } else { //elem is not null, so we carry on if(xbt_swag_belongs(*elem,&(cnst->enabled_element_set))){ //Look at enabled_element_set, and jump to disabled_element_set when finished *elem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->enabled_element_set.offset); if (!(*elem)) - *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set)); + *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set)); } else { *elem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->disabled_element_set.offset); } @@ -568,11 +536,8 @@ lmm_variable_t lmm_get_var_from_cnst(lmm_system_t /*sys*/, //if we modify the swag between calls, normal version may loop forever //this safe version ensures that we browse the swag elements only once -lmm_variable_t lmm_get_var_from_cnst_safe(lmm_system_t /*sys*/, - lmm_constraint_t cnst, - lmm_element_t * elem, - lmm_element_t * nextelem, - int * numelem) +lmm_variable_t lmm_get_var_from_cnst_safe(lmm_system_t /*sys*/, lmm_constraint_t cnst, lmm_element_t * elem, + lmm_element_t * nextelem, int * numelem) { if (!(*elem)){ *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->enabled_element_set)); @@ -592,7 +557,7 @@ lmm_variable_t lmm_get_var_from_cnst_safe(lmm_system_t /*sys*/, //Look at enabled_element_set, and jump to disabled_element_set when finished *nextelem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->enabled_element_set.offset); if (!(*nextelem)) - *nextelem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set)); + *nextelem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set)); } else { *nextelem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->disabled_element_set.offset); } @@ -611,10 +576,8 @@ void *lmm_variable_id(lmm_variable_t var) return var->id; } -static inline void saturated_constraint_set_update(double usage, - int cnst_light_num, - dyn_light_t saturated_constraint_set, - double *min_usage) +static inline void saturated_constraint_set_update(double usage, int cnst_light_num, + dyn_light_t saturated_constraint_set, double *min_usage) { xbt_assert(usage > 0,"Impossible"); @@ -626,17 +589,16 @@ static inline void saturated_constraint_set_update(double usage, } else if (*min_usage == usage) { if(saturated_constraint_set->pos == saturated_constraint_set->size) { // realloc the size saturated_constraint_set->size *= 2; - saturated_constraint_set->data = (int*) xbt_realloc(saturated_constraint_set->data, (saturated_constraint_set->size) * sizeof(int)); + saturated_constraint_set->data = + (int*) xbt_realloc(saturated_constraint_set->data, (saturated_constraint_set->size) * sizeof(int)); } saturated_constraint_set->data[saturated_constraint_set->pos] = cnst_light_num; saturated_constraint_set->pos++; } } -static inline void saturated_variable_set_update( - s_lmm_constraint_light_t *cnst_light_tab, - dyn_light_t saturated_constraint_set, - lmm_system_t sys) +static inline void saturated_variable_set_update(s_lmm_constraint_light_t *cnst_light_tab, + dyn_light_t saturated_constraint_set, lmm_system_t sys) { /* Add active variables (i.e. variables that need to be set) from the set of constraints to saturate (cnst_light_tab)*/ lmm_constraint_light_t cnst = NULL; @@ -673,19 +635,16 @@ void lmm_print(lmm_system_t sys) /* Printing Objective */ var_list = &(sys->variable_set); sprintf(print_buf, "MAX-MIN ( "); - trace_buf = (char*) - xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); + trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); strcat(trace_buf, print_buf); xbt_swag_foreach(_var, var_list) { var = (lmm_variable_t)_var; sprintf(print_buf, "'%d'(%f) ", var->id_int, var->weight); - trace_buf = (char*) - xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); + trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); strcat(trace_buf, print_buf); } sprintf(print_buf, ")"); - trace_buf = (char*) - xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); + trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); strcat(trace_buf, print_buf); XBT_DEBUG("%20s", trace_buf); trace_buf[0] = '\000'; @@ -699,21 +658,16 @@ void lmm_print(lmm_system_t sys) //Show the enabled variables elem_list = &(cnst->enabled_element_set); sprintf(print_buf, "\t"); - trace_buf = (char*) - xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); + trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); strcat(trace_buf, print_buf); sprintf(print_buf, "%s(",(cnst->sharing_policy)?"":"max"); - trace_buf = (char*) - xbt_realloc(trace_buf, - strlen(trace_buf) + strlen(print_buf) + 1); - strcat(trace_buf, print_buf); + trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); + strcat(trace_buf, print_buf); xbt_swag_foreach(_elem, elem_list) { elem = (lmm_element_t)_elem; sprintf(print_buf, "%f.'%d'(%f) %s ", elem->value, elem->variable->id_int, elem->variable->value,(cnst->sharing_policy)?"+":","); - trace_buf = (char*) - xbt_realloc(trace_buf, - strlen(trace_buf) + strlen(print_buf) + 1); + trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); strcat(trace_buf, print_buf); if(cnst->sharing_policy) sum += elem->value * elem->variable->value; @@ -726,36 +680,29 @@ void lmm_print(lmm_system_t sys) elem = (lmm_element_t)_elem; sprintf(print_buf, "%f.'%d'(%f) %s ", elem->value, elem->variable->id_int, elem->variable->value,(cnst->sharing_policy)?"+":","); - trace_buf = (char*) - xbt_realloc(trace_buf, - strlen(trace_buf) + strlen(print_buf) + 1); + trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); strcat(trace_buf, print_buf); if(cnst->sharing_policy) sum += elem->value * elem->variable->value; else sum = MAX(sum,elem->value * elem->variable->value); } - + sprintf(print_buf, "0) <= %f ('%d')", cnst->bound, cnst->id_int); - trace_buf = (char*) - xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); + trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); strcat(trace_buf, print_buf); if (!cnst->sharing_policy) { sprintf(print_buf, " [MAX-Constraint]"); - trace_buf = (char*) - xbt_realloc(trace_buf, - strlen(trace_buf) + strlen(print_buf) + 1); + trace_buf = (char*) xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1); strcat(trace_buf, print_buf); } XBT_DEBUG("%s", trace_buf); trace_buf[0] = '\000'; xbt_assert(!double_positive(sum - cnst->bound, cnst->bound*sg_maxmin_precision), - "Incorrect value (%f is not smaller than %f): %g", - sum, cnst->bound, sum - cnst->bound); + "Incorrect value (%f is not smaller than %f): %g", sum, cnst->bound, sum - cnst->bound); //if(double_positive(sum - cnst->bound, cnst->bound*sg_maxmin_precision)) //XBT_ERROR("Incorrect value (%f is not smaller than %f): %g",sum, cnst->bound, sum - cnst->bound); - } XBT_DEBUG("Variables"); @@ -763,11 +710,9 @@ void lmm_print(lmm_system_t sys) xbt_swag_foreach(_var, var_list) { var = (lmm_variable_t)_var; if (var->bound > 0) { - XBT_DEBUG("'%d'(%f) : %f (<=%f)", var->id_int, var->weight, var->value, - var->bound); + XBT_DEBUG("'%d'(%f) : %f (<=%f)", var->id_int, var->weight, var->value, var->bound); xbt_assert(!double_positive(var->value - var->bound, var->bound*sg_maxmin_precision), - "Incorrect value (%f is not smaller than %f", - var->value, var->bound); + "Incorrect value (%f is not smaller than %f", var->value, var->bound); } else { XBT_DEBUG("'%d'(%f) : %f", var->id_int, var->weight, var->value); } @@ -793,13 +738,10 @@ void lmm_solve(lmm_system_t sys) XBT_IN("(sys=%p)", sys); - /* - * Compute Usage and store the variables that reach the maximum. If selective_update_active is true, only constraints that changed are considered. Otherwise all constraints with active actions are considered. + /* Compute Usage and store the variables that reach the maximum. If selective_update_active is true, only constraints + * that changed are considered. Otherwise all constraints with active actions are considered. */ - cnst_list = - sys-> - selective_update_active ? &(sys->modified_constraint_set) : - &(sys->active_constraint_set); + cnst_list = sys->selective_update_active ? &(sys->modified_constraint_set) : &(sys->active_constraint_set); XBT_DEBUG("Active constraints : %d", xbt_swag_size(cnst_list)); /* Init: Only modified code portions: reset the value of active variables */ @@ -814,7 +756,8 @@ void lmm_solve(lmm_system_t sys) } } - s_lmm_constraint_light_t *cnst_light_tab = (s_lmm_constraint_light_t *)xbt_malloc0(xbt_swag_size(cnst_list)*sizeof(s_lmm_constraint_light_t)); + s_lmm_constraint_light_t *cnst_light_tab = + (s_lmm_constraint_light_t *)xbt_malloc0(xbt_swag_size(cnst_list)*sizeof(s_lmm_constraint_light_t)); int cnst_light_num = 0; dyn_light_t saturated_constraint_set = xbt_new0(s_dyn_light_t,1); saturated_constraint_set->size = 5; @@ -822,7 +765,8 @@ void lmm_solve(lmm_system_t sys) xbt_swag_foreach_safe(_cnst, _cnst_next, cnst_list) { cnst = (lmm_constraint_t)_cnst; - /* INIT: Collect constraints that actually need to be saturated (i.e remaining and usage are strictly positive) into cnst_light_tab. */ + /* INIT: Collect constraints that actually need to be saturated (i.e remaining and usage are strictly positive) + * into cnst_light_tab. */ cnst->remaining = cnst->bound; if (!double_positive(cnst->remaining, cnst->bound*sg_maxmin_precision)) continue; @@ -843,7 +787,8 @@ void lmm_solve(lmm_system_t sys) sys->keep_track->push_back(*action); } } - XBT_DEBUG("Constraint '%d' usage: %f remaining: %f concurrency: %i<=%i<=%i", cnst->id_int, cnst->usage, cnst->remaining,cnst->concurrency_current,cnst->concurrency_maximum,cnst->concurrency_limit); + XBT_DEBUG("Constraint '%d' usage: %f remaining: %f concurrency: %i<=%i<=%i", cnst->id_int, cnst->usage, + cnst->remaining,cnst->concurrency_current,cnst->concurrency_maximum,cnst->concurrency_limit); /* Saturated constraints update */ if(cnst->usage > 0) { @@ -852,17 +797,14 @@ void lmm_solve(lmm_system_t sys) cnst_light_tab[cnst_light_num].remaining_over_usage = cnst->remaining / cnst->usage; saturated_constraint_set_update(cnst_light_tab[cnst_light_num].remaining_over_usage, cnst_light_num, saturated_constraint_set, &min_usage); - xbt_assert(cnst->active_element_set.count>0, "There is no sense adding a constraint that has no active element!" ); + xbt_assert(cnst->active_element_set.count>0, "There is no sense adding a constraint that has no active element!"); cnst_light_num++; } } - saturated_variable_set_update( cnst_light_tab, - saturated_constraint_set, - sys); + saturated_variable_set_update( cnst_light_tab, saturated_constraint_set, sys); /* Saturated variables update */ - do { /* Fix the variables that have to be */ var_list = &(sys->saturated_variable_set); @@ -871,12 +813,10 @@ void lmm_solve(lmm_system_t sys) var = (lmm_variable_t)_var; if (var->weight <= 0.0) DIE_IMPOSSIBLE; - /* First check if some of these variables could reach their upper - bound and update min_bound accordingly. */ + /* First check if some of these variables could reach their upper bound and update min_bound accordingly. */ XBT_DEBUG ("var=%d, var->bound=%f, var->weight=%f, min_usage=%f, var->bound*var->weight=%f", - var->id_int, var->bound, var->weight, min_usage, - var->bound * var->weight); + var->id_int, var->bound, var->weight, min_usage, var->bound * var->weight); if ((var->bound > 0) && (var->bound * var->weight < min_usage)) { if (min_bound < 0) min_bound = var->bound*var->weight; @@ -886,48 +826,48 @@ void lmm_solve(lmm_system_t sys) } } - while ((var = (lmm_variable_t)xbt_swag_getFirst(var_list))) { int i; if (min_bound < 0) { - //If no variable could reach its bound, deal iteratively the constraints usage ( at worst one constraint is saturated at each cycle) + //If no variable could reach its bound, deal iteratively the constraints usage ( at worst one constraint is + // saturated at each cycle) var->value = min_usage / var->weight; - // XBT_DEBUG("Setting %p (%d) value to %f\n", var, var->id_int, var->value); + // XBT_DEBUG("Setting %p (%d) value to %f\n", var, var->id_int, var->value); XBT_DEBUG("Setting var (%d) value to %f\n", var->id_int, var->value); } else { - //If there exist a variable that can reach its bound, only update it (and other with the same bound) for now. - if (double_equals(min_bound, var->bound*var->weight, sg_maxmin_precision)){ - var->value = var->bound; - XBT_DEBUG("Setting %p (%d) value to %f\n", var, var->id_int, var->value); - } - else { - // Variables which bound is different are not considered for this cycle, but they will be afterwards. - XBT_DEBUG("Do not consider %p (%d) \n", var, var->id_int); - xbt_swag_remove(var, var_list); - continue; - } + //If there exist a variable that can reach its bound, only update it (and other with the same bound) for now. + if (double_equals(min_bound, var->bound*var->weight, sg_maxmin_precision)){ + var->value = var->bound; + XBT_DEBUG("Setting %p (%d) value to %f\n", var, var->id_int, var->value); + } else { + // Variables which bound is different are not considered for this cycle, but they will be afterwards. + XBT_DEBUG("Do not consider %p (%d) \n", var, var->id_int); + xbt_swag_remove(var, var_list); + continue; + } } XBT_DEBUG("Min usage: %f, Var(%d)->weight: %f, Var(%d)->value: %f ", - min_usage, var->id_int, var->weight, var->id_int, var->value); - + min_usage, var->id_int, var->weight, var->id_int, var->value); /* Update the usage of contraints where this variable is involved */ for (i = 0; i < var->cnsts_number; i++) { elem = &var->cnsts[i]; cnst = elem->constraint; if (cnst->sharing_policy) { - //Remember: shared constraints require that sum(elem->value * var->value) < cnst->bound + //Remember: shared constraints require that sum(elem->value * var->value) < cnst->bound double_update(&(cnst->remaining), elem->value * var->value, cnst->bound*sg_maxmin_precision); double_update(&(cnst->usage), elem->value / var->weight, sg_maxmin_precision); - //If the constraint is saturated, remove it from the set of active constraints (light_tab) - if(!double_positive(cnst->usage,sg_maxmin_precision) || !double_positive(cnst->remaining,cnst->bound*sg_maxmin_precision)) { + //If the constraint is saturated, remove it from the set of active constraints (light_tab) + if(!double_positive(cnst->usage,sg_maxmin_precision) || + !double_positive(cnst->remaining,cnst->bound*sg_maxmin_precision)) { if (cnst->cnst_light) { int index = (cnst->cnst_light-cnst_light_tab); XBT_DEBUG("index: %d \t cnst_light_num: %d \t || usage: %f remaining: %f bound: %f ", - index,cnst_light_num, cnst->usage, cnst->remaining, cnst->bound); - // XBT_DEBUG("index: %d \t cnst_light_num: %d \t || \t cnst: %p \t cnst->cnst_light: %p \t cnst_light_tab: %p usage: %f remaining: %f bound: %f ", - //index,cnst_light_num, cnst, cnst->cnst_light, cnst_light_tab, cnst->usage, cnst->remaining, cnst->bound); + index,cnst_light_num, cnst->usage, cnst->remaining, cnst->bound); + //XBT_DEBUG("index: %d \t cnst_light_num: %d \t || \t cnst: %p \t cnst->cnst_light: %p " + // "\t cnst_light_tab: %p usage: %f remaining: %f bound: %f ", index,cnst_light_num, + // cnst, cnst->cnst_light, cnst_light_tab, cnst->usage, cnst->remaining, cnst->bound); cnst_light_tab[index]=cnst_light_tab[cnst_light_num-1]; cnst_light_tab[index].cnst->cnst_light = &cnst_light_tab[index]; cnst_light_num--; @@ -938,23 +878,25 @@ void lmm_solve(lmm_system_t sys) } make_elem_inactive(elem); } else { - //Remember: non-shared constraints only require that max(elem->value * var->value) < cnst->bound + //Remember: non-shared constraints only require that max(elem->value * var->value) < cnst->bound cnst->usage = 0.0; make_elem_inactive(elem); elem_list = &(cnst->enabled_element_set); xbt_swag_foreach(_elem, elem_list) { - elem = (lmm_element_t)_elem; - xbt_assert(elem->variable->weight > 0); - if (elem->variable->value > 0) continue; - if (elem->value > 0) - cnst->usage = MAX(cnst->usage, elem->value / elem->variable->weight); + elem = (lmm_element_t)_elem; + xbt_assert(elem->variable->weight > 0); + if (elem->variable->value > 0) continue; + if (elem->value > 0) + cnst->usage = MAX(cnst->usage, elem->value / elem->variable->weight); } - //If the constraint is saturated, remove it from the set of active constraints (light_tab) - if(!double_positive(cnst->usage,sg_maxmin_precision) || !double_positive(cnst->remaining,cnst->bound*sg_maxmin_precision)) { + //If the constraint is saturated, remove it from the set of active constraints (light_tab) + if(!double_positive(cnst->usage,sg_maxmin_precision) || + !double_positive(cnst->remaining,cnst->bound*sg_maxmin_precision)) { if(cnst->cnst_light) { int index = (cnst->cnst_light-cnst_light_tab); - XBT_DEBUG("index: %d \t cnst_light_num: %d \t || \t cnst: %p \t cnst->cnst_light: %p \t cnst_light_tab: %p usage: %f remaining: %f bound: %f ", - index,cnst_light_num, cnst, cnst->cnst_light, cnst_light_tab, cnst->usage, cnst->remaining, cnst->bound); + XBT_DEBUG("index: %d \t cnst_light_num: %d \t || \t cnst: %p \t cnst->cnst_light: %p " + "\t cnst_light_tab: %p usage: %f remaining: %f bound: %f ", index,cnst_light_num, cnst, + cnst->cnst_light, cnst_light_tab, cnst->usage, cnst->remaining, cnst->bound); cnst_light_tab[index]=cnst_light_tab[cnst_light_num-1]; cnst_light_tab[index].cnst->cnst_light = &cnst_light_tab[index]; cnst_light_num--; @@ -962,7 +904,8 @@ void lmm_solve(lmm_system_t sys) } } else { cnst->cnst_light->remaining_over_usage = cnst->remaining / cnst->usage; - xbt_assert(cnst->active_element_set.count>0, "Should not keep a maximum constraint that has no active element! You want to check the maxmin precision and possible rounding effects." ); + xbt_assert(cnst->active_element_set.count>0, "Should not keep a maximum constraint that has no active" + " element! You want to check the maxmin precision and possible rounding effects." ); } } } @@ -975,17 +918,16 @@ void lmm_solve(lmm_system_t sys) saturated_constraint_set->pos = 0; int pos; for(pos=0; posactive_element_set.count>0, "Cannot saturate more a constraint that has no active element! You may want to change the maxmin precision (--cfg=maxmin/precision:) because of possible rounding effects.\n\tFor the record, the usage of this constraint is %g while the maxmin precision to which it is compared is %g.\n\tThe usage of the previous constraint is %g.", cnst_light_tab[pos].cnst->usage, sg_maxmin_precision, cnst_light_tab[pos-1].cnst->usage); - saturated_constraint_set_update( - cnst_light_tab[pos].remaining_over_usage, - pos, - saturated_constraint_set, - &min_usage); - } + xbt_assert(cnst_light_tab[pos].cnst->active_element_set.count>0, "Cannot saturate more a constraint that has" + " no active element! You may want to change the maxmin precision (--cfg=maxmin/precision:)" + " because of possible rounding effects.\n\tFor the record, the usage of this constraint is %g while " + "the maxmin precision to which it is compared is %g.\n\tThe usage of the previous constraint is %g.", + cnst_light_tab[pos].cnst->usage, sg_maxmin_precision, cnst_light_tab[pos-1].cnst->usage); + saturated_constraint_set_update(cnst_light_tab[pos].remaining_over_usage, pos, saturated_constraint_set, + &min_usage); + } - saturated_variable_set_update( cnst_light_tab, - saturated_constraint_set, - sys); + saturated_variable_set_update(cnst_light_tab, saturated_constraint_set, sys); } while (cnst_light_num > 0); @@ -998,28 +940,23 @@ void lmm_solve(lmm_system_t sys) } lmm_check_concurrency(sys); - + xbt_free(saturated_constraint_set->data); xbt_free(saturated_constraint_set); xbt_free(cnst_light_tab); XBT_OUT(); } - /** \brief Attribute the value bound to var->bound. * * \param sys the lmm_system_t * \param var the lmm_variable_t * \param bound the new bound to associate with var * - * Makes var->bound equal to bound. Whenever this function is called - * a change is signed in the system. To - * avoid false system changing detection it is a good idea to test - * (bound != 0) before calling it. - * + * Makes var->bound equal to bound. Whenever this function is called a change is signed in the system. To + * avoid false system changing detection it is a good idea to test (bound != 0) before calling it. */ -void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var, - double bound) +void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var, double bound) { sys->modified = 1; var->bound = bound; @@ -1028,10 +965,7 @@ void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var, lmm_update_modified_set(sys, var->cnsts[0].constraint); } - - int lmm_concurrency_slack(lmm_constraint_t cnstr){ - //FIXME MARTIN: Replace by infinite value std::numeric_limits::(max)(), or something better within Simgrid? if(cnstr->concurrency_limit<0) return 666; @@ -1042,7 +976,6 @@ int lmm_concurrency_slack(lmm_constraint_t cnstr){ /** \brief Measure the minimum concurrency slack across all constraints where var is involved * * \param The variable to check for - * */ int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var){ int i; @@ -1050,7 +983,7 @@ int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var){ int slack,minslack=666; for (i = 0; i < var->cnsts_number; i++) { slack=lmm_concurrency_slack(var->cnsts[i].constraint); - + //This is only an optimization, to avoid looking at more constraints when slack is already zero //Disable it when debugging to let lmm_concurrency_slack catch nasty things if(!slack && !XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) @@ -1071,21 +1004,21 @@ int lmm_can_enable_var(lmm_variable_t var){ return var->staged_weight>0 && lmm_cnstrs_min_concurrency_slack(var)>=var->concurrency_share; } - -//Small remark: In this implementation of lmm_enable_var and lmm_disable_var, we will meet multiple times with var when running lmm_update_modified_set. -//A priori not a big performance issue, but we might do better by calling lmm_update_modified_set within the for loops (after doing the first for enabling==1, and before doing the last for disabling==1) - +//Small remark: In this implementation of lmm_enable_var and lmm_disable_var, we will meet multiple times with var when +// running lmm_update_modified_set. +//A priori not a big performance issue, but we might do better by calling lmm_update_modified_set within the for loops +// (after doing the first for enabling==1, and before doing the last for disabling==1) void lmm_enable_var(lmm_system_t sys, lmm_variable_t var){ - int i; lmm_element_t elem; - + xbt_assert(lmm_can_enable_var(var)); var->weight = var->staged_weight; var->staged_weight = 0; - //Enabling the variable, move to var to list head. Subtility is: here, we need to call lmm_update_modified_set AFTER moving at least one element of var. + //Enabling the variable, move to var to list head. Subtility is: here, we need to call lmm_update_modified_set AFTER + // moving at least one element of var. xbt_swag_remove(var, &(sys->variable_set)); xbt_swag_insert_at_head(var, &(sys->variable_set)); @@ -1098,7 +1031,8 @@ void lmm_enable_var(lmm_system_t sys, lmm_variable_t var){ if (var->cnsts_number) lmm_update_modified_set(sys, var->cnsts[0].constraint); - //When used within lmm_on_disabled_var, we would get an assertion fail, because transiently there can be variables that are staged and could be activated. + //When used within lmm_on_disabled_var, we would get an assertion fail, because transiently there can be variables + // that are staged and could be activated. //Anyway, caller functions all call lmm_check_concurrency() in the end. // lmm_check_concurrency(sys); } @@ -1108,7 +1042,8 @@ void lmm_disable_var(lmm_system_t sys, lmm_variable_t var){ lmm_element_t elem; xbt_assert(!var->staged_weight,"Staged weight should have been cleared"); - //Disabling the variable, move to var to list tail. Subtility is: here, we need to call lmm_update_modified_set BEFORE moving the last element of var. + //Disabling the variable, move to var to list tail. Subtility is: here, we need to call lmm_update_modified_set BEFORE + //moving the last element of var. xbt_swag_remove(var, &(sys->variable_set)); xbt_swag_insert_at_tail(var, &(sys->variable_set)); if (var->cnsts_number) @@ -1137,11 +1072,10 @@ void lmm_disable_var(lmm_system_t sys, lmm_variable_t var){ * And then add it to enabled variables */ void lmm_on_disabled_var(lmm_system_t sys, lmm_constraint_t cnstr){ - lmm_element_t elem; lmm_element_t nextelem; int numelem; - + if(cnstr->concurrency_limit<0) return; @@ -1156,14 +1090,14 @@ void lmm_on_disabled_var(lmm_system_t sys, lmm_constraint_t cnstr){ nextelem = (lmm_element_t) xbt_swag_getNext(elem, cnstr->disabled_element_set.offset); - if (elem->variable->staged_weight>0 ) - { - //Found a staged variable - //TODOLATER: Add random timing function to model reservation protocol fuzziness? Then how to make sure that staged variables will eventually be called? - if(lmm_can_enable_var(elem->variable)){ - lmm_enable_var(sys,elem->variable); - } + if (elem->variable->staged_weight>0 ){ + //Found a staged variable + //TODOLATER: Add random timing function to model reservation protocol fuzziness? Then how to make sure that + //staged variables will eventually be called? + if(lmm_can_enable_var(elem->variable)){ + lmm_enable_var(sys,elem->variable); } + } xbt_assert(cnstr->concurrency_current<=cnstr->concurrency_limit,"Concurrency overflow!"); if(cnstr->concurrency_current==cnstr->concurrency_limit) @@ -1176,48 +1110,47 @@ void lmm_on_disabled_var(lmm_system_t sys, lmm_constraint_t cnstr){ //And we need to go through all constraints of the disabled var before getting back a coherent state. //Anyway, caller functions all call lmm_check_concurrency() in the end. // lmm_check_concurrency(sys); - } /* \brief update the weight of a variable, and enable/disable it. * @return Returns whether a change was made */ -void lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var, - double weight) +void lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var, double weight) { int minslack; - + xbt_assert(weight>=0,"Variable weight should not be negative!"); - + if (weight == var->weight) return; int enabling_var= (weight>0 && var->weight<=0); int disabling_var= (weight<=0 && var->weight>0); - + XBT_IN("(sys=%p, var=%p, weight=%f)", sys, var, weight); sys->modified = 1; - + //Are we enabling this variable? if (enabling_var){ var->staged_weight = weight; minslack=lmm_cnstrs_min_concurrency_slack(var); if(minslackconcurrency_share){ - XBT_DEBUG("Staging var (instead of enabling) because min concurrency slack %i, with weight %f and concurrency share %i", minslack, weight, var->concurrency_share); + XBT_DEBUG("Staging var (instead of enabling) because min concurrency slack %i, with weight %f and concurrency" + " share %i", minslack, weight, var->concurrency_share); return; } XBT_DEBUG("Enabling var with min concurrency slack %i", minslack); - lmm_enable_var(sys,var); + lmm_enable_var(sys,var); } else if (disabling_var){ //Are we disabling this variable? - lmm_disable_var(sys,var); + lmm_disable_var(sys,var); } else { var->weight=weight; } lmm_check_concurrency(sys); - + XBT_OUT(); return; } @@ -1227,9 +1160,7 @@ double lmm_get_variable_weight(lmm_variable_t var) return var->weight; } -void lmm_update_constraint_bound(lmm_system_t sys, - lmm_constraint_t cnst, - double bound) +void lmm_update_constraint_bound(lmm_system_t sys, lmm_constraint_t cnst, double bound) { sys->modified = 1; lmm_update_modified_set(sys, cnst); @@ -1241,16 +1172,12 @@ int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst) return xbt_swag_belongs(cnst, &(sys->active_constraint_set)); } -inline lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t - sys) +inline lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys) { return (lmm_constraint_t)xbt_swag_getFirst(&(sys->active_constraint_set)); } -inline lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t - sys, - lmm_constraint_t - cnst) +inline lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys, lmm_constraint_t cnst) { return (lmm_constraint_t)xbt_swag_getNext(cnst, (sys->active_constraint_set).offset); } @@ -1261,26 +1188,20 @@ inline lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t * \param sys the lmm_system_t * \param cnst the lmm_constraint_t affected by the change * - * A recursive algorithm to optimize the system recalculation selecting only - * constraints that have changed. Each constraint change is propagated - * to the list of constraints for each variable. + * A recursive algorithm to optimize the system recalculation selecting only constraints that have changed. Each + * constraint change is propagated to the list of constraints for each variable. */ -static void lmm_update_modified_set_rec(lmm_system_t sys, - lmm_constraint_t cnst) +static void lmm_update_modified_set_rec(lmm_system_t sys, lmm_constraint_t cnst) { void* _elem; //TODOLATER: Why lmm_modified_set has been changed in git version 2392B5157...? Looks equivalent logically and less obvious.. - xbt_swag_foreach(_elem, &cnst->enabled_element_set) { lmm_variable_t var = ((lmm_element_t)_elem)->variable; s_lmm_element_t *cnsts = var->cnsts; int i; - for (i = 0; var->visited != sys->visited_counter - && i < var->cnsts_number ; i++) { - if (cnsts[i].constraint != cnst - && !xbt_swag_belongs(cnsts[i].constraint, - &sys->modified_constraint_set)) { + for (i = 0; var->visited != sys->visited_counter && i < var->cnsts_number ; i++) { + if (cnsts[i].constraint != cnst && !xbt_swag_belongs(cnsts[i].constraint, &sys->modified_constraint_set)) { xbt_swag_insert(cnsts[i].constraint, &sys->modified_constraint_set); lmm_update_modified_set_rec(sys, cnsts[i].constraint); } @@ -1290,12 +1211,10 @@ static void lmm_update_modified_set_rec(lmm_system_t sys, } } -static void lmm_update_modified_set(lmm_system_t sys, - lmm_constraint_t cnst) +static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst) { /* nothing to do if selective update isn't active */ - if (sys->selective_update_active - && !xbt_swag_belongs(cnst, &sys->modified_constraint_set)) { + if (sys->selective_update_active && !xbt_swag_belongs(cnst, &sys->modified_constraint_set)) { xbt_swag_insert(cnst, &sys->modified_constraint_set); lmm_update_modified_set_rec(sys, cnst); } @@ -1304,14 +1223,14 @@ static void lmm_update_modified_set(lmm_system_t sys, /** \brief Remove all constraints of the modified_constraint_set. * * \param sys the lmm_system_t - * */ static void lmm_remove_all_modified_set(lmm_system_t sys) { - //We cleverly un-flag all variables just by incrementing sys->visited_counter //In effect, the var->visited value will no more be equal to sys->visited counter - //To be clean, when visited counter has wrapped around, we force these var->visited values so that variables that were in the modified a long (long long) time ago are not wrongly skipped here, which would lead to very nasty bugs (i.e. not readibily reproducible, and requiring a lot of run time before happening). + //To be clean, when visited counter has wrapped around, we force these var->visited values so that variables that + //were in the modified a long (long long) time ago are not wrongly skipped here, which would lead to very nasty bugs + //(i.e. not readibily reproducible, and requiring a lot of run time before happening). if (++sys->visited_counter == 1) { /* the counter wrapped around, reset each variable->visited */ void *_var; @@ -1326,7 +1245,6 @@ static void lmm_remove_all_modified_set(lmm_system_t sys) * * \param cnst the lmm_constraint_t associated to the resource * - * * This is dead code, but we may use it later for debug/trace. */ double lmm_constraint_get_usage(lmm_constraint_t cnst) { @@ -1356,36 +1274,36 @@ void lmm_check_concurrency(lmm_system_t sys){ lmm_variable_t var; int concurrency; int i,belong_to_enabled,belong_to_disabled,belong_to_active; - + //These checks are very expensive, so do them only if we want to debug SURF LMM if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) { - xbt_swag_foreach(_cnst, &(sys->constraint_set)) { cnst = (lmm_constraint_t) _cnst; concurrency=0; xbt_swag_foreach(_elem, &(cnst->enabled_element_set)) { - elem = (lmm_element_t)_elem; - xbt_assert(elem->variable->weight > 0); - concurrency+=lmm_element_concurrency(elem); + elem = (lmm_element_t)_elem; + xbt_assert(elem->variable->weight > 0); + concurrency+=lmm_element_concurrency(elem); } - + xbt_swag_foreach(_elem, &(cnst->disabled_element_set)) { - elem = (lmm_element_t)_elem; - //We should have staged variables only if concurrency is reached in some constraint - xbt_assert(cnst->concurrency_limit<0 || elem->variable->staged_weight==0 || lmm_cnstrs_min_concurrency_slack(elem->variable) < elem->variable->concurrency_share,"should not have staged variable!"); + elem = (lmm_element_t)_elem; + //We should have staged variables only if concurrency is reached in some constraint + xbt_assert(cnst->concurrency_limit<0 || elem->variable->staged_weight==0 || + lmm_cnstrs_min_concurrency_slack(elem->variable) < elem->variable->concurrency_share, + "should not have staged variable!"); } - + xbt_assert(cnst->concurrency_limit<0 || cnst->concurrency_limit >= concurrency,"concurrency check failed!"); xbt_assert(cnst->concurrency_current == concurrency, "concurrency_current is out-of-date!"); } - //Check that for each variable, all corresponding elements are in the same state (i.e. same element sets) xbt_swag_foreach(_var, &(sys->variable_set)) { var= (lmm_variable_t) _var; if(!var->cnsts_number) - continue; + continue; elem = &var->cnsts[0]; belong_to_enabled=xbt_swag_belongs(elem,&(elem->constraint->enabled_element_set)); @@ -1393,15 +1311,14 @@ void lmm_check_concurrency(lmm_system_t sys){ belong_to_active=xbt_swag_belongs(elem,&(elem->constraint->active_element_set)); for (i = 1; i < var->cnsts_number; i++) { - elem = &var->cnsts[i]; - xbt_assert(belong_to_enabled==xbt_swag_belongs(elem,&(elem->constraint->enabled_element_set)), - "Variable inconsistency (1): enabled_element_set"); - xbt_assert(belong_to_disabled==xbt_swag_belongs(elem,&(elem->constraint->disabled_element_set)), - "Variable inconsistency (2): disabled_element_set"); - xbt_assert(belong_to_active==xbt_swag_belongs(elem,&(elem->constraint->active_element_set)), - "Variable inconsistency (3): active_element_set"); + elem = &var->cnsts[i]; + xbt_assert(belong_to_enabled==xbt_swag_belongs(elem,&(elem->constraint->enabled_element_set)), + "Variable inconsistency (1): enabled_element_set"); + xbt_assert(belong_to_disabled==xbt_swag_belongs(elem,&(elem->constraint->disabled_element_set)), + "Variable inconsistency (2): disabled_element_set"); + xbt_assert(belong_to_active==xbt_swag_belongs(elem,&(elem->constraint->active_element_set)), + "Variable inconsistency (3): active_element_set"); } - } } } diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index a2ed64bac2..e1c84d703a 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -1101,6 +1101,7 @@ set(PLATFORMS_EXAMPLES examples/platforms/syscoord/median_harvard.syscoord examples/platforms/syscoord/median_meridian.syscoord examples/platforms/syscoord/median_p2psim.syscoord + examples/platforms/three_multicore_hosts.xml examples/platforms/torus_cluster.xml examples/platforms/two_hosts.xml examples/platforms/two_hosts_platform.xml