From: Arnaud Giersch Date: Tue, 8 Dec 2020 10:03:28 +0000 (+0100) Subject: Convert deprecated/msg/trace-process-migration to s4u/trace-process-migration. X-Git-Tag: v3.26~22 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/295e4684470e17e4d4353d284f01a9e8d2f5d511 Convert deprecated/msg/trace-process-migration to s4u/trace-process-migration. --- diff --git a/.gitignore b/.gitignore index 0149a15727..94cf8fc7bf 100644 --- a/.gitignore +++ b/.gitignore @@ -166,7 +166,6 @@ examples/deprecated/msg/mc/bugged3 examples/deprecated/msg/mc/centralized_mutex examples/deprecated/msg/mc/electric_fence examples/deprecated/msg/synchro-semaphore/synchro-semaphore -examples/deprecated/msg/trace-process-migration/trace-process-migration examples/deprecated/msg/*.pcap examples/deprecated/msg/*.tr examples/s4u/actor-create/s4u-actor-create @@ -241,6 +240,7 @@ examples/s4u/trace-host-user-variables/s4u-trace-host-user-variables examples/s4u/trace-link-user-variables/s4u-trace-link-user-variables examples/s4u/trace-masterworkers/s4u-trace-masterworkers examples/s4u/trace-platform/s4u-trace-platform +examples/s4u/trace-process-migration/s4u-trace-process-migration examples/s4u/trace-route-user-variables/s4u-trace-route-user-variables examples/deprecated/simdag/dag-dotload/sd_dag-dotload examples/deprecated/simdag/daxload/sd_daxload diff --git a/MANIFEST.in b/MANIFEST.in index 27f30437ad..007485d38b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -262,8 +262,6 @@ include examples/deprecated/msg/mc/centralized_mutex.tesh include examples/deprecated/msg/mc/deploy_bugged2_liveness.xml include examples/deprecated/msg/mc/deploy_centralized_mutex.xml include examples/deprecated/msg/mc/promela_bugged2_liveness -include examples/deprecated/msg/trace-process-migration/trace-process-migration.c -include examples/deprecated/msg/trace-process-migration/trace-process-migration.tesh include examples/deprecated/simdag/dag-dotload/dag.dot include examples/deprecated/simdag/dag-dotload/dag_with_cycle.dot include examples/deprecated/simdag/dag-dotload/sd_dag-dotload.c @@ -519,6 +517,8 @@ include examples/s4u/trace-masterworkers/s4u-trace-masterworkers.cpp include examples/s4u/trace-masterworkers/s4u-trace-masterworkers.tesh include examples/s4u/trace-platform/s4u-trace-platform.cpp include examples/s4u/trace-platform/s4u-trace-platform.tesh +include examples/s4u/trace-process-migration/s4u-trace-process-migration.cpp +include examples/s4u/trace-process-migration/s4u-trace-process-migration.tesh include examples/s4u/trace-route-user-variables/s4u-trace-route-user-variables.cpp include examples/s4u/trace-route-user-variables/s4u-trace-route-user-variables.tesh include examples/smpi/NAS/DGraph.c diff --git a/examples/deprecated/msg/CMakeLists.txt b/examples/deprecated/msg/CMakeLists.txt index 4eb771178f..8ed68b133a 100644 --- a/examples/deprecated/msg/CMakeLists.txt +++ b/examples/deprecated/msg/CMakeLists.txt @@ -1,24 +1,3 @@ -foreach(x trace-process-migration) - if(enable_msg) - add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.c) - target_link_libraries(${x} simgrid) - set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x}) - add_dependencies(tests ${x}) - endif() - set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c) - set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh) -endforeach() - set(examples_src ${examples_src} PARENT_SCOPE) set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/README.doc PARENT_SCOPE) set(tesh_files ${tesh_files} PARENT_SCOPE) - -if(enable_msg) - foreach (x trace-process-migration) - ADD_TESH(msg-${x} --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg/${x} - --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/${x} - --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms - --cd ${CMAKE_BINARY_DIR}/examples/deprecated/msg/${x} - ${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/${x}/${x}.tesh) - endforeach() -endif(enable_msg) diff --git a/examples/deprecated/msg/trace-process-migration/trace-process-migration.c b/examples/deprecated/msg/trace-process-migration/trace-process-migration.c deleted file mode 100644 index cdc4eb28f9..0000000000 --- a/examples/deprecated/msg/trace-process-migration/trace-process-migration.c +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved. */ - -/* 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" - -/* The guy we will move from host to host. It move alone and then is moved by policeman back */ -static int emigrant(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[]) -{ - msg_task_t task = NULL; - char *destination = NULL; - - MSG_process_sleep(2); - - while (1){ // I am an eternal emigrant - MSG_task_receive(&(task), "master_mailbox"); - destination = (char*)MSG_task_get_data (task); - MSG_task_destroy (task); - if (destination == NULL) - break; //there is no destination, die - MSG_process_migrate(MSG_process_self(), MSG_host_by_name(destination)); - MSG_process_sleep(2); // I am tired, have to sleep for 2 seconds - free (destination); - task = NULL; - } - return 0; -} - -static int policeman(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[]) -{ - // I am the master of emigrant process, - // I tell it where it must emigrate to. - xbt_dynar_t destinations = xbt_dynar_new (sizeof(char*), &xbt_free_ref); - xbt_dynar_push_as (destinations, char*, xbt_strdup ("Tremblay")); - xbt_dynar_push_as (destinations, char*, xbt_strdup ("Jupiter")); - xbt_dynar_push_as (destinations, char*, xbt_strdup ("Fafard")); - xbt_dynar_push_as (destinations, char*, xbt_strdup ("Ginette")); - xbt_dynar_push_as (destinations, char*, xbt_strdup ("Bourassa")); - xbt_dynar_push_as (destinations, char*, xbt_strdup ("Fafard")); - xbt_dynar_push_as (destinations, char*, xbt_strdup ("Tremblay")); - xbt_dynar_push_as (destinations, char*, xbt_strdup ("Ginette")); - xbt_dynar_push_as (destinations, char*, NULL); - - char *destination; - unsigned int i; - xbt_dynar_foreach(destinations, i, destination){ - msg_task_t task = MSG_task_create("task", 0, 0, NULL); - if (destination != NULL){ - MSG_task_set_data(task, xbt_strdup (destination)); - } - MSG_task_set_category(task, "migration_order"); - MSG_task_send (task, "master_mailbox"); - } - xbt_dynar_free (&destinations); - return 0; -} - -int main(int argc, char *argv[]) -{ - MSG_init(&argc, argv); - xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]); - - MSG_create_environment(argv[1]); - - TRACE_category ("migration_order"); - - MSG_process_create("emigrant", emigrant, NULL, MSG_get_host_by_name("Fafard")); - MSG_process_create("policeman", policeman, NULL, MSG_get_host_by_name("Tremblay")); - - MSG_main(); - return 0; -} diff --git a/examples/s4u/CMakeLists.txt b/examples/s4u/CMakeLists.txt index a6941cb54f..fa8d05d7cc 100644 --- a/examples/s4u/CMakeLists.txt +++ b/examples/s4u/CMakeLists.txt @@ -183,7 +183,7 @@ endif() # Examples not accepting factories ################################## -foreach (example trace-categories trace-platform trace-masterworkers +foreach (example trace-categories trace-masterworkers trace-platform trace-process-migration trace-host-user-variables trace-link-user-variables trace-route-user-variables) add_executable (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp) target_link_libraries(s4u-${example} simgrid) diff --git a/examples/s4u/trace-process-migration/s4u-trace-process-migration.cpp b/examples/s4u/trace-process-migration/s4u-trace-process-migration.cpp new file mode 100644 index 0000000000..fd8d3d3386 --- /dev/null +++ b/examples/s4u/trace-process-migration/s4u-trace-process-migration.cpp @@ -0,0 +1,57 @@ +/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved. */ + +/* 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. */ + +/* This source code simply loads the platform. This is only useful to play + * with the tracing module. See the tesh file to see how to generate the + * traces. + */ + +#include "simgrid/instr.h" +#include "simgrid/s4u.hpp" +#include + +/* The guy we will move from host to host. It move alone and then is moved by policeman back */ +static void emigrant() +{ + auto mailbox = simgrid::s4u::Mailbox::by_name("master_mailbox"); + + simgrid::s4u::this_actor::sleep_for(2); + + while (true) { // I am an eternal emigrant + auto destination = std::unique_ptr(static_cast(mailbox->get())); + if (destination->empty()) + break; // there is no destination, die + simgrid::s4u::this_actor::set_host(simgrid::s4u::Host::by_name(*destination)); + simgrid::s4u::this_actor::sleep_for(2); // I am tired, have to sleep for 2 seconds + } +} + +static void policeman() +{ + // I am the master of emigrant process, + // I tell it where it must emigrate to. + auto destinations = {"Tremblay", "Jupiter", "Fafard", "Ginette", "Bourassa", "Fafard", "Tremblay", "Ginette", ""}; + auto mailbox = simgrid::s4u::Mailbox::by_name("master_mailbox"); + + for (auto const& destination : destinations) { + mailbox->put_init(new std::string(destination), 0)->set_tracing_category("migration_order")->wait(); + } +} + +int main(int argc, char* argv[]) +{ + simgrid::s4u::Engine e(&argc, argv); + xbt_assert(argc > 1, "Usage: %s platform_file\n \tExample: %s small_platform.xml\n", argv[0], argv[0]); + + e.load_platform(argv[1]); + + TRACE_category("migration_order"); + + simgrid::s4u::Actor::create("emigrant", simgrid::s4u::Host::by_name("Fafard"), emigrant); + simgrid::s4u::Actor::create("policeman", simgrid::s4u::Host::by_name("Tremblay"), policeman); + + e.run(); + return 0; +} diff --git a/examples/deprecated/msg/trace-process-migration/trace-process-migration.tesh b/examples/s4u/trace-process-migration/s4u-trace-process-migration.tesh similarity index 91% rename from examples/deprecated/msg/trace-process-migration/trace-process-migration.tesh rename to examples/s4u/trace-process-migration/s4u-trace-process-migration.tesh index d935ce20f8..b6dafe2905 100644 --- a/examples/deprecated/msg/trace-process-migration/trace-process-migration.tesh +++ b/examples/s4u/trace-process-migration/s4u-trace-process-migration.tesh @@ -1,11 +1,10 @@ #!/usr/bin/env tesh p Tracing processes -$ ${bindir:=.}/trace-process-migration --cfg=tracing:yes --cfg=tracing/filename:procmig.trace --cfg=tracing/msg/process:yes ${platfdir}/small_platform.xml +$ ${bindir:=.}/s4u-trace-process-migration --cfg=tracing:yes --cfg=tracing/filename:procmig.trace --cfg=tracing/actor:yes ${platfdir}/small_platform.xml > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to 'yes' > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'procmig.trace' -> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/msg/process' to 'yes' -> [0.000000] [xbt_cfg/INFO] Option tracing/msg/process has been renamed to tracing/actor. Consider switching. +> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/actor' to 'yes' $ tail -n +3 procmig.trace > %EventDef PajeDefineContainerType 0 @@ -255,15 +254,12 @@ $ tail -n +3 procmig.trace > 4 13 0 6 6 ACTOR_LINK > 6 0.000000 33 6 1 "policeman-2" > 12 0.000000 7 32 9 -> 15 0.000000 13 0 SR 33 p0 > 12 0.000000 7 33 11 > 13 2.000000 7 32 > 12 2.000000 7 32 10 > 13 2.025708 7 33 -> 15 2.025708 13 0 SR 33 p1 > 12 2.025708 7 33 11 > 13 2.025708 7 32 -> 16 2.025708 13 0 SR 32 p0 > 15 2.025708 13 0 M 32 0 > 7 2.025708 6 32 > 6 2.025708 34 6 1 "emigrant-1" @@ -272,10 +268,8 @@ $ tail -n +3 procmig.trace > 13 4.025708 7 34 > 12 4.025708 7 34 10 > 13 4.025903 7 33 -> 15 4.025903 13 0 SR 33 p2 > 12 4.025903 7 33 11 > 13 4.025903 7 34 -> 16 4.025903 13 0 SR 34 p1 > 15 4.025903 13 0 M 34 1 > 7 4.025903 6 34 > 6 4.025903 35 6 2 "emigrant-1" @@ -284,10 +278,8 @@ $ tail -n +3 procmig.trace > 13 6.025903 7 35 > 12 6.025903 7 35 10 > 13 6.044918 7 33 -> 15 6.044918 13 0 SR 33 p3 > 12 6.044918 7 33 11 > 13 6.044918 7 35 -> 16 6.044918 13 0 SR 35 p2 > 15 6.044918 13 0 M 35 2 > 7 6.044918 6 35 > 6 6.044918 36 6 3 "emigrant-1" @@ -296,10 +288,8 @@ $ tail -n +3 procmig.trace > 13 8.044918 7 36 > 12 8.044918 7 36 10 > 13 8.070626 7 33 -> 15 8.070626 13 0 SR 33 p4 > 12 8.070626 7 33 11 > 13 8.070626 7 36 -> 16 8.070626 13 0 SR 36 p3 > 15 8.070626 13 0 M 36 3 > 7 8.070626 6 36 > 6 8.070626 37 6 4 "emigrant-1" @@ -308,10 +298,8 @@ $ tail -n +3 procmig.trace > 13 10.070626 7 37 > 12 10.070626 7 37 10 > 13 10.087178 7 33 -> 15 10.087178 13 0 SR 33 p5 > 12 10.087178 7 33 11 > 13 10.087178 7 37 -> 16 10.087178 13 0 SR 37 p4 > 15 10.087178 13 0 M 37 4 > 7 10.087178 6 37 > 6 10.087178 38 6 5 "emigrant-1" @@ -320,10 +308,8 @@ $ tail -n +3 procmig.trace > 13 12.087178 7 38 > 12 12.087178 7 38 10 > 13 12.112617 7 33 -> 15 12.112617 13 0 SR 33 p6 > 12 12.112617 7 33 11 > 13 12.112617 7 38 -> 16 12.112617 13 0 SR 38 p5 > 15 12.112617 13 0 M 38 5 > 7 12.112617 6 38 > 6 12.112617 39 6 3 "emigrant-1" @@ -332,10 +318,8 @@ $ tail -n +3 procmig.trace > 13 14.112617 7 39 > 12 14.112617 7 39 10 > 13 14.138325 7 33 -> 15 14.138325 13 0 SR 33 p7 > 12 14.138325 7 33 11 > 13 14.138325 7 39 -> 16 14.138325 13 0 SR 39 p6 > 15 14.138325 13 0 M 39 6 > 7 14.138325 6 39 > 6 14.138325 40 6 1 "emigrant-1" @@ -344,10 +328,8 @@ $ tail -n +3 procmig.trace > 13 16.138325 7 40 > 12 16.138325 7 40 10 > 13 16.138521 7 33 -> 15 16.138521 13 0 SR 33 p8 > 12 16.138521 7 33 11 > 13 16.138521 7 40 -> 16 16.138521 13 0 SR 40 p7 > 15 16.138521 13 0 M 40 7 > 7 16.138521 6 40 > 6 16.138521 41 6 4 "emigrant-1" @@ -357,7 +339,6 @@ $ tail -n +3 procmig.trace > 12 18.138521 7 41 10 > 13 18.155073 7 33 > 13 18.155073 7 41 -> 16 18.155073 13 0 SR 41 p8 > 7 18.155073 6 33 > 7 18.155073 6 41 > 7 18.155073 2 16 @@ -392,4 +373,4 @@ $ tail -n +3 procmig.trace > 7 18.155073 1 1 > 7 18.155073 2 31 -$ rm -rf procmig.trace +$ rm -f procmig.trace