From 455d314e8fc3b4c8a088724b1baac831df0b997f Mon Sep 17 00:00:00 2001 From: Takishipp Date: Fri, 6 Oct 2017 16:50:45 +0200 Subject: [PATCH] Convert actor-execute to s4u API --- examples/s4u/CMakeLists.txt | 5 +++- examples/s4u/README.doc | 6 +++- .../s4u/actor-execute/BuilSimGrid.sh.log* | 3 ++ .../s4u/actor-execute/s4u-actor-execute.cpp | 30 +++++++++++++++++++ .../s4u/actor-execute/s4u-actor-execute.tesh | 4 +++ 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 examples/s4u/actor-execute/BuilSimGrid.sh.log* create mode 100644 examples/s4u/actor-execute/s4u-actor-execute.cpp create mode 100644 examples/s4u/actor-execute/s4u-actor-execute.tesh diff --git a/examples/s4u/CMakeLists.txt b/examples/s4u/CMakeLists.txt index 0ee6b1e500..933e55d840 100644 --- a/examples/s4u/CMakeLists.txt +++ b/examples/s4u/CMakeLists.txt @@ -2,6 +2,7 @@ foreach (example actions-comm actions-storage actor-create actor-daemon actor-kill actor-migration actor-suspend app-masterworker app-pingpong app-token-ring async-wait async-waitany async-waitall + actor-execute plugin-hostload io mutex) add_executable (s4u-${example} ${example}/s4u-${example}.cpp) target_link_libraries(s4u-${example} simgrid) @@ -34,7 +35,8 @@ set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord.tesh ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/s4u-async-wait.tesh ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u-async-waitany.tesh - ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/s4u-async-waitall.tesh PARENT_SCOPE) + ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/s4u-async-waitall.tesh + ${CMAKE_CURRENT_SOURCE_DIR}/process-create/s4u-actor-execute.tesh PARENT_SCOPE) set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm-split_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/actions-storage/s4u-actions-storage_d.xml @@ -55,6 +57,7 @@ foreach(example actions-comm actions-storage actor-create actor-daemon actor-kill actor-migration actor-suspend app-bittorrent app-masterworker app-pingpong app-token-ring async-wait async-waitall async-waitany + actor-execute dht-chord plugin-hostload io mutex) ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example} s4u-${example}.tesh) endforeach() diff --git a/examples/s4u/README.doc b/examples/s4u/README.doc index 97be9a1597..9766f81577 100644 --- a/examples/s4u/README.doc +++ b/examples/s4u/README.doc @@ -25,6 +25,10 @@ documentation, but it should remain readable directly. @ref examples/s4u/actor-create/s4u-actor-create_d.xml \n Shows how to start your actors to populate your simulation. + - Excute actors. + @ref examples/s4u/process-create/s4u-process-create.cpp \n + Most processes are started from the deployment XML file. + - Ping Pong: @ref examples/s4u/app-pingpong/s4u-app-pingpong.c\n It's hard to think of a simpler example: it is just sending one message back and forth. The tesh file laying in the directory show how to start the simulator binary, highlighting how to pass options to @@ -57,7 +61,7 @@ documentation, but it should remain readable directly. @ref examples/s4u/async-waitany/s4u-async-waitany.cpp\n The @ref simgrid::s4u::Comm::wait_any() function is useful when you want to block until one activity of the set completes, no matter which terminates - first. + first. @section s4u_ex_actors Acting on Actors diff --git a/examples/s4u/actor-execute/BuilSimGrid.sh.log* b/examples/s4u/actor-execute/BuilSimGrid.sh.log* new file mode 100644 index 0000000000..d6109fad5c --- /dev/null +++ b/examples/s4u/actor-execute/BuilSimGrid.sh.log* @@ -0,0 +1,3 @@ +make: *** No targets specified and no makefile found. Stop. +make: *** No targets specified and no makefile found. Stop. +vendredi 6 octobre 2017, 16:34:15 (UTC+0200) diff --git a/examples/s4u/actor-execute/s4u-actor-execute.cpp b/examples/s4u/actor-execute/s4u-actor-execute.cpp new file mode 100644 index 0000000000..26fc7d13b9 --- /dev/null +++ b/examples/s4u/actor-execute/s4u-actor-execute.cpp @@ -0,0 +1,30 @@ +/* Copyright (c) 2010-2017. 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/s4u.hpp" + #include + #include + +/* Main function of the actor I want to start manually */ +static int actor_function(std::vector args) +{ + simgrid::s4u::this_actor::execute(100); + return 0; +} + +int main(int argc, char *argv[]) +{ + simgrid::s4u::Engine e(&argc, argv); + std::vector args; + xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]); + + e.loadPlatform(argv[1]); + + simgrid::s4u::Actor::createActor("simple_func", simgrid::s4u::Host::by_name("Tremblay"), actor_function, args); + + e.run(); + + return 0; +} diff --git a/examples/s4u/actor-execute/s4u-actor-execute.tesh b/examples/s4u/actor-execute/s4u-actor-execute.tesh new file mode 100644 index 0000000000..e4575eb320 --- /dev/null +++ b/examples/s4u/actor-execute/s4u-actor-execute.tesh @@ -0,0 +1,4 @@ +#! ./tesh + +p Start remote processes +$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-execute$EXEEXT ${srcdir:=.}/small_platform.xml -- 2.20.1