From: Frederic Suter Date: Fri, 1 Dec 2017 17:34:50 +0000 (+0100) Subject: one more MSG example to go to the dungeon X-Git-Tag: v3.18~188 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/707b11fe424a58eb8e870fc71978568c58006a3e one more MSG example to go to the dungeon --- diff --git a/examples/msg/CMakeLists.txt b/examples/msg/CMakeLists.txt index 0c6fa92ef6..be821f78bf 100644 --- a/examples/msg/CMakeLists.txt +++ b/examples/msg/CMakeLists.txt @@ -1,7 +1,7 @@ # C examples foreach(x app-masterworker app-pingpong app-token-ring async-wait async-waitall async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks - dht-pastry energy-consumption energy-onoff energy-pstate energy-ptask energy-vm platform-failures + dht-pastry energy-consumption energy-onoff energy-pstate energy-vm platform-failures io-file io-remote io-storage task-priority plugin-hostload process-create process-daemon process-join process-migration process-suspend @@ -99,7 +99,6 @@ endforeach() ADD_TESH_FACTORIES(msg-dht-kademlia-parallel "thread;ucontext;raw;boost" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO} --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/dht-kademlia --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/dht-kademlia dht-kademlia.tesh) ADD_TESH_FACTORIES(msg-energy-pstate-ptask "thread;ucontext;raw;boost" --cfg host/model:ptask_L07 --log xbt_cfg.threshold:critical --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy-pstate/energy-pstate.tesh) ADD_TESH_FACTORIES(msg-energy-consumption-ptask "thread;ucontext;raw;boost" --cfg host/model:ptask_L07 --log xbt_cfg.threshold:critical --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy-consumption/energy-consumption.tesh) -ADD_TESH_FACTORIES(msg-energy-ptask "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/energy-ptask/energy-ptask.tesh) ADD_TESH_FACTORIES(msg-plugin-hostload "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/ ${CMAKE_HOME_DIRECTORY}/examples/msg/plugin-hostload/plugin-hostload.tesh) if(NOT WIN32) ADD_TESH_FACTORIES(msg-maestro-set "thread" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/msg --cd ${CMAKE_BINARY_DIR}/examples/msg ${CMAKE_HOME_DIRECTORY}/examples/msg/maestro-set/maestro-set.tesh) diff --git a/teshsuite/msg/CMakeLists.txt b/teshsuite/msg/CMakeLists.txt index 5d4b694b85..bdb83bff3d 100644 --- a/teshsuite/msg/CMakeLists.txt +++ b/teshsuite/msg/CMakeLists.txt @@ -1,6 +1,7 @@ # C examples foreach(x actions-comm actions-storage cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes process-kill process-yield + energy-ptask trace_integration) add_executable (${x} ${x}/${x}.c) target_link_libraries(${x} simgrid) @@ -55,7 +56,8 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/acti foreach(x get_sender host_on_off host_on_off_processes host_on_off_recv task_destroy_cancel task_listen_from task_progress - process-kill process-yield + process-kill process-yield + energy-ptask trace_integration) ADD_TESH_FACTORIES(tesh-msg-${x} "thread;ucontext;raw;boost" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_BINARY_DIR}/teshsuite/msg/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh) endforeach() diff --git a/examples/msg/energy-ptask/energy-ptask.c b/teshsuite/msg/energy-ptask/energy-ptask.c similarity index 75% rename from examples/msg/energy-ptask/energy-ptask.c rename to teshsuite/msg/energy-ptask/energy-ptask.c index d368bb1378..8a41939ab1 100644 --- a/examples/msg/energy-ptask/energy-ptask.c +++ b/teshsuite/msg/energy-ptask/energy-ptask.c @@ -3,8 +3,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "simgrid/msg.h" #include "simgrid/plugins/energy.h" +#include "simgrid/msg.h" XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); @@ -16,26 +16,26 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example") * interfaces, but it's not possible ATM). */ -static int runner(int argc, char *argv[]) +static int runner(int argc, char* argv[]) { /* Retrieve the list of all hosts as an array of hosts */ - int hosts_count = MSG_get_host_number(); - msg_host_t *hosts = xbt_dynar_to_array(MSG_hosts_as_dynar()); + int hosts_count = MSG_get_host_number(); + msg_host_t* hosts = xbt_dynar_to_array(MSG_hosts_as_dynar()); XBT_INFO("First, build a classical parallel task, with 1 Gflop to execute on each node, " "and 10MB to exchange between each pair"); - double *computation_amounts = xbt_new0(double, hosts_count); - double *communication_amounts = xbt_new0(double, hosts_count * hosts_count); + double* computation_amounts = xbt_new0(double, hosts_count); + double* communication_amounts = xbt_new0(double, hosts_count* hosts_count); - for (int i = 0; i < hosts_count; i++) + for (int i = 0; i < hosts_count; i++) computation_amounts[i] = 1e9; // 1 Gflop for (int i = 0; i < hosts_count; i++) - for (int j = i + 1; j < hosts_count; j++) + for (int j = i + 1; j < hosts_count; j++) communication_amounts[i * hosts_count + j] = 1e7; // 10 MB msg_task_t ptask = - MSG_parallel_task_create("parallel task", hosts_count, hosts, computation_amounts, communication_amounts, NULL); + MSG_parallel_task_create("parallel task", hosts_count, hosts, computation_amounts, communication_amounts, NULL); MSG_parallel_task_execute(ptask); MSG_task_destroy(ptask); xbt_free(communication_amounts); @@ -59,28 +59,29 @@ static int runner(int argc, char *argv[]) XBT_INFO("Then, build a parallel task involving only computations and no communication (1 Gflop per node)"); computation_amounts = xbt_new0(double, hosts_count); - for (int i = 0; i < hosts_count; i++) + for (int i = 0; i < hosts_count; i++) computation_amounts[i] = 1e9; // 1 Gflop - ptask = MSG_parallel_task_create("parallel exec", hosts_count, hosts, computation_amounts, NULL/* no comm */, NULL); + ptask = MSG_parallel_task_create("parallel exec", hosts_count, hosts, computation_amounts, NULL /* no comm */, NULL); MSG_parallel_task_execute(ptask); MSG_task_destroy(ptask); xbt_free(computation_amounts); XBT_INFO("Then, build a parallel task with no computation nor communication (synchro only)"); - computation_amounts = xbt_new0(double, hosts_count); - communication_amounts = xbt_new0(double, hosts_count * hosts_count); /* memset to 0 by xbt_new0 */ - ptask = MSG_parallel_task_create("parallel sync", hosts_count, hosts, computation_amounts, communication_amounts, NULL); + computation_amounts = xbt_new0(double, hosts_count); + communication_amounts = xbt_new0(double, hosts_count* hosts_count); /* memset to 0 by xbt_new0 */ + ptask = + MSG_parallel_task_create("parallel sync", hosts_count, hosts, computation_amounts, communication_amounts, NULL); MSG_parallel_task_execute(ptask); MSG_task_destroy(ptask); xbt_free(communication_amounts); xbt_free(computation_amounts); XBT_INFO("Finally, trick the ptask to do a 'remote execution', on host %s", MSG_host_get_name(hosts[1])); - computation_amounts = xbt_new0(double, 1); + computation_amounts = xbt_new0(double, 1); computation_amounts[0] = 1e9; // 1 Gflop - msg_host_t *remote = xbt_new(msg_host_t,1); - remote[0] = hosts[1]; - ptask = MSG_parallel_task_create("remote exec", 1, remote, computation_amounts, NULL/* no comm */, NULL); + msg_host_t* remote = xbt_new(msg_host_t, 1); + remote[0] = hosts[1]; + ptask = MSG_parallel_task_create("remote exec", 1, remote, computation_amounts, NULL /* no comm */, NULL); MSG_parallel_task_execute(ptask); MSG_task_destroy(ptask); xbt_free(remote); @@ -91,7 +92,7 @@ static int runner(int argc, char *argv[]) return 0; } -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { MSG_init(&argc, argv); MSG_config("host/model", "ptask_L07"); @@ -99,14 +100,14 @@ int main(int argc, char *argv[]) xbt_assert(argc <= 3, "1Usage: %s [--energy]", argv[0]); xbt_assert(argc >= 2, "2Usage: %s [--energy]", argv[0]); - if(argc == 3 && argv[2][2] == 'e') + if (argc == 3 && argv[2][2] == 'e') sg_host_energy_plugin_init(); MSG_create_environment(argv[1]); /* Pick a process, no matter which, from the platform file */ xbt_dynar_t all_hosts = MSG_hosts_as_dynar(); - msg_host_t first_host = xbt_dynar_getfirst_as(all_hosts,msg_host_t); + msg_host_t first_host = xbt_dynar_getfirst_as(all_hosts, msg_host_t); xbt_dynar_free(&all_hosts); MSG_process_create("test", runner, NULL, first_host); diff --git a/examples/msg/energy-ptask/energy-ptask.tesh b/teshsuite/msg/energy-ptask/energy-ptask.tesh similarity index 88% rename from examples/msg/energy-ptask/energy-ptask.tesh rename to teshsuite/msg/energy-ptask/energy-ptask.tesh index 6414155e8d..1a102044c0 100644 --- a/examples/msg/energy-ptask/energy-ptask.tesh +++ b/teshsuite/msg/energy-ptask/energy-ptask.tesh @@ -1,6 +1,6 @@ #! ./tesh -$ ${bindir:=.}/energy-ptask/energy-ptask$EXEEXT ${srcdir:=.}/../platforms/energy_platform.xml --energy "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ ${bindir:=.}/energy-ptask$EXEEXT ${platfdir:=.}/energy_platform.xml --energy "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (0:maestro@) Switching to the L07 model to handle parallel tasks. > [ 0.000000] (1:test@MyHost1) First, build a classical parallel task, with 1 Gflop to execute on each node, and 10MB to exchange between each pair > [300.000000] (1:test@MyHost1) We can do the same with a timeout of one second enabled.