From: Yann Duplouy Date: Mon, 27 Apr 2020 17:09:07 +0000 (+0200) Subject: Merge branch 'random_readwritestate' into 'master' X-Git-Tag: v3.26~641 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/56651d7c6d0cc1c2108ca0d8de7e34462acd0514?hp=c34969e89c1e480aaab7d7fb40fdfe025e30a30d Merge branch 'random_readwritestate' into 'master' [xbt/random] Read/Write the state of the RNG See merge request simgrid/simgrid!36 --- diff --git a/.mailmap b/.mailmap index c1668575ba..0eeaab3430 100644 --- a/.mailmap +++ b/.mailmap @@ -18,6 +18,7 @@ Henri Casanova Henri Casanova Henri Casanova Henri Casanova +Henri Casanova Stéphane Castelli Stéphane Castelli Fabien Chaix @@ -48,7 +49,8 @@ Darina Dimitrova Bruno Donassolo Yann Duplouy Pierre-François Dutot -Julien Emmanuel +Julien Emmanuel +Julien Emmanuel Lionel Eyraud-Dubois Lionel Eyraud-Dubois Lionel Eyraud-Dubois diff --git a/ChangeLog b/ChangeLog index 416340d0de..4f77382963 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,17 +27,22 @@ C interface: - Many MSG tests were converted to the new S4U's interface in C, that was extended for that. +Simix: + - Remove obsolete option --cfg=contexts/parallel-threshold. + Fixed bugs (FG#.. -> FramaGit bugs; FG!.. -> FG merge requests) (FG: issues on Framagit; GF: issues on GForge; GH: issues on GitHub) - FG#41: Add sg_actor_create C interface - FG#43: xbt::random needs some care - FG#48: The Impossible Did Happen (yet again) - FG!24: Documentation and fix for xbt/random + - FG!35: Add a modeling hint for parallel links in doc - GF#18137: Allow different stack sizes? - GH#128: Parallelization of simulation with --cfg=contexts/nthreads - GH#139: Allow pthread creation in SMPI - GH#336: Packet-level simulation using SMPI? - GH!337: Fix link_energy plugin for wifi platforms + - GH!339: Add Mailbox set_receiver method to python binding ---------------------------------------------------------------------------- @@ -560,7 +565,7 @@ Plugins: - Rename Energy plugin into host_energy - Rename Load plugin into host_load -simix: +Simix: - Add parameter --cfg=simix/breakpoint to raise a SIGTRAP at given time. - kill simix::onDeadlock() that was somewhat dupplicating s4u::on_deadlock() - Improve performance when handling timeouts of simix synchros. diff --git a/docs/source/Configuring_SimGrid.rst b/docs/source/Configuring_SimGrid.rst index 17654ef962..e3689ec53a 100644 --- a/docs/source/Configuring_SimGrid.rst +++ b/docs/source/Configuring_SimGrid.rst @@ -87,7 +87,6 @@ Existing Configuration Items - **contexts/factory:** :ref:`cfg=contexts/factory` - **contexts/guard-size:** :ref:`cfg=contexts/guard-size` - **contexts/nthreads:** :ref:`cfg=contexts/nthreads` -- **contexts/parallel-threshold:** :ref:`cfg=contexts/parallel-threshold` - **contexts/stack-size:** :ref:`cfg=contexts/stack-size` - **contexts/synchro:** :ref:`cfg=contexts/synchro` @@ -832,7 +831,6 @@ on other parts of the memory if their size is too small for the application. .. _cfg=contexts/nthreads: -.. _cfg=contexts/parallel-threshold: .. _cfg=contexts/synchro: Running User Code in Parallel @@ -850,17 +848,6 @@ run. To activate this, set the ``contexts/nthreads`` item to the amount of cores that you have in your computer (or lower than 1 to have the amount of cores auto-detected). -Even if you asked several worker threads using the previous option, -you can request to start the parallel execution (and pay the -associated synchronization costs) only if the potential parallelism is -large enough. For that, set the ``contexts/parallel-threshold`` -item to the minimal amount of user contexts needed to start the -parallel execution. In any given simulation round, if that amount is -not reached, the contexts will be run sequentially directly by the -main thread (thus saving the synchronization costs). Note that this -option is mainly useful when the grain of the user code is very fine, -because our synchronization is now very efficient. - When parallel execution is activated, you can choose the synchronization schema used with the ``contexts/synchro`` item, which value is either: diff --git a/docs/source/platform_howtos.rst b/docs/source/platform_howtos.rst index 0cd01b449e..2a135eaaf3 100644 --- a/docs/source/platform_howtos.rst +++ b/docs/source/platform_howtos.rst @@ -183,6 +183,68 @@ period and another one for the shutdown period. Of course, this is only one possible way to model these things. YMMV ;) +.. _howto_parallel_links: + +Modeling parallel links +*********************** + +Most HPC topologies, such as fat-trees, allow parallel links (a +router A and a router B can be connected by more than one link). +You might be tempted to model this configuration as follows : + +.. code-block:: xml + + + + + + + + + + + + + + +But that will not work, since SimGrid doesn't allow several routes for +a single `{src ; dst}` pair. Instead, what you should do is : + + - Use a single route with both links (so both will be traversed + each time a message is exchanged between router A and B) + + - Double the bandwidth of one link, to model the total bandwidth of + both links used in parallel. This will make sure no combined + communications between router A and B use more than the bandwidth + of two links + + - Assign the other link a `FATPIPE` sharing policy, which will allow + several communications to use the full bandwidth of this link without + having to share it. This will model the fact that individual + communications can use at most this link's bandwidth + + - Set the latency of one of the links to 0, so that latency is only + accounted for once (since both link are traversed by each message) + +So the final platform for our example becomes : + +.. code-block:: xml + + + + + + + + + + + + + + + + .. _understanding_lv08 Understanding the default TCP model diff --git a/examples/deprecated/msg/trace-process-migration/trace-process-migration.tesh b/examples/deprecated/msg/trace-process-migration/trace-process-migration.tesh index 319a3e6509..772f8718cc 100644 --- a/examples/deprecated/msg/trace-process-migration/trace-process-migration.tesh +++ b/examples/deprecated/msg/trace-process-migration/trace-process-migration.tesh @@ -252,17 +252,16 @@ $ tail -n +3 procmig.trace > 5 11 7 send "0 0 1" > 5 12 7 execute "0 1 1" > 4 13 0 6 6 ACTOR_LINK -> 4 14 0 6 6 ACTOR_TASK_LINK > 6 0.000000 33 6 1 "policeman-2" > 12 0.000000 7 32 9 -> 15 0.000000 14 0 SR 33 p0 +> 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 14 0 SR 33 p1 +> 15 2.025708 13 0 SR 33 p1 > 12 2.025708 7 33 11 -> 16 2.025708 14 0 SR 32 p0 +> 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" @@ -271,9 +270,9 @@ $ tail -n +3 procmig.trace > 13 4.025708 7 34 > 12 4.025708 7 34 10 > 13 4.025903 7 33 -> 15 4.025903 14 0 SR 33 p2 +> 15 4.025903 13 0 SR 33 p2 > 12 4.025903 7 33 11 -> 16 4.025903 14 0 SR 34 p1 +> 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" @@ -282,9 +281,9 @@ $ tail -n +3 procmig.trace > 13 6.025903 7 35 > 12 6.025903 7 35 10 > 13 6.044918 7 33 -> 15 6.044918 14 0 SR 33 p3 +> 15 6.044918 13 0 SR 33 p3 > 12 6.044918 7 33 11 -> 16 6.044918 14 0 SR 35 p2 +> 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" @@ -293,9 +292,9 @@ $ tail -n +3 procmig.trace > 13 8.044918 7 36 > 12 8.044918 7 36 10 > 13 8.070626 7 33 -> 15 8.070626 14 0 SR 33 p4 +> 15 8.070626 13 0 SR 33 p4 > 12 8.070626 7 33 11 -> 16 8.070626 14 0 SR 36 p3 +> 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" @@ -304,9 +303,9 @@ $ tail -n +3 procmig.trace > 13 10.070626 7 37 > 12 10.070626 7 37 10 > 13 10.087178 7 33 -> 15 10.087178 14 0 SR 33 p5 +> 15 10.087178 13 0 SR 33 p5 > 12 10.087178 7 33 11 -> 16 10.087178 14 0 SR 37 p4 +> 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" @@ -315,9 +314,9 @@ $ tail -n +3 procmig.trace > 13 12.087178 7 38 > 12 12.087178 7 38 10 > 13 12.112617 7 33 -> 15 12.112617 14 0 SR 33 p6 +> 15 12.112617 13 0 SR 33 p6 > 12 12.112617 7 33 11 -> 16 12.112617 14 0 SR 38 p5 +> 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" @@ -326,9 +325,9 @@ $ tail -n +3 procmig.trace > 13 14.112617 7 39 > 12 14.112617 7 39 10 > 13 14.138325 7 33 -> 15 14.138325 14 0 SR 33 p7 +> 15 14.138325 13 0 SR 33 p7 > 12 14.138325 7 33 11 -> 16 14.138325 14 0 SR 39 p6 +> 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" @@ -337,9 +336,9 @@ $ tail -n +3 procmig.trace > 13 16.138325 7 40 > 12 16.138325 7 40 10 > 13 16.138521 7 33 -> 15 16.138521 14 0 SR 33 p8 +> 15 16.138521 13 0 SR 33 p8 > 12 16.138521 7 33 11 -> 16 16.138521 14 0 SR 40 p7 +> 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" @@ -348,7 +347,7 @@ $ tail -n +3 procmig.trace > 13 18.138521 7 41 > 12 18.138521 7 41 10 > 13 18.155073 7 33 -> 16 18.155073 14 0 SR 41 p8 +> 16 18.155073 13 0 SR 41 p8 > 7 18.155073 6 33 > 7 18.155073 6 41 > 7 18.155073 2 16 diff --git a/examples/s4u/dht-kademlia/answer.cpp b/examples/s4u/dht-kademlia/answer.cpp index 7fa86551fd..6d5515cc76 100644 --- a/examples/s4u/dht-kademlia/answer.cpp +++ b/examples/s4u/dht-kademlia/answer.cpp @@ -65,9 +65,9 @@ void Answer::addBucket(const Bucket* bucket) { xbt_assert((bucket != nullptr), "Provided a NULL bucket"); - for (auto const& id : bucket->nodes) { + for (auto const& id : bucket->nodes_) { unsigned int distance = id ^ destination_id_; nodes_.push_back(std::pair(id, distance)); } } -} +} // namespace kademlia diff --git a/examples/s4u/dht-kademlia/answer.hpp b/examples/s4u/dht-kademlia/answer.hpp index 34896d679a..de5e1c9e83 100644 --- a/examples/s4u/dht-kademlia/answer.hpp +++ b/examples/s4u/dht-kademlia/answer.hpp @@ -29,6 +29,6 @@ public: bool destinationFound() const; void addBucket(const kademlia::Bucket* bucket); }; -} +} // namespace kademlia #endif diff --git a/examples/s4u/dht-kademlia/message.hpp b/examples/s4u/dht-kademlia/message.hpp index 35ec478e58..15f5e5fb87 100644 --- a/examples/s4u/dht-kademlia/message.hpp +++ b/examples/s4u/dht-kademlia/message.hpp @@ -38,5 +38,5 @@ public: Message(const Message&) = delete; Message& operator=(const Message&) = delete; }; -} +} // namespace kademlia #endif diff --git a/examples/s4u/dht-kademlia/node.cpp b/examples/s4u/dht-kademlia/node.cpp index fc2a7e481f..d331cc361b 100644 --- a/examples/s4u/dht-kademlia/node.cpp +++ b/examples/s4u/dht-kademlia/node.cpp @@ -122,19 +122,19 @@ void Node::routingTableUpdate(unsigned int id) Bucket* bucket = table.findBucket(id); // check if the id is already in the bucket. - auto id_pos = std::find(bucket->nodes.begin(), bucket->nodes.end(), id); + auto id_pos = std::find(bucket->nodes_.begin(), bucket->nodes_.end(), id); - if (id_pos == bucket->nodes.end()) { + if (id_pos == bucket->nodes_.end()) { /* We check if the bucket is full or not. If it is, we evict an old element */ - if (bucket->nodes.size() >= BUCKET_SIZE) { - bucket->nodes.pop_back(); + if (bucket->nodes_.size() >= BUCKET_SIZE) { + bucket->nodes_.pop_back(); } - bucket->nodes.push_front(id); + bucket->nodes_.push_front(id); XBT_VERB("I'm adding to my routing table %08x", id); } else { // We push the element to the front - bucket->nodes.erase(id_pos); - bucket->nodes.push_front(id); + bucket->nodes_.erase(id_pos); + bucket->nodes_.push_front(id); XBT_VERB("I'm updating %08x", id); } } @@ -159,12 +159,12 @@ Answer* Node::findClosest(unsigned int destination_id) for (int i = 1; answer->getSize() < BUCKET_SIZE && ((bucket_id - i > 0) || (bucket_id + i < IDENTIFIER_SIZE)); i++) { /* We check the previous buckets */ if (bucket_id - i >= 0) { - const Bucket* bucket_p = &table.buckets[bucket_id - i]; + const Bucket* bucket_p = &table.getBucketAt(bucket_id - i); answer->addBucket(bucket_p); } /* We check the next buckets */ if (bucket_id + i <= IDENTIFIER_SIZE) { - const Bucket* bucket_n = &table.buckets[bucket_id + i]; + const Bucket* bucket_n = &table.getBucketAt(bucket_id + i); answer->addBucket(bucket_n); } } @@ -280,7 +280,12 @@ void Node::handleFindNode(const Message* msg) // Sending the answer msg->answer_to_->put_init(answer, 1)->detach(kademlia::destroy); } + +void Node::displaySuccessRate() +{ + XBT_INFO("%u/%u FIND_NODE have succeeded", find_node_success, find_node_success + find_node_failed); } +} // namespace kademlia /**@brief Returns an identifier which is in a specific bucket of a routing table * @param id id of the routing table owner * @param prefix id of the bucket where we want that identifier to be diff --git a/examples/s4u/dht-kademlia/node.hpp b/examples/s4u/dht-kademlia/node.hpp index dc36ae20fb..ab64fa7252 100644 --- a/examples/s4u/dht-kademlia/node.hpp +++ b/examples/s4u/dht-kademlia/node.hpp @@ -16,11 +16,11 @@ namespace kademlia { class Node { unsigned int id_; // node id - 160 bits RoutingTable table; // node routing table + unsigned int find_node_success = 0; // Number of find_node which have succeeded. + unsigned int find_node_failed = 0; // Number of find_node which have failed. public: simgrid::s4u::CommPtr receive_comm = nullptr; void* received_msg = nullptr; - unsigned int find_node_success = 0; // Number of find_node which have succeeded. - unsigned int find_node_failed = 0; // Number of find_node which have failed. explicit Node(unsigned int node_id) : id_(node_id), table(node_id) {} Node(const Node&) = delete; Node& operator=(const Node&) = delete; @@ -34,8 +34,9 @@ public: bool findNode(unsigned int id_to_find, bool count_in_stats); void randomLookup(); void handleFindNode(const Message* msg); + void displaySuccessRate(); }; -} +} // namespace kademlia // identifier functions unsigned int get_id_in_prefix(unsigned int id, unsigned int prefix); unsigned int get_node_prefix(unsigned int id, unsigned int nb_bits); diff --git a/examples/s4u/dht-kademlia/routing_table.cpp b/examples/s4u/dht-kademlia/routing_table.cpp index c94ae3c01f..3bd9e5eda1 100644 --- a/examples/s4u/dht-kademlia/routing_table.cpp +++ b/examples/s4u/dht-kademlia/routing_table.cpp @@ -14,9 +14,9 @@ namespace kademlia { /** @brief Initialization of a node routing table. */ RoutingTable::RoutingTable(unsigned int node_id) : id_(node_id) { - buckets.reserve(IDENTIFIER_SIZE + 1); + buckets_.reserve(IDENTIFIER_SIZE + 1); for (unsigned int i = 0; i < IDENTIFIER_SIZE + 1; i++) - buckets.emplace_back(i); + buckets_.emplace_back(i); } void RoutingTable::print() const @@ -24,10 +24,10 @@ void RoutingTable::print() const XBT_INFO("Routing table of %08x:", id_); for (unsigned int i = 0; i <= IDENTIFIER_SIZE; i++) { - if (not buckets[i].nodes.empty()) { + if (not buckets_[i].nodes_.empty()) { XBT_INFO("Bucket number %u: ", i); int j = 0; - for (auto value : buckets[i].nodes) { + for (auto value : buckets_[i].nodes_) { XBT_INFO("Element %d: %08x", j, value); j++; } @@ -44,13 +44,13 @@ Bucket* RoutingTable::findBucket(unsigned int id) unsigned int xor_number = id_ ^ id; unsigned int prefix = get_node_prefix(xor_number, IDENTIFIER_SIZE); xbt_assert(prefix <= IDENTIFIER_SIZE, "Tried to return a bucket that doesn't exist."); - return &buckets[prefix]; + return &buckets_[prefix]; } /** Returns if the routing table contains the id. */ bool RoutingTable::contains(unsigned int node_id) { const Bucket* bucket = findBucket(node_id); - return std::find(bucket->nodes.begin(), bucket->nodes.end(), node_id) != bucket->nodes.end(); -} + return std::find(bucket->nodes_.begin(), bucket->nodes_.end(), node_id) != bucket->nodes_.end(); } +} // namespace kademlia diff --git a/examples/s4u/dht-kademlia/routing_table.hpp b/examples/s4u/dht-kademlia/routing_table.hpp index 1c609d4cec..dda6217439 100644 --- a/examples/s4u/dht-kademlia/routing_table.hpp +++ b/examples/s4u/dht-kademlia/routing_table.hpp @@ -16,7 +16,7 @@ namespace kademlia { class Bucket { unsigned int id_; // bucket id public: - std::deque nodes; // Nodes in the bucket. + std::deque nodes_; // Nodes in the bucket. unsigned int getId() const { return id_; } explicit Bucket(unsigned int id) noexcept : id_(id) {} }; @@ -24,15 +24,16 @@ public: /* Node routing table */ class RoutingTable { unsigned int id_; // node id of the client's routing table + std::vector buckets_; // Node bucket list public: - std::vector buckets; // Node bucket list - 160 sized. explicit RoutingTable(unsigned int node_id); RoutingTable(const RoutingTable&) = delete; RoutingTable& operator=(const RoutingTable&) = delete; void print() const; Bucket* findBucket(unsigned int id); + const Bucket& getBucketAt(unsigned int pos) const { return buckets_[pos]; } bool contains(unsigned int node_id); }; -} +} // namespace kademlia #endif diff --git a/examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp b/examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp index ac5231cf8a..c38206c99c 100644 --- a/examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp +++ b/examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp @@ -75,7 +75,7 @@ static void node(int argc, char* argv[]) XBT_INFO("I couldn't join the network :("); } XBT_DEBUG("I'm leaving the network"); - XBT_INFO("%u/%u FIND_NODE have succeeded", node.find_node_success, node.find_node_success + node.find_node_failed); + node.displaySuccessRate(); } /** @brief Main function */ diff --git a/examples/s4u/dht-kademlia/s4u-dht-kademlia.hpp b/examples/s4u/dht-kademlia/s4u-dht-kademlia.hpp index c1fae1712c..347f4d6190 100644 --- a/examples/s4u/dht-kademlia/s4u-dht-kademlia.hpp +++ b/examples/s4u/dht-kademlia/s4u-dht-kademlia.hpp @@ -12,7 +12,7 @@ namespace kademlia { class Answer; class Message; -} +} // namespace kademlia constexpr double FIND_NODE_TIMEOUT = 10.0; constexpr double FIND_NODE_GLOBAL_TIMEOUT = 50.0; diff --git a/examples/smpi/replay/replay-override-replayer.tesh b/examples/smpi/replay/replay-override-replayer.tesh index 2a7b050fd2..8bb2014364 100644 --- a/examples/smpi/replay/replay-override-replayer.tesh +++ b/examples/smpi/replay/replay-override-replayer.tesh @@ -155,53 +155,59 @@ $ tail -n +3 ./simgrid_override.trace > 6 0.000000 1 1 0 "rank-0" > 6 0.000000 2 1 0 "rank-1" > 6 0.000000 3 1 0 "rank-2" -> 5 6 2 computing "0 1 1" -> 5 7 2 smpi_replay_run_init "0 1 0" +> 5 6 2 smpi_replay_run_init "0 1 0" +> 5 7 2 computing "0 1 1" > 5 8 2 action_bcast "0 0.78 0.39" -> 12 0.000000 2 1 7 +> 12 0.000000 2 1 6 > 13 0.000000 2 1 -> 12 0.000000 2 2 7 +> 12 0.000000 2 2 6 > 13 0.000000 2 2 -> 12 0.000000 2 3 7 +> 12 0.000000 2 3 6 > 13 0.000000 2 3 > 12 0.000000 2 1 8 > 12 0.000000 2 2 8 > 12 0.000000 2 3 8 > 13 0.000000 2 1 -> 12 0.000000 2 1 6 +> 12 0.000000 2 1 7 > 5 9 2 action_reduce "0 1 0" > 5 10 2 smpi_replay_run_finalize "0 1 0" > 13 0.015036 2 2 -> 12 0.015036 2 2 6 +> 12 0.015036 2 2 7 > 13 0.015676 2 3 -> 12 0.015676 2 3 6 +> 12 0.015676 2 3 7 > 13 2.636405 2 2 > 12 2.636405 2 2 8 > 13 5.097100 2 1 > 12 5.097100 2 1 8 > 13 5.097100 2 1 -> 12 5.097100 2 1 6 +> 12 5.097100 2 1 7 > 13 5.112136 2 2 -> 12 5.112136 2 2 6 +> 12 5.112136 2 2 7 > 13 6.569099 2 3 > 12 6.569099 2 3 8 > 13 6.584775 2 3 -> 12 6.584775 2 3 6 +> 12 6.584775 2 3 7 > 13 7.733505 2 2 > 12 7.733505 2 2 9 +> 12 7.733505 2 2 7 > 13 10.194200 2 1 > 12 10.194200 2 1 9 > 13 13.138198 2 3 > 12 13.138198 2 3 9 +> 12 13.138198 2 3 7 +> 12 13.153874 2 1 7 +> 13 14.286929 2 2 > 13 14.286929 2 2 > 12 14.286929 2 2 10 > 13 14.286929 2 2 > 7 14.286929 1 2 > 13 18.250974 2 1 +> 13 18.250974 2 1 > 12 18.250974 2 1 10 > 13 18.250974 2 1 > 7 18.250974 1 1 > 13 19.691622 2 3 +> 13 19.691622 2 3 > 12 19.691622 2 3 10 > 13 19.691622 2 3 > 7 19.691622 1 3 diff --git a/examples/smpi/replay/replay.tesh b/examples/smpi/replay/replay.tesh index da20f7b41e..afcf6444b8 100644 --- a/examples/smpi/replay/replay.tesh +++ b/examples/smpi/replay/replay.tesh @@ -155,53 +155,59 @@ $ tail -n +3 ./simgrid.trace > 6 0.000000 1 1 0 "rank-0" > 6 0.000000 2 1 0 "rank-1" > 6 0.000000 3 1 0 "rank-2" -> 5 6 2 computing "0 1 1" -> 5 7 2 smpi_replay_run_init "0 1 0" +> 5 6 2 smpi_replay_run_init "0 1 0" +> 5 7 2 computing "0 1 1" > 5 8 2 action_bcast "0 0.78 0.39" -> 12 0.000000 2 1 7 +> 12 0.000000 2 1 6 > 13 0.000000 2 1 -> 12 0.000000 2 2 7 +> 12 0.000000 2 2 6 > 13 0.000000 2 2 -> 12 0.000000 2 3 7 +> 12 0.000000 2 3 6 > 13 0.000000 2 3 > 12 0.000000 2 1 8 > 12 0.000000 2 2 8 > 12 0.000000 2 3 8 > 13 0.000000 2 1 -> 12 0.000000 2 1 6 +> 12 0.000000 2 1 7 > 5 9 2 action_reduce "0 1 0" > 5 10 2 smpi_replay_run_finalize "0 1 0" > 13 0.015036 2 2 -> 12 0.015036 2 2 6 +> 12 0.015036 2 2 7 > 13 0.015676 2 3 -> 12 0.015676 2 3 6 +> 12 0.015676 2 3 7 > 13 2.636405 2 2 > 12 2.636405 2 2 8 > 13 5.097100 2 1 > 12 5.097100 2 1 8 > 13 5.097100 2 1 -> 12 5.097100 2 1 6 +> 12 5.097100 2 1 7 > 13 5.112136 2 2 -> 12 5.112136 2 2 6 +> 12 5.112136 2 2 7 > 13 6.569099 2 3 > 12 6.569099 2 3 8 > 13 6.584775 2 3 -> 12 6.584775 2 3 6 +> 12 6.584775 2 3 7 > 13 7.733505 2 2 > 12 7.733505 2 2 9 +> 12 7.733505 2 2 7 > 13 10.194200 2 1 > 12 10.194200 2 1 9 > 13 13.138198 2 3 > 12 13.138198 2 3 9 +> 12 13.138198 2 3 7 +> 12 13.153874 2 1 7 +> 13 14.286929 2 2 > 13 14.286929 2 2 > 12 14.286929 2 2 10 > 13 14.286929 2 2 > 7 14.286929 1 2 > 13 18.250974 2 1 +> 13 18.250974 2 1 > 12 18.250974 2 1 10 > 13 18.250974 2 1 > 7 18.250974 1 1 > 13 19.691622 2 3 +> 13 19.691622 2 3 > 12 19.691622 2 3 10 > 13 19.691622 2 3 > 7 19.691622 1 3 diff --git a/include/simgrid/kernel/routing/NetPoint.hpp b/include/simgrid/kernel/routing/NetPoint.hpp index 39b74e3fb5..f73bfd582e 100644 --- a/include/simgrid/kernel/routing/NetPoint.hpp +++ b/include/simgrid/kernel/routing/NetPoint.hpp @@ -24,7 +24,7 @@ namespace routing { * * @details This represents a position in the network. One can send information between two netpoints */ -class NetPoint : public simgrid::xbt::Extendable { +class NetPoint : public xbt::Extendable { public: enum class Type { Host, Router, NetZone }; @@ -42,7 +42,7 @@ public: bool is_host() const { return component_type_ == Type::Host; } bool is_router() const { return component_type_ == Type::Router; } - static simgrid::xbt::signal on_creation; + static xbt::signal on_creation; bool operator<(const NetPoint& rhs) const { return name_ < rhs.name_; } diff --git a/include/simgrid/link.h b/include/simgrid/link.h index 4c4cf86994..115e64aea5 100644 --- a/include/simgrid/link.h +++ b/include/simgrid/link.h @@ -17,7 +17,9 @@ XBT_PUBLIC const char* sg_link_name(const_sg_link_t link); XBT_PUBLIC sg_link_t sg_link_by_name(const char* name); XBT_PUBLIC int sg_link_is_shared(const_sg_link_t link); XBT_PUBLIC double sg_link_bandwidth(const_sg_link_t link); +XBT_PUBLIC void sg_link_bandwidth_set(sg_link_t link, double value); XBT_PUBLIC double sg_link_latency(const_sg_link_t link); +XBT_PUBLIC void sg_link_latency_set(sg_link_t link, double value); XBT_PUBLIC void* sg_link_data(const_sg_link_t link); XBT_PUBLIC void sg_link_data_set(sg_link_t link, void* data); XBT_PUBLIC int sg_link_count(); diff --git a/include/simgrid/s4u/Link.hpp b/include/simgrid/s4u/Link.hpp index 4fa04e8b26..d5d13bba1d 100644 --- a/include/simgrid/s4u/Link.hpp +++ b/include/simgrid/s4u/Link.hpp @@ -54,9 +54,11 @@ public: /** @brief Get the bandwidth in bytes per second of current Link */ double get_bandwidth() const; + void set_bandwidth(double value); /** @brief Get the latency in seconds of current Link */ double get_latency() const; + void set_latency(double value); /** @brief Describes how the link is shared between flows */ SharingPolicy get_sharing_policy() const; diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 9264bf53c1..749b0a7188 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -29,8 +29,6 @@ XBT_PUBLIC smx_actor_t SIMIX_process_from_PID(aid_t PID); XBT_PUBLIC int SIMIX_context_is_parallel(); XBT_PUBLIC int SIMIX_context_get_nthreads(); XBT_PUBLIC void SIMIX_context_set_nthreads(int nb_threads); -XBT_PUBLIC int SIMIX_context_get_parallel_threshold(); -XBT_PUBLIC void SIMIX_context_set_parallel_threshold(int threshold); XBT_PUBLIC e_xbt_parmap_mode_t SIMIX_context_get_parallel_mode(); XBT_PUBLIC void SIMIX_context_set_parallel_mode(e_xbt_parmap_mode_t mode); XBT_PUBLIC int SIMIX_is_maestro(); diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index af3d7583e4..670be45bc5 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -256,7 +256,13 @@ PYBIND11_MODULE(simgrid, m) // data.dec_ref(); // FIXME: why does it break python-actor-create? return data; }, - py::call_guard(), "Blocking data reception"); + py::call_guard(), "Blocking data reception") + .def("set_receiver", + [](Mailbox* self, ActorPtr actor) { + self->set_receiver(actor); + }, + py::call_guard(), + "Sets the actor as permanent receiver"); /* Class Comm */ py::class_(m, "Comm", "Communication") diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index 6bf9e2c0ca..7cad3f6a9f 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -31,17 +31,17 @@ Type::Type(e_event_type event_type, const std::string& name, const std::string& void StateType::set_event(const std::string& value_name) { - events_.push_back(new StateEvent(issuer_, this, PAJE_SetState, get_entity_value(value_name), nullptr)); + events_.push_back(new StateEvent(get_issuer(), this, PAJE_SetState, get_entity_value(value_name), nullptr)); } void StateType::push_event(const std::string& value_name, TIData* extra) { - events_.push_back(new StateEvent(issuer_, this, PAJE_PushState, get_entity_value(value_name), extra)); + events_.push_back(new StateEvent(get_issuer(), this, PAJE_PushState, get_entity_value(value_name), extra)); } void StateType::push_event(const std::string& value_name) { - events_.push_back(new StateEvent(issuer_, this, PAJE_PushState, get_entity_value(value_name), nullptr)); + events_.push_back(new StateEvent(get_issuer(), this, PAJE_PushState, get_entity_value(value_name), nullptr)); } void StateType::pop_event() @@ -51,7 +51,7 @@ void StateType::pop_event() void StateType::pop_event(TIData* extra) { - events_.push_back(new StateEvent(issuer_, this, PAJE_PopState, nullptr, extra)); + events_.push_back(new StateEvent(get_issuer(), this, PAJE_PopState, nullptr, extra)); } void VariableType::instr_event(double now, double delta, const char* resource, double value) @@ -76,17 +76,17 @@ void VariableType::instr_event(double now, double delta, const char* resource, d void VariableType::set_event(double timestamp, double value) { - events_.push_back(new VariableEvent(timestamp, issuer_, this, PAJE_SetVariable, value)); + events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PAJE_SetVariable, value)); } void VariableType::add_event(double timestamp, double value) { - events_.push_back(new VariableEvent(timestamp, issuer_, this, PAJE_AddVariable, value)); + events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PAJE_AddVariable, value)); } void VariableType::sub_event(double timestamp, double value) { - events_.push_back(new VariableEvent(timestamp, issuer_, this, PAJE_SubVariable, value)); + events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PAJE_SubVariable, value)); } void LinkType::start_event(Container* startContainer, const std::string& value, const std::string& key) @@ -96,12 +96,12 @@ void LinkType::start_event(Container* startContainer, const std::string& value, void LinkType::start_event(Container* startContainer, const std::string& value, const std::string& key, int size) { - new LinkEvent(issuer_, this, PAJE_StartLink, startContainer, value, key, size); + new LinkEvent(get_issuer(), this, PAJE_StartLink, startContainer, value, key, size); } void LinkType::end_event(Container* endContainer, const std::string& value, const std::string& key) { - new LinkEvent(issuer_, this, PAJE_EndLink, endContainer, value, key, -1); + new LinkEvent(get_issuer(), this, PAJE_EndLink, endContainer, value, key, -1); } Type* Type::by_name(const std::string& name) diff --git a/src/instr/instr_paje_types.hpp b/src/instr/instr_paje_types.hpp index 7d9fa60ee7..2ce289b7d7 100644 --- a/src/instr/instr_paje_types.hpp +++ b/src/instr/instr_paje_types.hpp @@ -21,11 +21,14 @@ class Type { std::string name_; std::string color_; Type* father_; + std::map> children_; + Container* issuer_ = nullptr; + +protected: + Container* get_issuer() const { return issuer_; } public: static xbt::signal on_creation; - std::map> children_; - Container* issuer_ = nullptr; Type(e_event_type event_type, const std::string& name, const std::string& alias, const std::string& color, Type* father); @@ -36,6 +39,7 @@ public: const char* get_cname() { return name_.c_str(); } const std::string& get_color() const { return color_; } Type* get_father() const { return father_; } + const std::map>& get_children() { return children_; } bool is_colored() { return not color_.empty(); } Type* by_name(const std::string& name); diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index 7889d9717c..b2d214c92a 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -161,7 +161,7 @@ static void recursiveNewVariableType(const std::string& new_typename, const std: if (root->get_name() == "LINK") root->by_name_or_create(std::string("b") + new_typename, color); - for (auto const& elm : root->children_) { + for (auto const& elm : root->get_children()) { recursiveNewVariableType(new_typename, color, elm.second.get()); } } @@ -177,7 +177,7 @@ static void recursiveNewUserVariableType(const std::string& father_type, const s if (root->get_name() == father_type) { root->by_name_or_create(new_typename, color); } - for (auto const& elm : root->children_) + for (auto const& elm : root->get_children()) recursiveNewUserVariableType(father_type, new_typename, color, elm.second.get()); } @@ -193,7 +193,7 @@ static void recursiveNewUserStateType(const std::string& father_type, const std: if (root->get_name() == father_type) root->by_name_or_create(new_typename); - for (auto const& elm : root->children_) + for (auto const& elm : root->get_children()) recursiveNewUserStateType(father_type, new_typename, elm.second.get()); } @@ -208,7 +208,7 @@ static void recursiveNewValueForUserStateType(const std::string& type_name, cons if (root->get_name() == type_name) static_cast(root)->add_entity_value(val, color); - for (auto const& elm : root->children_) + for (auto const& elm : root->get_children()) recursiveNewValueForUserStateType(type_name, val, color, elm.second.get()); } @@ -339,13 +339,6 @@ static void on_host_creation(s4u::Host const& host) } } -static void on_host_speed_change(s4u::Host const& host) -{ - Container::by_name(host.get_name()) - ->get_variable("speed") - ->set_event(surf_get_clock(), host.get_core_count() * host.get_available_speed()); -} - static void on_action_state_change(kernel::resource::Action const& action, kernel::resource::Action::State /* previous */) { @@ -369,19 +362,6 @@ static void on_action_state_change(kernel::resource::Action const& action, } } -static void on_link_bandwidth_change(s4u::Link const& link) -{ - Container::by_name(link.get_name()) - ->get_variable("bandwidth") - ->set_event(surf_get_clock(), sg_bandwidth_factor * link.get_bandwidth()); -} - -static void on_netpoint_creation(kernel::routing::NetPoint const& netpoint) -{ - if (netpoint.is_router()) - new RouterContainer(netpoint.get_name(), currentContainer.back()); -} - static void on_platform_created() { currentContainer.clear(); @@ -395,10 +375,11 @@ static void on_platform_created() static void on_actor_creation(s4u::Actor const& actor) { - const Container* root = Container::get_root(); - Container* container = Container::by_name(actor.get_host()->get_name()); + const Container* root = Container::get_root(); + Container* container = Container::by_name(actor.get_host()->get_name()); + std::string container_name = instr_pid(actor); - container->create_child(instr_pid(actor), "ACTOR"); + container->create_child(container_name, "ACTOR"); ContainerType* actor_type = container->type_->by_name_or_create("ACTOR"); StateType* state = actor_type->by_name_or_create("ACTOR_STATE"); state->add_entity_value("suspend", "1 0 1"); @@ -407,9 +388,7 @@ static void on_actor_creation(s4u::Actor const& actor) state->add_entity_value("send", "0 0 1"); state->add_entity_value("execute", "0 1 1"); root->type_->by_name_or_create("ACTOR_LINK", actor_type, actor_type); - root->type_->by_name_or_create("ACTOR_TASK_LINK", actor_type, actor_type); - std::string container_name = instr_pid(actor); actor.on_exit([container_name](bool failed) { if (failed) // kill means that this actor no longer exists, let's destroy it @@ -456,12 +435,24 @@ void define_callbacks() if (TRACE_needs_platform()) { s4u::Engine::on_platform_created.connect(on_platform_created); s4u::Host::on_creation.connect(on_host_creation); - s4u::Host::on_speed_change.connect(on_host_speed_change); + s4u::Host::on_speed_change.connect([](s4u::Host const& host) { + Container::by_name(host.get_name()) + ->get_variable("speed") + ->set_event(surf_get_clock(), host.get_core_count() * host.get_available_speed()); + }); s4u::Link::on_creation.connect(on_link_creation); - s4u::Link::on_bandwidth_change.connect(on_link_bandwidth_change); + s4u::Link::on_bandwidth_change.connect([](s4u::Link const& link) { + Container::by_name(link.get_name()) + ->get_variable("bandwidth") + ->set_event(surf_get_clock(), sg_bandwidth_factor * link.get_bandwidth()); + }); s4u::NetZone::on_seal.connect([](s4u::NetZone const& /*netzone*/) { currentContainer.pop_back(); }); - kernel::routing::NetPoint::on_creation.connect(on_netpoint_creation); + kernel::routing::NetPoint::on_creation.connect([](kernel::routing::NetPoint const& netpoint) { + if (netpoint.is_router()) + new RouterContainer(netpoint.get_name(), currentContainer.back()); + }); } + s4u::NetZone::on_creation.connect(on_netzone_creation); kernel::resource::CpuAction::on_state_change.connect(on_action_state_change); @@ -501,6 +492,17 @@ void define_callbacks() s4u::Actor::on_host_change.connect(on_actor_host_change); } + if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing()) { + s4u::Exec::on_start.connect([](simgrid::s4u::Actor const& actor, s4u::Exec const& exec) { + Container::by_name(std::string("rank-") + std::to_string(actor.get_pid())) + ->get_state("MPI_STATE") + ->push_event("computing", new CpuTIData("compute", exec.get_cost())); + }); + s4u::Exec::on_completion.connect([](s4u::Actor const& actor, s4u::Exec const&) { + Container::by_name(std::string("rank-") + std::to_string(actor.get_pid()))->get_state("MPI_STATE")->pop_event(); + }); + } + if (TRACE_vm_is_enabled()) { s4u::Host::on_creation.connect(on_vm_creation); s4u::VirtualMachine::on_start.connect([](s4u::VirtualMachine const& vm) { diff --git a/src/instr/instr_smpi.hpp b/src/instr/instr_smpi.hpp index a99c15f45c..1a9ecf9d7c 100644 --- a/src/instr/instr_smpi.hpp +++ b/src/instr/instr_smpi.hpp @@ -14,17 +14,14 @@ XBT_PRIVATE container_t smpi_container(int rank); XBT_PRIVATE void TRACE_smpi_setup_container(int rank, const_sg_host_t host); -XBT_PRIVATE void TRACE_smpi_computing_init(int rank); -XBT_PRIVATE void TRACE_smpi_computing_out(int rank); -XBT_PRIVATE void TRACE_smpi_computing_in(int rank, double amount); -XBT_PRIVATE void TRACE_smpi_sleeping_init(int rank); XBT_PRIVATE void TRACE_smpi_sleeping_out(int rank); XBT_PRIVATE void TRACE_smpi_sleeping_in(int rank, double duration); XBT_PRIVATE void TRACE_smpi_comm_in(int rank, const char* operation, simgrid::instr::TIData* extra); XBT_PRIVATE void TRACE_smpi_comm_out(int rank); XBT_PRIVATE void TRACE_smpi_send(int rank, int src, int dst, int tag, int size); XBT_PRIVATE void TRACE_smpi_recv(int src, int dst, int tag); -XBT_PRIVATE void TRACE_smpi_init(int rank); +XBT_PRIVATE void TRACE_smpi_init(int rank, std::string calling_func); + /* SMPI + LB (load balancer) */ XBT_PRIVATE void TRACE_smpi_process_change_host(int rank, const_sg_host_t new_host); diff --git a/src/kernel/resource/DiskImpl.hpp b/src/kernel/resource/DiskImpl.hpp index d536e0e8c2..962dd9f999 100644 --- a/src/kernel/resource/DiskImpl.hpp +++ b/src/kernel/resource/DiskImpl.hpp @@ -53,6 +53,8 @@ class DiskImpl : public Resource, public xbt::PropertyHolder { s4u::Disk piface_; double read_bw_; double write_bw_; + lmm::Constraint* constraint_write_; /* Constraint for maximum write bandwidth*/ + lmm::Constraint* constraint_read_; /* Constraint for maximum write bandwidth*/ public: DiskImpl(Model* model, const std::string& name, kernel::lmm::System* maxmin_system, double read_bw, double bwrite_bw); @@ -63,27 +65,24 @@ public: /** @brief Public interface */ s4u::Disk* get_iface() { return &piface_; } + s4u::Host* get_host() const { return host_; } + void set_host(s4u::Host* host) { host_ = host; } + double get_read_bandwidth() { return read_bw_; } double get_write_bandwidth() { return write_bw_; } + lmm::Constraint* get_read_constraint() const { return constraint_read_; } + lmm::Constraint* get_write_constraint() const { return constraint_write_; } /** @brief Check if the Storage is used (if an action currently uses its resources) */ bool is_used() override; - void apply_event(profile::Event* event, double value) override; - void turn_on() override; void turn_off() override; - s4u::Host* get_host() const { return host_; } - void set_host(s4u::Host* host) { host_ = host; } - void destroy(); // Must be called instead of the destructor virtual DiskAction* io_start(sg_size_t size, s4u::Io::OpType type) = 0; virtual DiskAction* read(sg_size_t size) = 0; virtual DiskAction* write(sg_size_t size) = 0; - - lmm::Constraint* constraint_write_; /* Constraint for maximum write bandwidth*/ - lmm::Constraint* constraint_read_; /* Constraint for maximum write bandwidth*/ }; /********** diff --git a/src/mc/checker/Checker.hpp b/src/mc/checker/Checker.hpp index c9ff8336ef..070a779ea5 100644 --- a/src/mc/checker/Checker.hpp +++ b/src/mc/checker/Checker.hpp @@ -65,7 +65,8 @@ protected: XBT_PUBLIC Checker* createLivenessChecker(Session& session); XBT_PUBLIC Checker* createSafetyChecker(Session& session); XBT_PUBLIC Checker* createCommunicationDeterminismChecker(Session& session); -} -} + +} // namespace mc +} // namespace simgrid #endif diff --git a/src/mc/checker/CommunicationDeterminismChecker.hpp b/src/mc/checker/CommunicationDeterminismChecker.hpp index 1701a284ab..c692e2ce0c 100644 --- a/src/mc/checker/CommunicationDeterminismChecker.hpp +++ b/src/mc/checker/CommunicationDeterminismChecker.hpp @@ -28,19 +28,18 @@ private: void prepare(); void real_run(); void log_state() override; - void deterministic_comm_pattern(int process, const simgrid::mc::PatternCommunication* comm, int backtracking); + void deterministic_comm_pattern(int process, const PatternCommunication* comm, int backtracking); void restoreState(); public: // These are used by functions which should be moved in CommunicationDeterminismChecker: void get_comm_pattern(smx_simcall_t request, e_mc_call_type_t call_type, int backtracking); - void complete_comm_pattern(simgrid::mc::RemotePtr comm_addr, unsigned int issuer, - int backtracking); + void complete_comm_pattern(RemotePtr comm_addr, unsigned int issuer, int backtracking); private: /** Stack representing the position in the exploration graph */ - std::list> stack_; - simgrid::mc::VisitedStates visited_states_; + std::list> stack_; + VisitedStates visited_states_; unsigned long expanded_states_count_ = 0; bool initial_communications_pattern_done = false; @@ -49,8 +48,8 @@ private: char *send_diff = nullptr; char *recv_diff = nullptr; }; +} // namespace mc +} // namespace simgrid #endif -} -} diff --git a/src/mc/checker/LivenessChecker.hpp b/src/mc/checker/LivenessChecker.hpp index 678e0eef4d..3ce6200e80 100644 --- a/src/mc/checker/LivenessChecker.hpp +++ b/src/mc/checker/LivenessChecker.hpp @@ -22,7 +22,7 @@ class XBT_PRIVATE Pair { public: int num = 0; bool search_cycle = false; - std::shared_ptr graph_state = nullptr; /* System state included */ + std::shared_ptr graph_state = nullptr; /* System state included */ xbt_automaton_state_t automaton_state = nullptr; std::shared_ptr> atomic_propositions; int requests = 0; @@ -40,16 +40,14 @@ class XBT_PRIVATE VisitedPair { public: int num; int other_num = 0; /* Dot output for */ - std::shared_ptr graph_state = nullptr; /* System state included */ + std::shared_ptr graph_state = nullptr; /* System state included */ xbt_automaton_state_t automaton_state; std::shared_ptr> atomic_propositions; std::size_t heap_bytes_used = 0; int actors_count = 0; - VisitedPair( - int pair_num, xbt_automaton_state_t automaton_state, - std::shared_ptr> atomic_propositions, - std::shared_ptr graph_state); + VisitedPair(int pair_num, xbt_automaton_state_t automaton_state, + std::shared_ptr> atomic_propositions, std::shared_ptr graph_state); ~VisitedPair() = default; }; @@ -64,8 +62,8 @@ public: private: std::shared_ptr> get_proposition_values(); - std::shared_ptr insert_acceptance_pair(simgrid::mc::Pair* pair); - int insert_visited_pair(std::shared_ptr visited_pair, simgrid::mc::Pair* pair); + std::shared_ptr insert_acceptance_pair(Pair* pair); + int insert_visited_pair(std::shared_ptr visited_pair, Pair* pair); void show_acceptance_cycle(std::size_t depth); void replay(); void remove_acceptance_pair(int pair_num); @@ -85,7 +83,7 @@ private: std::string previous_request_; }; -} -} +} // namespace mc +} // namespace simgrid #endif diff --git a/src/mc/checker/SafetyChecker.hpp b/src/mc/checker/SafetyChecker.hpp index ec6ba66e82..0167dda233 100644 --- a/src/mc/checker/SafetyChecker.hpp +++ b/src/mc/checker/SafetyChecker.hpp @@ -20,7 +20,8 @@ namespace simgrid { namespace mc { class XBT_PRIVATE SafetyChecker : public Checker { - simgrid::mc::ReductionMode reductionMode_ = simgrid::mc::ReductionMode::unset; + ReductionMode reductionMode_ = ReductionMode::unset; + public: explicit SafetyChecker(Session& session); ~SafetyChecker() = default; @@ -35,13 +36,13 @@ private: void restore_state(); /** Stack representing the position in the exploration graph */ - std::list> stack_; - simgrid::mc::VisitedStates visited_states_; - std::unique_ptr visited_state_; + std::list> stack_; + VisitedStates visited_states_; + std::unique_ptr visited_state_; unsigned long expanded_states_count_ = 0; }; -} -} +} // namespace mc +} // namespace simgrid #endif diff --git a/src/mc/inspect/DwarfExpression.hpp b/src/mc/inspect/DwarfExpression.hpp index 811bbb0e62..c2058a988f 100644 --- a/src/mc/inspect/DwarfExpression.hpp +++ b/src/mc/inspect/DwarfExpression.hpp @@ -44,10 +44,10 @@ typedef std::vector DwarfExpression; */ struct ExpressionContext { /** CPU state (registers) */ - unw_cursor_t* cursor = nullptr; - void* frame_base = nullptr; - const simgrid::mc::AddressSpace* address_space = nullptr; /** Address space used to read memory */ - simgrid::mc::ObjectInformation* object_info = nullptr; + unw_cursor_t* cursor = nullptr; + void* frame_base = nullptr; + const mc::AddressSpace* address_space = nullptr; /** Address space used to read memory */ + mc::ObjectInformation* object_info = nullptr; }; /** When an error happens in the execution of a DWARF expression */ diff --git a/src/mc/remote/Channel.hpp b/src/mc/remote/Channel.hpp index 5494f334d2..30161b5bb3 100644 --- a/src/mc/remote/Channel.hpp +++ b/src/mc/remote/Channel.hpp @@ -55,7 +55,7 @@ public: int get_socket() const { return socket_; } }; -} -} +} // namespace mc +} // namespace simgrid #endif diff --git a/src/mc/remote/Client.hpp b/src/mc/remote/Client.hpp index d6b7fd61dd..11cf82ad1f 100644 --- a/src/mc/remote/Client.hpp +++ b/src/mc/remote/Client.hpp @@ -51,7 +51,7 @@ public: static Client* initialize(); static Client* get() { return instance_.get(); } }; -} -} +} // namespace mc +} // namespace simgrid #endif diff --git a/src/mc/remote/RemoteClient.hpp b/src/mc/remote/RemoteClient.hpp index 6f0a1bd4a6..6a2349b725 100644 --- a/src/mc/remote/RemoteClient.hpp +++ b/src/mc/remote/RemoteClient.hpp @@ -20,8 +20,8 @@ namespace mc { class ActorInformation { public: /** MCed address of the process */ - RemotePtr address{nullptr}; - Remote copy; + RemotePtr address{nullptr}; + Remote copy; /** Hostname (owned by `mc_modelchecker->hostnames`) */ const char* hostname = nullptr; @@ -105,11 +105,11 @@ public: void clear_bytes(RemotePtr address, size_t len); // Debug information: - std::shared_ptr find_object_info(RemotePtr addr) const; - std::shared_ptr find_object_info_exec(RemotePtr addr) const; - std::shared_ptr find_object_info_rw(RemotePtr addr) const; - simgrid::mc::Frame* find_function(RemotePtr ip) const; - const simgrid::mc::Variable* find_variable(const char* name) const; + std::shared_ptr find_object_info(RemotePtr addr) const; + std::shared_ptr find_object_info_exec(RemotePtr addr) const; + std::shared_ptr find_object_info_rw(RemotePtr addr) const; + Frame* find_function(RemotePtr ip) const; + const Variable* find_variable(const char* name) const; // Heap access: xbt_mheap_t get_heap() @@ -146,7 +146,7 @@ public: void ignore_global_variable(const char* name) { - for (std::shared_ptr const& info : this->object_infos) + for (std::shared_ptr const& info : this->object_infos) info->remove_global_variable(name); } @@ -158,11 +158,11 @@ public: void unignore_heap(void* address, size_t size); void ignore_local_variable(const char* var_name, const char* frame_name); - std::vector& actors(); - std::vector& dead_actors(); + std::vector& actors(); + std::vector& dead_actors(); /** Get a local description of a remote SIMIX actor */ - simgrid::mc::ActorInformation* resolve_actor_info(simgrid::mc::RemotePtr actor) + ActorInformation* resolve_actor_info(RemotePtr actor) { xbt_assert(mc_model_checker != nullptr); if (not actor) @@ -178,9 +178,9 @@ public: } /** Get a local copy of the SIMIX actor structure */ - simgrid::kernel::actor::ActorImpl* resolve_actor(simgrid::mc::RemotePtr process) + kernel::actor::ActorImpl* resolve_actor(RemotePtr process) { - simgrid::mc::ActorInformation* actor_info = this->resolve_actor_info(process); + ActorInformation* actor_info = this->resolve_actor_info(process); if (actor_info) return actor_info->copy.get_buffer(); else @@ -198,7 +198,7 @@ private: pid_t pid_ = -1; Channel channel_; bool running_ = false; - std::vector memory_map_; + std::vector memory_map_; RemotePtr maestro_stack_start_; RemotePtr maestro_stack_end_; int memory_file = -1; @@ -209,9 +209,9 @@ private: public: // object info // TODO, make private (first, objectify simgrid::mc::ObjectInformation*) - std::vector> object_infos; - std::shared_ptr libsimgrid_info; - std::shared_ptr binary_info; + std::vector> object_infos; + std::shared_ptr libsimgrid_info; + std::shared_ptr binary_info; // Copies of MCed SMX data structures /** Copy of `simix_global->process_list` @@ -278,7 +278,7 @@ public: /** Open a FD to a remote process memory (`/dev/$pid/mem`) */ XBT_PRIVATE int open_vm(pid_t pid, int flags); -} -} +} // namespace mc +} // namespace simgrid #endif diff --git a/src/mc/remote/RemotePtr.hpp b/src/mc/remote/RemotePtr.hpp index e3f0371fb4..d4c7bca2a9 100644 --- a/src/mc/remote/RemotePtr.hpp +++ b/src/mc/remote/RemotePtr.hpp @@ -135,7 +135,7 @@ template inline RemotePtr remote(uint64_t p) { return RemotePtr(p); } -} -} +} // namespace mc +} // namespace simgrid #endif diff --git a/src/mc/sosp/Snapshot.hpp b/src/mc/sosp/Snapshot.hpp index 5b8bb660ad..233297d65e 100644 --- a/src/mc/sosp/Snapshot.hpp +++ b/src/mc/sosp/Snapshot.hpp @@ -89,8 +89,8 @@ public: private: void add_region(RegionType type, ObjectInformation* object_info, void* start_addr, std::size_t size); - void snapshot_regions(simgrid::mc::RemoteClient* process); - void snapshot_stacks(simgrid::mc::RemoteClient* process); + void snapshot_regions(RemoteClient* process); + void snapshot_stacks(RemoteClient* process); }; } // namespace mc } // namespace simgrid diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index 032624f3cf..b2eefa85c4 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -105,7 +105,7 @@ s4u::CommPtr Task::send_async(const std::string& alias, void_f_pvoid_t cleanup, if (TRACE_actor_is_enabled()) { container_t process_container = instr::Container::by_name(instr_pid(*MSG_process_self())); std::string key = std::string("p") + std::to_string(get_id()); - instr::Container::get_root()->get_link("ACTOR_TASK_LINK")->start_event(process_container, "SR", key); + instr::Container::get_root()->get_link("ACTOR_LINK")->start_event(process_container, "SR", key); } /* Prepare the task to send */ @@ -576,7 +576,7 @@ msg_error_t MSG_task_receive_with_timeout_bounded(msg_task_t* task, const char* container_t process_container = simgrid::instr::Container::by_name(instr_pid(*MSG_process_self())); std::string key = std::string("p") + std::to_string((*task)->get_id()); - simgrid::instr::Container::get_root()->get_link("ACTOR_TASK_LINK")->end_event(process_container, "SR", key); + simgrid::instr::Container::get_root()->get_link("ACTOR_LINK")->end_event(process_container, "SR", key); } return ret; } diff --git a/src/s4u/s4u_Link.cpp b/src/s4u/s4u_Link.cpp index 4942e65ee6..44742271e1 100644 --- a/src/s4u/s4u_Link.cpp +++ b/src/s4u/s4u_Link.cpp @@ -55,11 +55,21 @@ double Link::get_latency() const return this->pimpl_->get_latency(); } +void Link::set_latency(double value) +{ + kernel::actor::simcall([this, value] { pimpl_->set_latency(value); }); +} + double Link::get_bandwidth() const { return this->pimpl_->get_bandwidth(); } +void Link::set_bandwidth(double value) +{ + kernel::actor::simcall([this, value] { pimpl_->set_bandwidth(value); }); +} + Link::SharingPolicy Link::get_sharing_policy() const { return this->pimpl_->get_sharing_policy(); @@ -127,10 +137,20 @@ double sg_link_bandwidth(const_sg_link_t link) { return link->get_bandwidth(); } + +void sg_link_bandwidth_set(sg_link_t link, double value) +{ + return link->set_bandwidth(value); +} + double sg_link_latency(const_sg_link_t link) { return link->get_latency(); } +void sg_link_latency_set(sg_link_t link, double value) +{ + return link->set_latency(value); +} void* sg_link_data(const_sg_link_t link) { return link->get_data(); diff --git a/src/simgrid/sg_config.cpp b/src/simgrid/sg_config.cpp index 5a515878bd..813dce80bc 100644 --- a/src/simgrid/sg_config.cpp +++ b/src/simgrid/sg_config.cpp @@ -342,11 +342,6 @@ void sg_config_init(int *argc, char **argv) simgrid::config::declare_flag("contexts/nthreads", "Number of parallel threads used to execute user contexts", 1, &SIMIX_context_set_nthreads); - simgrid::config::declare_flag("contexts/parallel-threshold", - "Minimal number of user contexts to be run in parallel (raw contexts only)", 2, - &SIMIX_context_set_parallel_threshold); - simgrid::config::alias("contexts/parallel-threshold", {"contexts/parallel_threshold"}); - /* synchronization mode for parallel user contexts */ #if HAVE_FUTEX_H std::string default_synchro_mode = "futex"; diff --git a/src/simix/smx_context.cpp b/src/simix/smx_context.cpp index d0343ddcfc..1365a6ad00 100644 --- a/src/simix/smx_context.cpp +++ b/src/simix/smx_context.cpp @@ -50,7 +50,6 @@ static simgrid::config::Flag context_factory_name( unsigned smx_context_stack_size; unsigned smx_context_guard_size; static int smx_parallel_contexts = 1; -static int smx_parallel_threshold = 2; static e_xbt_parmap_mode_t smx_parallel_synchronization_mode = XBT_PARMAP_DEFAULT; /** @@ -151,32 +150,6 @@ void SIMIX_context_set_nthreads(int nb_threads) { smx_parallel_contexts = nb_threads; } -/** - * @brief Returns the threshold above which user processes are run in parallel. - * - * If the number of threads is set to 1, there is no parallelism and this - * threshold has no effect. - * - * @return when the number of user processes ready to run is above - * this threshold, they are run in parallel - */ -int SIMIX_context_get_parallel_threshold() { - return smx_parallel_threshold; -} - -/** - * @brief Sets the threshold above which user processes are run in parallel. - * - * If the number of threads is set to 1, there is no parallelism and this - * threshold has no effect. - * - * @param threshold when the number of user processes ready to run is above - * this threshold, they are run in parallel - */ -void SIMIX_context_set_parallel_threshold(int threshold) { - smx_parallel_threshold = threshold; -} - /** * @brief Returns the synchronization mode used when processes are run in * parallel. diff --git a/src/smpi/bindings/smpi_pmpi.cpp b/src/smpi/bindings/smpi_pmpi.cpp index 0b484fd3b4..de3c35d79a 100644 --- a/src/smpi/bindings/smpi_pmpi.cpp +++ b/src/smpi/bindings/smpi_pmpi.cpp @@ -42,11 +42,7 @@ int PMPI_Init(int*, char***) simgrid::smpi::ActorExt::init(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_init(rank_traced); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::NoOpTIData("init")); - TRACE_smpi_comm_out(rank_traced); - TRACE_smpi_computing_init(rank_traced); - TRACE_smpi_sleeping_init(rank_traced); + TRACE_smpi_init(rank_traced, __func__); smpi_bench_begin(); smpi_process()->mark_as_initialized(); diff --git a/src/smpi/internals/instr_smpi.cpp b/src/smpi/internals/instr_smpi.cpp index 4c27a616fb..5dba5c2a14 100644 --- a/src/smpi/internals/instr_smpi.cpp +++ b/src/smpi/internals/instr_smpi.cpp @@ -146,7 +146,7 @@ void TRACE_smpi_setup_container(int rank, const_sg_host_t host) father->create_child(std::string("rank-") + std::to_string(rank), "MPI"); // This container is of type MPI } -void TRACE_smpi_init(int rank) +void TRACE_smpi_init(int rank, std::string calling_func) { if (not TRACE_smpi_is_enabled()) return; @@ -155,6 +155,17 @@ void TRACE_smpi_init(int rank) TRACE_smpi_setup_container(rank, sg_host_self()); simgrid::s4u::this_actor::on_exit([self](bool) { smpi_container(self->get_pid())->remove_from_parent(); }); + + simgrid::instr::StateType* state = smpi_container(rank)->get_state("MPI_STATE"); + + state->add_entity_value(calling_func, instr_find_color(calling_func.c_str())); + state->push_event(calling_func, new simgrid::instr::NoOpTIData("init")); + state->pop_event(); + if (TRACE_smpi_is_computing()) + state->add_entity_value("computing", instr_find_color("computing")); + if (TRACE_smpi_is_sleeping()) + state->add_entity_value("sleeping", instr_find_color("sleeping")); + #if HAVE_PAPI const simgrid::instr::Container* container = smpi_container(rank); papi_counter_t counters = smpi_process()->papi_counters(); @@ -169,34 +180,6 @@ void TRACE_smpi_init(int rank) #endif } -void TRACE_smpi_computing_init(int rank) -{ - //first use, initialize the color in the trace - if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing()) - smpi_container(rank)->get_state("MPI_STATE")->add_entity_value("computing", instr_find_color("computing")); -} - -void TRACE_smpi_sleeping_init(int rank) -{ - //first use, initialize the color in the trace - if (TRACE_smpi_is_enabled() && TRACE_smpi_is_sleeping()) - smpi_container(rank)->get_state("MPI_STATE")->add_entity_value("sleeping", instr_find_color("sleeping")); -} - -void TRACE_smpi_computing_in(int rank, double amount) -{ - if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing()) - smpi_container(rank) - ->get_state("MPI_STATE") - ->push_event("computing", new simgrid::instr::CpuTIData("compute", amount)); -} - -void TRACE_smpi_computing_out(int rank) -{ - if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing()) - smpi_container(rank)->get_state("MPI_STATE")->pop_event(); -} - void TRACE_smpi_sleeping_in(int rank, double duration) { if (TRACE_smpi_is_enabled() && TRACE_smpi_is_sleeping()) diff --git a/src/smpi/internals/smpi_bench.cpp b/src/smpi/internals/smpi_bench.cpp index 6eb4ab17cb..c28f90a63c 100644 --- a/src/smpi/internals/smpi_bench.cpp +++ b/src/smpi/internals/smpi_bench.cpp @@ -47,27 +47,16 @@ void private_execute_flops(double flops) { smpi_switch_data_segment(simgrid::s4u::Actor::self()); } -void smpi_execute_flops(double flops) { - int rank = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_computing_in(rank, flops); - +void smpi_execute_flops(double flops) +{ private_execute_flops(flops); - - TRACE_smpi_computing_out(rank); } void smpi_execute(double duration) { if (duration >= smpi_cfg_cpu_thresh()) { XBT_DEBUG("Sleep for %g to handle real computation time", duration); - double flops = duration * smpi_cfg_host_speed(); - int rank = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_computing_in(rank, flops); - - private_execute_flops(flops); - - TRACE_smpi_computing_out(rank); - + private_execute_flops(duration * smpi_cfg_host_speed()); } else { XBT_DEBUG("Real computation took %g while option smpi/cpu-threshold is set to %g => ignore it", duration, smpi_cfg_cpu_thresh()); diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 7ddc56596c..c3e32fa864 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -642,5 +642,5 @@ void smpi_mpi_init() { } void SMPI_thread_create() { - TRACE_smpi_init(simgrid::s4u::this_actor::get_pid()); + TRACE_smpi_init(simgrid::s4u::this_actor::get_pid(), __func__); } diff --git a/src/smpi/internals/smpi_replay.cpp b/src/smpi/internals/smpi_replay.cpp index 1cd1302092..d05719e85d 100644 --- a/src/smpi/internals/smpi_replay.cpp +++ b/src/smpi/internals/smpi_replay.cpp @@ -773,10 +773,7 @@ void smpi_replay_init(const char* instance_id, int rank, double start_delay_flop int my_proc_id = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_init(my_proc_id); - TRACE_smpi_computing_init(my_proc_id); - TRACE_smpi_comm_in(my_proc_id, "smpi_replay_run_init", new simgrid::instr::NoOpTIData("init")); - TRACE_smpi_comm_out(my_proc_id); + TRACE_smpi_init(my_proc_id, "smpi_replay_run_init"); xbt_replay_action_register("init", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::InitAction().execute(action); }); xbt_replay_action_register("finalize", [](simgrid::xbt::ReplayAction const&) { /* nothing to do */ }); xbt_replay_action_register("comm_size", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::CommunicatorAction().execute(action); }); diff --git a/src/surf/disk_s19.cpp b/src/surf/disk_s19.cpp index 8e849d8353..66525d7eee 100644 --- a/src/surf/disk_s19.cpp +++ b/src/surf/disk_s19.cpp @@ -96,10 +96,10 @@ DiskS19Action::DiskS19Action(Model* model, double cost, bool failed, DiskImpl* d model->get_maxmin_system()->expand(disk->get_constraint(), get_variable(), 1.0); switch (type) { case s4u::Io::OpType::READ: - model->get_maxmin_system()->expand(disk->constraint_read_, get_variable(), 1.0); + model->get_maxmin_system()->expand(disk->get_read_constraint(), get_variable(), 1.0); break; case s4u::Io::OpType::WRITE: - model->get_maxmin_system()->expand(disk->constraint_write_, get_variable(), 1.0); + model->get_maxmin_system()->expand(disk->get_write_constraint(), get_variable(), 1.0); break; default: THROW_UNIMPLEMENTED; diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index 355cba0bd4..06db5168d0 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -1001,7 +1001,7 @@ void surf_parse_open(const std::string& file) surf_file_to_parse = surf_fopen(file, "r"); if (surf_file_to_parse == nullptr) - throw std::invalid_argument(std::string("Unable to open ')") + file + "' from '" + simgrid::xbt::Path().get_name() + + throw std::invalid_argument(std::string("Unable to open '") + file + "' from '" + simgrid::xbt::Path().get_name() + "'. Does this file exist?"); surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE); surf_parse__switch_to_buffer(surf_input_buffer);