From: Zitagcc Date: Wed, 18 Oct 2017 13:51:08 +0000 (+0200) Subject: Merge branch 'master' into actor-priority X-Git-Tag: v3.18~401^2~3^2^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/22e6546d2c6f14864cc93c4ed1470d8e8c1e2d95?hp=c82612f115c9741b134e7cba11e28bb706acacd7 Merge branch 'master' into actor-priority --- diff --git a/examples/s4u/CMakeLists.txt b/examples/s4u/CMakeLists.txt index 669aba8d27..5a9d1cc390 100644 --- a/examples/s4u/CMakeLists.txt +++ b/examples/s4u/CMakeLists.txt @@ -1,5 +1,6 @@ foreach (example actions-comm actions-storage - actor-create actor-daemon actor-execute actor-kill actor-lifetime actor-migration actor-suspend + actor-create actor-daemon actor-kill actor-migration actor-suspend + actor-create actor-daemon actor-execute actor-kill actor-lifetime actor-migration actor-suspend actor-priority app-masterworker app-pingpong app-token-ring async-wait async-waitany async-waitall plugin-hostload io mutex) @@ -32,6 +33,7 @@ endforeach() set(examples_src ${examples_src} PARENT_SCOPE) set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent.tesh ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord.tesh + ${CMAKE_CURRENT_SOURCE_DIR}/actor-priority/s4u-actor-priority.tesh ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime.tesh ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/s4u-async-wait.tesh ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u-async-waitany.tesh @@ -42,6 +44,7 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-a ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/actions-storage/s4u-actions-storage_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-actor-create_d.xml + ${CMAKE_CURRENT_SOURCE_DIR}/actor-priority/s4u-actor-priority_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/s4u-app-masterworker_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u-async-waitany_d.xml @@ -59,7 +62,7 @@ set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-a foreach(example actions-comm actions-storage actor-create actor-daemon actor-execute actor-kill actor-lifetime actor-migration actor-suspend app-bittorrent app-masterworker app-pingpong app-token-ring - async-wait async-waitall async-waitany + async-wait async-waitall async-waitany actor-priority 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 a3763fb427..96691c5b7f 100644 --- a/examples/s4u/README.doc +++ b/examples/s4u/README.doc @@ -82,6 +82,11 @@ documentation, but it should remain readable directly. Actors can be suspended and resumed during their executions thanks to the @ref suspend and @ref resume methods. + - Priority actors. + @ref examples/s4u/actor-priority/s4u-actor-priority.cpp \n + Actors can be launched according their priorities thanks to the @ref + execution method. + - Kill actors. @ref examples/s4u/actor-kill/s4u-actor-kill.cpp \n Actors can forcefully stop other actors with the @ref kill method. diff --git a/examples/s4u/actor-priority/s4u-actor-priority.cpp b/examples/s4u/actor-priority/s4u-actor-priority.cpp new file mode 100644 index 0000000000..1564f7e746 --- /dev/null +++ b/examples/s4u/actor-priority/s4u-actor-priority.cpp @@ -0,0 +1,45 @@ +/* Copyright (c) 2007-2016. 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 + +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); + +class test { + double computation_amount; + double priority; + +public: + explicit test(std::vector args) +{ + computation_amount = std::stod(args[1]); + priority = std::stod(args[2]); +} +void operator()() +{ + XBT_INFO("Hello! Running an actor of size %g with priority %g", computation_amount, priority); + simgrid::s4u::this_actor::execute(computation_amount, priority); + + XBT_INFO("Goodbye now!"); +} +}; + +int main(int argc, char *argv[]) +{ + simgrid::s4u::Engine e(&argc, argv); + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + + e.registerFunction("test"); + + e.loadPlatform(argv[1]); + e.loadDeployment(argv[2]); + + e.run(); + + return 0; +} diff --git a/examples/s4u/actor-priority/s4u-actor-priority.tesh b/examples/s4u/actor-priority/s4u-actor-priority.tesh new file mode 100644 index 0000000000..82916b37d3 --- /dev/null +++ b/examples/s4u/actor-priority/s4u-actor-priority.tesh @@ -0,0 +1,8 @@ +#! ./tesh + +! output sort 19 +$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-priority$EXEEXT ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../s4u/actor-priority/s4u-actor-priority_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +> [ 0.000000] (1:test@Fafard) Hello! Running an actor of size 7.6296e+07 with priority 1 +> [ 0.000000] (2:test@Fafard) Hello! Running an actor of size 7.6296e+07 with priority 2 +> [ 1.500000] (2:test@Fafard) Goodbye now! +> [ 2.000000] (1:test@Fafard) Goodbye now! diff --git a/examples/s4u/actor-priority/s4u-actor-priority_d.xml b/examples/s4u/actor-priority/s4u-actor-priority_d.xml new file mode 100644 index 0000000000..5d15f2b87f --- /dev/null +++ b/examples/s4u/actor-priority/s4u-actor-priority_d.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 210baad3b4..facaf0a59e 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -303,29 +303,32 @@ XBT_ATTRIB_DEPRECATED_v320("Use sleep_for(): v3.20 will turn this warning into a /** Block the actor, computing the given amount of flops */ XBT_PUBLIC(void) execute(double flop); -/** Block the actor until it gets a message from the given mailbox. - * - * See \ref Comm for the full communication API (including non blocking communications). - */ -XBT_PUBLIC(void*) -XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::get(): v3.20 will turn this warning into an error.") recv(MailboxPtr chan); -XBT_PUBLIC(void*) -XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::get(): v3.20 will turn this warning into an error.") - recv(MailboxPtr chan, double timeout); -XBT_PUBLIC(CommPtr) -XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::recv_async(): v3.20 will turn this warning into an error.") - irecv(MailboxPtr chan, void** data); + /** Block the actor, computing the given amount of flops and priority */ + XBT_PUBLIC(void) execute(double flop, double priority); -/** Block the actor until it delivers a message of the given simulated size to the given mailbox - * - * See \ref Comm for the full communication API (including non blocking communications). -*/ -XBT_PUBLIC(void) -XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::put(): v3.20 will turn this warning into an error.") - send(MailboxPtr chan, void* payload, double simulatedSize); // 3.17 -XBT_PUBLIC(void) -XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::put(): v3.20 will turn this warning into an error.") - send(MailboxPtr chan, void* payload, double simulatedSize, double timeout); // 3.17 + /** Block the actor until it gets a message from the given mailbox. + * + * See \ref Comm for the full communication API (including non blocking communications). + */ + XBT_PUBLIC(void*) + XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::get(): v3.20 will turn this warning into an error.") recv(MailboxPtr chan); + XBT_PUBLIC(void*) + XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::get(): v3.20 will turn this warning into an error.") + recv(MailboxPtr chan, double timeout); + XBT_PUBLIC(CommPtr) + XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::recv_async(): v3.20 will turn this warning into an error.") + irecv(MailboxPtr chan, void** data); + + /** Block the actor until it delivers a message of the given simulated size to the given mailbox + * + * See \ref Comm for the full communication API (including non blocking communications). + */ + XBT_PUBLIC(void) + XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::put(): v3.20 will turn this warning into an error.") + send(MailboxPtr chan, void* payload, double simulatedSize); // 3.17 + XBT_PUBLIC(void) + XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::put(): v3.20 will turn this warning into an error.") + send(MailboxPtr chan, void* payload, double simulatedSize, double timeout); // 3.17 XBT_PUBLIC(CommPtr) XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::put_async(): v3.20 will turn this warning into an error.") diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 80f0c11c78..1553bb9313 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -227,6 +227,12 @@ void execute(double flops) simcall_execution_wait(s); } +void execute(double flops,double priority) +{ + smx_activity_t s = simcall_execution_start(nullptr,flops,1 / priority/*priority*/,0./*bound*/); + simcall_execution_wait(s); +} + void* recv(MailboxPtr chan) // deprecated { return chan->get();