From: Ehsan Azimi Date: Thu, 19 Nov 2020 11:22:48 +0000 (+0100) Subject: Merge branch 'master' of github.com:simgrid/simgrid into dev_7 X-Git-Tag: v3.26~72^2^2~49 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/be2d18ff8c8ee4ccf6b713010f8999e7613dcdf5?hp=d918db3ca7152c00113f2e072deca4614f97bb58 Merge branch 'master' of github.com:simgrid/simgrid into dev_7 --- diff --git a/doc/doxygen/inside_extending.doc b/doc/doxygen/inside_extending.doc index 2aba2a57d5..d9ae3934f9 100644 --- a/doc/doxygen/inside_extending.doc +++ b/doc/doxygen/inside_extending.doc @@ -168,7 +168,7 @@ generates the following files: Definition of type `enum e_smx_simcall_t` (one value per existing simcall) - popping_generated.cpp: Definitions of `simcall_names[]` (debug name of each simcall), and - SIMIX_simcall_enter() that deals with the simcall from within the kernel + ActorImpl::simcall_handle() that deals with the simcall from within the kernel The simcall.in file list all the simcalls in sections. A line starting by "##" define a new section which will be replace by a "ifdef" in the generated code. diff --git a/examples/s4u/app-bittorrent/s4u-bittorrent.hpp b/examples/s4u/app-bittorrent/s4u-bittorrent.hpp index 1c53685c68..29c8cb6973 100644 --- a/examples/s4u/app-bittorrent/s4u-bittorrent.hpp +++ b/examples/s4u/app-bittorrent/s4u-bittorrent.hpp @@ -23,49 +23,23 @@ constexpr int MAX_UNCHOKED_PEERS = 4; /** Interval between each update of the choked peers */ constexpr int UPDATE_CHOKED_INTERVAL = 30; -/** Message sizes - * Sizes based on report by A. Legout et al, Understanding BitTorrent: An Experimental Perspective - * http://hal.inria.fr/inria-00000156/en - */ -constexpr unsigned MESSAGE_HANDSHAKE_SIZE = 68; -constexpr unsigned MESSAGE_CHOKE_SIZE = 5; -constexpr unsigned MESSAGE_UNCHOKE_SIZE = 5; -constexpr unsigned MESSAGE_INTERESTED_SIZE = 5; -constexpr unsigned MESSAGE_NOTINTERESTED_SIZE = 5; -constexpr unsigned MESSAGE_HAVE_SIZE = 9; -constexpr unsigned MESSAGE_BITFIELD_SIZE = 5; -constexpr unsigned MESSAGE_REQUEST_SIZE = 17; -constexpr unsigned MESSAGE_PIECE_SIZE = 13; -constexpr unsigned MESSAGE_CANCEL_SIZE = 17; - /** Types of messages exchanged between two peers. */ -enum e_message_type { - MESSAGE_HANDSHAKE, - MESSAGE_CHOKE, - MESSAGE_UNCHOKE, - MESSAGE_INTERESTED, - MESSAGE_NOTINTERESTED, - MESSAGE_HAVE, - MESSAGE_BITFIELD, - MESSAGE_REQUEST, - MESSAGE_PIECE, - MESSAGE_CANCEL -}; +enum class MessageType { HANDSHAKE, CHOKE, UNCHOKE, INTERESTED, NOTINTERESTED, HAVE, BITFIELD, REQUEST, PIECE, CANCEL }; class Message { public: - e_message_type type; + MessageType type; int peer_id; simgrid::s4u::Mailbox* return_mailbox; unsigned int bitfield = 0U; int piece = 0; int block_index = 0; int block_length = 0; - Message(e_message_type type, int peer_id, simgrid::s4u::Mailbox* return_mailbox) + Message(MessageType type, int peer_id, simgrid::s4u::Mailbox* return_mailbox) : type(type), peer_id(peer_id), return_mailbox(return_mailbox){}; - Message(e_message_type type, int peer_id, unsigned int bitfield, simgrid::s4u::Mailbox* return_mailbox) + Message(MessageType type, int peer_id, unsigned int bitfield, simgrid::s4u::Mailbox* return_mailbox) : type(type), peer_id(peer_id), return_mailbox(return_mailbox), bitfield(bitfield){}; - Message(e_message_type type, int peer_id, simgrid::s4u::Mailbox* return_mailbox, int piece, int block_index, + Message(MessageType type, int peer_id, simgrid::s4u::Mailbox* return_mailbox, int piece, int block_index, int block_length) : type(type) , peer_id(peer_id) @@ -73,7 +47,7 @@ public: , piece(piece) , block_index(block_index) , block_length(block_length){}; - Message(e_message_type type, int peer_id, simgrid::s4u::Mailbox* return_mailbox, int piece) + Message(MessageType type, int peer_id, simgrid::s4u::Mailbox* return_mailbox, int piece) : type(type), peer_id(peer_id), return_mailbox(return_mailbox), piece(piece){}; }; diff --git a/examples/s4u/app-bittorrent/s4u-peer.cpp b/examples/s4u/app-bittorrent/s4u-peer.cpp index 67b6516754..f1473207a8 100644 --- a/examples/s4u/app-bittorrent/s4u-peer.cpp +++ b/examples/s4u/app-bittorrent/s4u-peer.cpp @@ -26,8 +26,31 @@ constexpr unsigned long BLOCKS_REQUESTED = 2UL; constexpr double SLEEP_DURATION = 1.0; #define BITS_TO_BYTES(x) (((x) / 8 + (x) % 8) ? 1 : 0) -constexpr std::array message_type_names{ - {"HANDSHAKE", "CHOKE", "UNCHOKE", "INTERESTED", "NOTINTERESTED", "HAVE", "BITFIELD", "REQUEST", "PIECE", "CANCEL"}}; +/** Message sizes + * Sizes based on report by A. Legout et al, Understanding BitTorrent: An Experimental Perspective + * http://hal.inria.fr/inria-00000156/en + */ +constexpr unsigned message_size(MessageType type) +{ + constexpr std::array sizes{{/* HANDSHAKE */ 68, + /* CHOKE */ 5, + /* UNCHOKE */ 5, + /* INTERESTED */ 5, + /* NOTINTERESTED */ 5, + /* HAVE */ 9, + /* BITFIELD */ 5, + /* REQUEST */ 17, + /* PIECE */ 13, + /* CANCEL */ 17}}; + return sizes[static_cast(type)]; +} + +constexpr const char* message_name(MessageType type) +{ + constexpr std::array names{{"HANDSHAKE", "CHOKE", "UNCHOKE", "INTERESTED", "NOTINTERESTED", "HAVE", + "BITFIELD", "REQUEST", "PIECE", "CANCEL"}}; + return names[static_cast(type)]; +} Peer::Peer(std::vector args) { @@ -110,15 +133,15 @@ void Peer::sendHandshakeToAllPeers() { for (auto const& kv : connected_peers) { const Connection& remote_peer = kv.second; - auto* handshake = new Message(MESSAGE_HANDSHAKE, id, mailbox_); - remote_peer.mailbox_->put_init(handshake, MESSAGE_HANDSHAKE_SIZE)->detach(); + auto* handshake = new Message(MessageType::HANDSHAKE, id, mailbox_); + remote_peer.mailbox_->put_init(handshake, message_size(MessageType::HANDSHAKE))->detach(); XBT_DEBUG("Sending a HANDSHAKE to %d", remote_peer.id); } } -void Peer::sendMessage(simgrid::s4u::Mailbox* mailbox, e_message_type type, uint64_t size) +void Peer::sendMessage(simgrid::s4u::Mailbox* mailbox, MessageType type, uint64_t size) { - XBT_DEBUG("Sending %s to %s", message_type_names.at(type), mailbox->get_cname()); + XBT_DEBUG("Sending %s to %s", message_name(type), mailbox->get_cname()); mailbox->put_init(new Message(type, id, bitfield_, mailbox_), size)->detach(); } @@ -126,8 +149,8 @@ void Peer::sendBitfield(simgrid::s4u::Mailbox* mailbox) { XBT_DEBUG("Sending a BITFIELD to %s", mailbox->get_cname()); mailbox - ->put_init(new Message(MESSAGE_BITFIELD, id, bitfield_, mailbox_), - MESSAGE_BITFIELD_SIZE + BITS_TO_BYTES(FILE_PIECES)) + ->put_init(new Message(MessageType::BITFIELD, id, bitfield_, mailbox_), + message_size(MessageType::BITFIELD) + BITS_TO_BYTES(FILE_PIECES)) ->detach(); } @@ -135,7 +158,8 @@ void Peer::sendPiece(simgrid::s4u::Mailbox* mailbox, unsigned int piece, int blo { xbt_assert(not hasNotPiece(piece), "Tried to send a unavailable piece."); XBT_DEBUG("Sending the PIECE %u (%d,%d) to %s", piece, block_index, block_length, mailbox->get_cname()); - mailbox->put_init(new Message(MESSAGE_PIECE, id, mailbox_, piece, block_index, block_length), BLOCK_SIZE)->detach(); + mailbox->put_init(new Message(MessageType::PIECE, id, mailbox_, piece, block_index, block_length), BLOCK_SIZE) + ->detach(); } void Peer::sendHaveToAllPeers(unsigned int piece) @@ -143,7 +167,8 @@ void Peer::sendHaveToAllPeers(unsigned int piece) XBT_DEBUG("Sending HAVE message to all my peers"); for (auto const& kv : connected_peers) { const Connection& remote_peer = kv.second; - remote_peer.mailbox_->put_init(new Message(MESSAGE_HAVE, id, mailbox_, piece), MESSAGE_HAVE_SIZE)->detach(); + remote_peer.mailbox_->put_init(new Message(MessageType::HAVE, id, mailbox_, piece), message_size(MessageType::HAVE)) + ->detach(); } } @@ -157,7 +182,8 @@ void Peer::sendRequestTo(Connection* remote_peer, unsigned int piece) XBT_DEBUG("Sending a REQUEST to %s for piece %u (%d,%d)", remote_peer->mailbox_->get_cname(), piece, block_index, block_length); remote_peer->mailbox_ - ->put_init(new Message(MESSAGE_REQUEST, id, mailbox_, piece, block_index, block_length), MESSAGE_REQUEST_SIZE) + ->put_init(new Message(MessageType::REQUEST, id, mailbox_, piece, block_index, block_length), + message_size(MessageType::REQUEST)) ->detach(); } } @@ -286,26 +312,25 @@ void Peer::updateActivePeersSet(Connection* remote_peer) void Peer::handleMessage() { - XBT_DEBUG("Received a %s message from %s", message_type_names.at(message->type), - message->return_mailbox->get_cname()); + XBT_DEBUG("Received a %s message from %s", message_name(message->type), message->return_mailbox->get_cname()); auto known_peer = connected_peers.find(message->peer_id); Connection* remote_peer = (known_peer == connected_peers.end()) ? nullptr : &known_peer->second; - xbt_assert(remote_peer != nullptr || message->type == MESSAGE_HANDSHAKE, + xbt_assert(remote_peer != nullptr || message->type == MessageType::HANDSHAKE, "The impossible did happened: A not-in-our-list peer sent us a message."); switch (message->type) { - case MESSAGE_HANDSHAKE: + case MessageType::HANDSHAKE: // Check if the peer is in our connection list. if (remote_peer == nullptr) { XBT_DEBUG("This peer %d was unknown, answer to its handshake", message->peer_id); connected_peers.emplace(message->peer_id, Connection(message->peer_id)); - sendMessage(message->return_mailbox, MESSAGE_HANDSHAKE, MESSAGE_HANDSHAKE_SIZE); + sendMessage(message->return_mailbox, MessageType::HANDSHAKE, message_size(MessageType::HANDSHAKE)); } // Send our bitfield to the peer sendBitfield(message->return_mailbox); break; - case MESSAGE_BITFIELD: + case MessageType::BITFIELD: // Update the pieces list updatePiecesCountFromBitfield(message->bitfield); // Store the bitfield @@ -313,32 +338,32 @@ void Peer::handleMessage() xbt_assert(not remote_peer->am_interested, "Should not be interested at first"); if (isInterestedBy(remote_peer)) { remote_peer->am_interested = true; - sendMessage(message->return_mailbox, MESSAGE_INTERESTED, MESSAGE_INTERESTED_SIZE); + sendMessage(message->return_mailbox, MessageType::INTERESTED, message_size(MessageType::INTERESTED)); } break; - case MESSAGE_INTERESTED: + case MessageType::INTERESTED: // Update the interested state of the peer. remote_peer->interested = true; updateActivePeersSet(remote_peer); break; - case MESSAGE_NOTINTERESTED: + case MessageType::NOTINTERESTED: remote_peer->interested = false; updateActivePeersSet(remote_peer); break; - case MESSAGE_UNCHOKE: + case MessageType::UNCHOKE: xbt_assert(remote_peer->choked_download); remote_peer->choked_download = false; // Send requests to the peer, since it has unchoked us if (remote_peer->am_interested) requestNewPieceTo(remote_peer); break; - case MESSAGE_CHOKE: + case MessageType::CHOKE: xbt_assert(not remote_peer->choked_download); remote_peer->choked_download = true; if (remote_peer->current_piece != -1) removeCurrentPiece(remote_peer, remote_peer->current_piece); break; - case MESSAGE_HAVE: + case MessageType::HAVE: XBT_DEBUG("\t for piece %d", message->piece); xbt_assert((message->piece >= 0 && static_cast(message->piece) < FILE_PIECES), "Wrong HAVE message received"); @@ -347,12 +372,12 @@ void Peer::handleMessage() // If the piece is in our pieces, we tell the peer that we are interested. if (not remote_peer->am_interested && hasNotPiece(message->piece)) { remote_peer->am_interested = true; - sendMessage(message->return_mailbox, MESSAGE_INTERESTED, MESSAGE_INTERESTED_SIZE); + sendMessage(message->return_mailbox, MessageType::INTERESTED, message_size(MessageType::INTERESTED)); if (not remote_peer->choked_download) requestNewPieceTo(remote_peer); } break; - case MESSAGE_REQUEST: + case MessageType::REQUEST: xbt_assert(remote_peer->interested); xbt_assert((message->piece >= 0 && static_cast(message->piece) < FILE_PIECES), "Wrong HAVE message received"); @@ -366,7 +391,7 @@ void Peer::handleMessage() XBT_DEBUG("\t for piece %d but he is choked.", message->peer_id); } break; - case MESSAGE_PIECE: + case MessageType::PIECE: XBT_DEBUG(" \t for piece %d (%d,%d)", message->piece, message->block_index, message->block_index + message->block_length); xbt_assert(not remote_peer->choked_download); @@ -394,7 +419,7 @@ void Peer::handleMessage() requestNewPieceTo(remote_peer); } break; - case MESSAGE_CANCEL: + case MessageType::CANCEL: break; default: THROW_IMPOSSIBLE; @@ -585,7 +610,7 @@ void Peer::updateChokedPeers() choked_peer->choked_upload = true; updateActivePeersSet(choked_peer); XBT_DEBUG("(%d) Sending a CHOKE to %d", id, choked_peer->id); - sendMessage(choked_peer->mailbox_, MESSAGE_CHOKE, MESSAGE_CHOKE_SIZE); + sendMessage(choked_peer->mailbox_, MessageType::CHOKE, message_size(MessageType::CHOKE)); } if (chosen_peer != nullptr) { xbt_assert((chosen_peer->choked_upload), "Tries to unchoked an unchoked peer"); @@ -594,7 +619,7 @@ void Peer::updateChokedPeers() chosen_peer->last_unchoke = simgrid::s4u::Engine::get_clock(); XBT_DEBUG("(%d) Sending a UNCHOKE to %d", id, chosen_peer->id); updateActivePeersSet(chosen_peer); - sendMessage(chosen_peer->mailbox_, MESSAGE_UNCHOKE, MESSAGE_UNCHOKE_SIZE); + sendMessage(chosen_peer->mailbox_, MessageType::UNCHOKE, message_size(MessageType::UNCHOKE)); } } } @@ -615,7 +640,7 @@ void Peer::updateInterestedAfterReceive() if (not interested) { // no more piece to download from connection remote_peer.am_interested = false; - sendMessage(remote_peer.mailbox_, MESSAGE_NOTINTERESTED, MESSAGE_NOTINTERESTED_SIZE); + sendMessage(remote_peer.mailbox_, MessageType::NOTINTERESTED, message_size(MessageType::NOTINTERESTED)); } } } diff --git a/examples/s4u/app-bittorrent/s4u-peer.hpp b/examples/s4u/app-bittorrent/s4u-peer.hpp index 4a3c84cf7e..a9ea46b36f 100644 --- a/examples/s4u/app-bittorrent/s4u-peer.hpp +++ b/examples/s4u/app-bittorrent/s4u-peer.hpp @@ -79,7 +79,7 @@ public: void requestNewPieceTo(Connection* remote_peer); bool getPeersFromTracker(); - void sendMessage(simgrid::s4u::Mailbox* mailbox, e_message_type type, uint64_t size); + void sendMessage(simgrid::s4u::Mailbox* mailbox, MessageType type, uint64_t size); void sendBitfield(simgrid::s4u::Mailbox* mailbox); void sendPiece(simgrid::s4u::Mailbox* mailbox, unsigned int piece, int block_index, int block_length); void sendHandshakeToAllPeers(); diff --git a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp index abb632b77c..d727cf3d76 100644 --- a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp +++ b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp @@ -104,7 +104,7 @@ void Node::leave() void Node::notifyAndQuit() { // send the PREDECESSOR_LEAVING to our successor - auto* pred_msg = new ChordMessage(PREDECESSOR_LEAVING); + auto* pred_msg = new ChordMessage(MessageType::PREDECESSOR_LEAVING); pred_msg->request_id = pred_id_; pred_msg->answer_to = mailbox_; @@ -118,7 +118,7 @@ void Node::notifyAndQuit() if (pred_id_ != -1 && pred_id_ != id_) { // send the SUCCESSOR_LEAVING to our predecessor (only if I have one that is not me) - auto* succ_msg = new ChordMessage(SUCCESSOR_LEAVING); + auto* succ_msg = new ChordMessage(MessageType::SUCCESSOR_LEAVING); succ_msg->request_id = fingers_[0]; succ_msg->answer_to = mailbox_; XBT_DEBUG("Sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_); @@ -208,7 +208,7 @@ void Node::checkPredecessor() simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_)); simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_is_alive"); - auto* message = new ChordMessage(PREDECESSOR_ALIVE); + auto* message = new ChordMessage(MessageType::PREDECESSOR_ALIVE); message->request_id = pred_id_; message->answer_to = return_mailbox; @@ -248,7 +248,7 @@ int Node::remoteGetPredecessor(int ask_to) simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to)); simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_pred"); - auto* message = new ChordMessage(GET_PREDECESSOR); + auto* message = new ChordMessage(MessageType::GET_PREDECESSOR); message->request_id = id_; message->answer_to = return_mailbox; @@ -320,7 +320,7 @@ int Node::remoteFindSuccessor(int ask_to, int id) simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to)); simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_succ"); - auto* message = new ChordMessage(FIND_SUCCESSOR); + auto* message = new ChordMessage(MessageType::FIND_SUCCESSOR); message->request_id = id_; message->answer_to = return_mailbox; @@ -366,7 +366,7 @@ void Node::notify(int predecessor_candidate_id) /* Notifies a remote node that its predecessor may have changed. */ void Node::remoteNotify(int notify_id, int predecessor_candidate_id) const { - auto* message = new ChordMessage(NOTIFY); + auto* message = new ChordMessage(MessageType::NOTIFY); message->request_id = predecessor_candidate_id; message->answer_to = nullptr; @@ -403,77 +403,78 @@ void Node::stabilize() void Node::handleMessage(ChordMessage* message) { switch (message->type) { - case FIND_SUCCESSOR: - XBT_DEBUG("Received a 'Find Successor' request from %s for id %d", message->issuer_host_name.c_str(), - message->request_id); - // is my successor the successor? - if (is_in_interval(message->request_id, id_ + 1, fingers_[0])) { - message->type = FIND_SUCCESSOR_ANSWER; - message->answer_id = fingers_[0]; - XBT_DEBUG("Sending back a 'Find Successor Answer' to %s (mailbox %s): the successor of %d is %d", - message->issuer_host_name.c_str(), message->answer_to->get_cname(), message->request_id, - message->answer_id); + case MessageType::FIND_SUCCESSOR: + XBT_DEBUG("Received a 'Find Successor' request from %s for id %d", message->issuer_host_name.c_str(), + message->request_id); + // is my successor the successor? + if (is_in_interval(message->request_id, id_ + 1, fingers_[0])) { + message->type = MessageType::FIND_SUCCESSOR_ANSWER; + message->answer_id = fingers_[0]; + XBT_DEBUG("Sending back a 'Find Successor Answer' to %s (mailbox %s): the successor of %d is %d", + message->issuer_host_name.c_str(), message->answer_to->get_cname(), message->request_id, + message->answer_id); + message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy); + } else { + // otherwise, forward the request to the closest preceding finger in my table + int closest = closestPrecedingFinger(message->request_id); + XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d", + message->request_id, closest); + simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(closest)); + mailbox->put_init(message, 10)->detach(ChordMessage::destroy); + } + break; + + case MessageType::GET_PREDECESSOR: + XBT_DEBUG("Receiving a 'Get Predecessor' request from %s", message->issuer_host_name.c_str()); + message->type = MessageType::GET_PREDECESSOR_ANSWER; + message->answer_id = pred_id_; + XBT_DEBUG("Sending back a 'Get Predecessor Answer' to %s via mailbox '%s': my predecessor is %d", + message->issuer_host_name.c_str(), message->answer_to->get_cname(), message->answer_id); message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy); - } else { - // otherwise, forward the request to the closest preceding finger in my table - int closest = closestPrecedingFinger(message->request_id); - XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d", - message->request_id, closest); - simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(closest)); - mailbox->put_init(message, 10)->detach(ChordMessage::destroy); - } - break; - - case GET_PREDECESSOR: - XBT_DEBUG("Receiving a 'Get Predecessor' request from %s", message->issuer_host_name.c_str()); - message->type = GET_PREDECESSOR_ANSWER; - message->answer_id = pred_id_; - XBT_DEBUG("Sending back a 'Get Predecessor Answer' to %s via mailbox '%s': my predecessor is %d", - message->issuer_host_name.c_str(), message->answer_to->get_cname(), message->answer_id); - message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy); - break; - - case NOTIFY: - // someone is telling me that he may be my new predecessor - XBT_DEBUG("Receiving a 'Notify' request from %s", message->issuer_host_name.c_str()); - notify(message->request_id); - delete message; - break; + break; + + case MessageType::NOTIFY: + // someone is telling me that he may be my new predecessor + XBT_DEBUG("Receiving a 'Notify' request from %s", message->issuer_host_name.c_str()); + notify(message->request_id); + delete message; + break; + + case MessageType::PREDECESSOR_LEAVING: + // my predecessor is about to quit + XBT_DEBUG("Receiving a 'Predecessor Leaving' message from %s", message->issuer_host_name.c_str()); + // modify my predecessor + setPredecessor(message->request_id); + delete message; + /*TODO : + >> notify my new predecessor + >> send a notify_predecessors !! + */ + break; + + case MessageType::SUCCESSOR_LEAVING: + // my successor is about to quit + XBT_DEBUG("Receiving a 'Successor Leaving' message from %s", message->issuer_host_name.c_str()); + // modify my successor FIXME : this should be implicit ? + setFinger(0, message->request_id); + delete message; + /* TODO + >> notify my new successor + >> update my table & predecessors table */ + break; + + case MessageType::PREDECESSOR_ALIVE: + XBT_DEBUG("Receiving a 'Predecessor Alive' request from %s", message->issuer_host_name.c_str()); + message->type = MessageType::PREDECESSOR_ALIVE_ANSWER; + XBT_DEBUG("Sending back a 'Predecessor Alive Answer' to %s (mailbox %s)", message->issuer_host_name.c_str(), + message->answer_to->get_cname()); + message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy); + break; - case PREDECESSOR_LEAVING: - // my predecessor is about to quit - XBT_DEBUG("Receiving a 'Predecessor Leaving' message from %s", message->issuer_host_name.c_str()); - // modify my predecessor - setPredecessor(message->request_id); - delete message; - /*TODO : - >> notify my new predecessor - >> send a notify_predecessors !! - */ - break; - - case SUCCESSOR_LEAVING: - // my successor is about to quit - XBT_DEBUG("Receiving a 'Successor Leaving' message from %s", message->issuer_host_name.c_str()); - // modify my successor FIXME : this should be implicit ? - setFinger(0, message->request_id); - delete message; - /* TODO - >> notify my new successor - >> update my table & predecessors table */ - break; - - case PREDECESSOR_ALIVE: - XBT_DEBUG("Receiving a 'Predecessor Alive' request from %s", message->issuer_host_name.c_str()); - message->type = PREDECESSOR_ALIVE_ANSWER; - XBT_DEBUG("Sending back a 'Predecessor Alive Answer' to %s (mailbox %s)", message->issuer_host_name.c_str(), - message->answer_to->get_cname()); - message->answer_to->put_init(message, 10)->detach(ChordMessage::destroy); - break; - - default: - XBT_DEBUG("Ignoring unexpected message: %d from %s", message->type, message->issuer_host_name.c_str()); - delete message; + default: + XBT_DEBUG("Ignoring unexpected message: %d from %s", static_cast(message->type), + message->issuer_host_name.c_str()); + delete message; } } diff --git a/examples/s4u/dht-chord/s4u-dht-chord.hpp b/examples/s4u/dht-chord/s4u-dht-chord.hpp index 4b9e85f8d6..d303e7fd76 100644 --- a/examples/s4u/dht-chord/s4u-dht-chord.hpp +++ b/examples/s4u/dht-chord/s4u-dht-chord.hpp @@ -22,7 +22,7 @@ extern int nb_keys; extern int timeout; /* Types of tasks exchanged between nodes. */ -enum e_message_type_t { +enum class MessageType { FIND_SUCCESSOR, FIND_SUCCESSOR_ANSWER, GET_PREDECESSOR, @@ -36,14 +36,14 @@ enum e_message_type_t { class ChordMessage { public: - e_message_type_t type; // type of message + MessageType type; // type of message std::string issuer_host_name = simgrid::s4u::this_actor::get_host()->get_name(); // used for logging int request_id = -1; // id (used by some types of messages) int request_finger = 1; // finger parameter (used by some types of messages) int answer_id = -1; // answer (used by some types of messages) simgrid::s4u::Mailbox* answer_to = nullptr; // mailbox to send an answer to (if any) - explicit ChordMessage(e_message_type_t type) : type(type) {} + explicit ChordMessage(MessageType type) : type(type) {} static void destroy(void* message); }; diff --git a/include/simgrid/Exception.hpp b/include/simgrid/Exception.hpp index 23695038ab..833cc025d8 100644 --- a/include/simgrid/Exception.hpp +++ b/include/simgrid/Exception.hpp @@ -60,19 +60,19 @@ public: class XBT_PUBLIC ImpossibleError : public std::logic_error { public: - explicit ImpossibleError(const std::string& arg) : std::logic_error(arg) {} + using std::logic_error::logic_error; ~ImpossibleError() override; }; class XBT_PUBLIC InitializationError : public std::logic_error { public: - explicit InitializationError(const std::string& arg) : std::logic_error(arg) {} + using std::logic_error::logic_error; ~InitializationError() override; }; class XBT_PUBLIC UnimplementedError : public std::logic_error { public: - explicit UnimplementedError(const std::string& arg) : std::logic_error(arg) {} + using std::logic_error::logic_error; ~UnimplementedError() override; }; @@ -81,8 +81,8 @@ public: /** Ancestor class of all SimGrid exception */ class Exception : public std::runtime_error { public: - Exception(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message) - : std::runtime_error(std::move(message)), throwpoint_(std::move(throwpoint)) + Exception(const simgrid::xbt::ThrowPoint& throwpoint, const std::string& message) + : std::runtime_error(message), throwpoint_(throwpoint) { } Exception(const Exception&) = default; @@ -104,12 +104,7 @@ private: /** Exception raised when a timeout elapsed */ class TimeoutException : public Exception { public: - TimeoutException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message) - : Exception(std::move(throwpoint), std::move(message)) - { - } - TimeoutException(const TimeoutException&) = default; - TimeoutException(TimeoutException&&) noexcept = default; + using Exception::Exception; ~TimeoutException() override; }; @@ -118,72 +113,42 @@ using TimeoutError XBT_ATTRIB_DEPRECATED_v328("Please use simgrid::TimeoutExcept /** Exception raised when a host fails */ class HostFailureException : public Exception { public: - HostFailureException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message) - : Exception(std::move(throwpoint), std::move(message)) - { - } - HostFailureException(const HostFailureException&) = default; - HostFailureException(HostFailureException&&) noexcept = default; + using Exception::Exception; ~HostFailureException() override; }; /** Exception raised when a communication fails because of the network or because of the remote host */ class NetworkFailureException : public Exception { public: - NetworkFailureException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message) - : Exception(std::move(throwpoint), std::move(message)) - { - } - NetworkFailureException(const NetworkFailureException&) = default; - NetworkFailureException(NetworkFailureException&&) noexcept = default; + using Exception::Exception; ~NetworkFailureException() override; }; /** Exception raised when a storage fails */ class StorageFailureException : public Exception { public: - StorageFailureException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message) - : Exception(std::move(throwpoint), std::move(message)) - { - } - StorageFailureException(const StorageFailureException&) = default; - StorageFailureException(StorageFailureException&&) noexcept = default; + using Exception::Exception; ~StorageFailureException() override; }; /** Exception raised when a VM fails */ class VmFailureException : public Exception { public: - VmFailureException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message) - : Exception(std::move(throwpoint), std::move(message)) - { - } - VmFailureException(const VmFailureException&) = default; - VmFailureException(VmFailureException&&) noexcept = default; + using Exception::Exception; ~VmFailureException() override; }; /** Exception raised when something got canceled before completion */ class CancelException : public Exception { public: - CancelException(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message) - : Exception(std::move(throwpoint), std::move(message)) - { - } - CancelException(const CancelException&) = default; - CancelException(CancelException&&) noexcept = default; + using Exception::Exception; ~CancelException() override; }; /** Exception raised when something is going wrong during the simulation tracing */ class TracingError : public Exception { public: - TracingError(simgrid::xbt::ThrowPoint&& throwpoint, std::string&& message) - : Exception(std::move(throwpoint), std::move(message)) - { - } - TracingError(const TracingError&) = default; - TracingError(TracingError&&) noexcept = default; + using Exception::Exception; ~TracingError() override; }; diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index a0e5a84b05..5dcdecee3b 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -146,9 +146,9 @@ typedef sg_vm_t msg_vm_t; XBT_PUBLIC msg_vm_t MSG_vm_create_core(msg_host_t pm, const char* name); XBT_PUBLIC msg_vm_t MSG_vm_create_multicore(msg_host_t pm, const char* name, int coreAmount); -XBT_PUBLIC int MSG_vm_is_created(msg_vm_t vm); -XBT_PUBLIC int MSG_vm_is_running(msg_vm_t vm); -XBT_PUBLIC int MSG_vm_is_suspended(msg_vm_t vm); +XBT_PUBLIC int MSG_vm_is_created(const_sg_vm_t vm); +XBT_PUBLIC int MSG_vm_is_running(const_sg_vm_t vm); +XBT_PUBLIC int MSG_vm_is_suspended(const_sg_vm_t vm); XBT_PUBLIC const char* MSG_vm_get_name(const_sg_vm_t vm); XBT_PUBLIC void MSG_vm_set_ramsize(msg_vm_t vm, size_t size); diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index 141cd5d02a..764bc089c6 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -63,19 +63,19 @@ public: template void register_actor(const std::string& name) { kernel::actor::ActorCodeFactory code_factory = [](std::vector args) { - return kernel::actor::ActorCode([args] { + return kernel::actor::ActorCode([args = std::move(args)]() mutable { F code(std::move(args)); code(); }); }; - register_function(name, std::move(code_factory)); + register_function(name, code_factory); } template void register_actor(const std::string& name, F code) { kernel::actor::ActorCodeFactory code_factory = [code](std::vector args) { - return kernel::actor::ActorCode([code, args] { code(std::move(args)); }); + return kernel::actor::ActorCode([code, args = std::move(args)]() mutable { code(std::move(args)); }); }; - register_function(name, std::move(code_factory)); + register_function(name, code_factory); } void load_deployment(const std::string& deploy) const; diff --git a/include/simgrid/smpi/replay.hpp b/include/simgrid/smpi/replay.hpp index 4da7a7ee7a..4b27c49b81 100644 --- a/include/simgrid/smpi/replay.hpp +++ b/include/simgrid/smpi/replay.hpp @@ -312,13 +312,13 @@ public: class GatherAction : public ReplayAction { public: - explicit GatherAction(const std::string& name) : ReplayAction(name) {} + using ReplayAction::ReplayAction; void kernel(xbt::ReplayAction& action) override; }; class GatherVAction : public ReplayAction { public: - explicit GatherVAction(const std::string& name) : ReplayAction(name) {} + using ReplayAction::ReplayAction; void kernel(xbt::ReplayAction& action) override; }; diff --git a/include/simgrid/vm.h b/include/simgrid/vm.h index a89e274e15..8a6592af2e 100644 --- a/include/simgrid/vm.h +++ b/include/simgrid/vm.h @@ -17,9 +17,9 @@ SG_BEGIN_DECL XBT_PUBLIC sg_vm_t sg_vm_create_core(sg_host_t pm, const char* name); XBT_PUBLIC sg_vm_t sg_vm_create_multicore(sg_host_t pm, const char* name, int core_amount); -XBT_PUBLIC int sg_vm_is_created(sg_vm_t vm); -XBT_PUBLIC int sg_vm_is_running(sg_vm_t vm); -XBT_PUBLIC int sg_vm_is_suspended(sg_vm_t vm); +XBT_PUBLIC int sg_vm_is_created(const_sg_vm_t vm); +XBT_PUBLIC int sg_vm_is_running(const_sg_vm_t vm); +XBT_PUBLIC int sg_vm_is_suspended(const_sg_vm_t vm); XBT_PUBLIC const char* sg_vm_get_name(const_sg_vm_t vm); XBT_PUBLIC void sg_vm_set_ramsize(sg_vm_t vm, size_t size); diff --git a/include/xbt/config.hpp b/include/xbt/config.hpp index 10440094fd..7d5572cfe2 100644 --- a/include/xbt/config.hpp +++ b/include/xbt/config.hpp @@ -117,7 +117,7 @@ template void bind_flag(T& value, const char* name, std::initializer_list aliases, const char* description) { bind_flag(value, name, description); - alias(name, std::move(aliases)); + alias(name, aliases); } /** Bind a variable to configuration flag @@ -146,7 +146,7 @@ typename std::enable_if()(std::declv bind_flag(T& value, const char* name, std::initializer_list aliases, const char* description, F callback) { bind_flag(value, name, description, std::move(callback)); - alias(name, std::move(aliases)); + alias(name, aliases); } template @@ -177,7 +177,7 @@ bind_flag(T& value, const char* name, std::initializer_list aliases const std::map& valid_values, F callback) { bind_flag(value, name, description, valid_values, std::move(callback)); - alias(name, std::move(aliases)); + alias(name, aliases); } /** Bind a variable to configuration flag @@ -228,7 +228,7 @@ public: Flag(const char* name, std::initializer_list aliases, const char* desc, T value) : value_(value), name_(name) { - simgrid::config::bind_flag(value_, name, std::move(aliases), desc); + simgrid::config::bind_flag(value_, name, aliases, desc); } /* A constructor accepting a callback that will be passed the parameter. @@ -243,7 +243,7 @@ public: Flag(const char* name, std::initializer_list aliases, const char* desc, T value, F callback) : value_(value), name_(name) { - simgrid::config::bind_flag(value_, name, std::move(aliases), desc, std::move(callback)); + simgrid::config::bind_flag(value_, name, aliases, desc, std::move(callback)); } /* A constructor accepting a map of valid values -> their description, @@ -262,7 +262,7 @@ public: const std::map& valid_values, F callback) : value_(value), name_(name) { - simgrid::config::bind_flag(value_, name, std::move(aliases), desc, valid_values, std::move(callback)); + simgrid::config::bind_flag(value_, name, aliases, desc, valid_values, std::move(callback)); } // No copy: diff --git a/include/xbt/random.hpp b/include/xbt/random.hpp index 7d4e4ef30b..b8a2474854 100644 --- a/include/xbt/random.hpp +++ b/include/xbt/random.hpp @@ -85,8 +85,7 @@ public: */ class XBT_PUBLIC StdRandom : public Random { public: - StdRandom() = default; - explicit StdRandom(int seed) : Random(seed) {} + using Random::Random; int uniform_int(int min, int max) override; double uniform_real(double min, double max) override; @@ -100,8 +99,7 @@ public: */ class XBT_PUBLIC XbtRandom : public Random { public: - XbtRandom() = default; - explicit XbtRandom(int seed) : Random(seed) {} + using Random::Random; int uniform_int(int min, int max) override; double uniform_real(double min, double max) override; diff --git a/include/xbt/string.hpp b/include/xbt/string.hpp index 8ae6756303..0a50fb6e71 100644 --- a/include/xbt/string.hpp +++ b/include/xbt/string.hpp @@ -101,7 +101,7 @@ public: string() : string(&NUL, 0) {} explicit string(const char* s) : string(s, strlen(s)) {} string(string const& s) : string(s.c_str(), s.size()) {} - string(string&& s) noexcept : str(std::move(s.str)) + string(string&& s) noexcept : str(s.str) { s.str.len = 0; s.str.data = &NUL; diff --git a/src/bindings/java/jmsg_vm.cpp b/src/bindings/java/jmsg_vm.cpp index 639c15d309..96a9550597 100644 --- a/src/bindings/java/jmsg_vm.cpp +++ b/src/bindings/java/jmsg_vm.cpp @@ -37,13 +37,13 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_nativeInit(JNIEnv *env, jclass cl JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isCreated(JNIEnv* env, jobject jvm) { - sg_vm_t vm = jvm_get_native(env, jvm); + const_sg_vm_t vm = jvm_get_native(env, jvm); return sg_vm_is_created(vm); } JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isRunning(JNIEnv* env, jobject jvm) { - sg_vm_t vm = jvm_get_native(env, jvm); + const_sg_vm_t vm = jvm_get_native(env, jvm); return sg_vm_is_running(vm); } @@ -55,7 +55,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isMigrating(JNIEnv* env, jobj JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_VM_isSuspended(JNIEnv* env, jobject jvm) { - sg_vm_t vm = jvm_get_native(env, jvm); + const_sg_vm_t vm = jvm_get_native(env, jvm); return sg_vm_is_suspended(vm); } diff --git a/src/instr/instr_config.cpp b/src/instr/instr_config.cpp index a1be1875e4..cf95509dcd 100644 --- a/src/instr/instr_config.cpp +++ b/src/instr/instr_config.cpp @@ -218,7 +218,7 @@ int trace_precision; *************/ xbt::signal Container::on_creation; xbt::signal Container::on_destruction; -xbt::signal Type::on_creation; +xbt::signal Type::on_creation; xbt::signal LinkType::on_creation; xbt::signal PajeEvent::on_creation; xbt::signal PajeEvent::on_destruction; @@ -230,9 +230,10 @@ static void on_container_creation_paje(const Container& c) double timestamp = SIMIX_get_clock(); std::stringstream stream; - XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_CreateContainer, timestamp); + XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, static_cast(PajeEventType::CreateContainer), + timestamp); - stream << std::fixed << std::setprecision(trace_precision) << PAJE_CreateContainer << " "; + stream << std::fixed << std::setprecision(trace_precision) << PajeEventType::CreateContainer << " "; stream << timestamp << " " << c.get_id() << " " << c.type_->get_id() << " " << c.father_->get_id() << " \""; if (c.get_name().find("rank-") != 0) stream << c.get_name() << "\""; @@ -251,9 +252,10 @@ static void on_container_destruction_paje(const Container& c) std::stringstream stream; double timestamp = SIMIX_get_clock(); - XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_DestroyContainer, timestamp); + XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, static_cast(PajeEventType::DestroyContainer), + timestamp); - stream << std::fixed << std::setprecision(trace_precision) << PAJE_DestroyContainer << " "; + stream << std::fixed << std::setprecision(trace_precision) << PajeEventType::DestroyContainer << " "; stream << timestamp << " " << c.type_->get_id() << " " << c.get_id(); XBT_DEBUG("Dump %s", stream.str().c_str()); tracing_file << stream.str() << std::endl; @@ -262,7 +264,8 @@ static void on_container_destruction_paje(const Container& c) static void on_container_creation_ti(const Container& c) { - XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_CreateContainer, SIMIX_get_clock()); + XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, static_cast(PajeEventType::CreateContainer), + SIMIX_get_clock()); // if we are in the mode with only one file static std::ofstream* ti_unique_file = nullptr; @@ -300,8 +303,8 @@ static void on_container_destruction_ti(const Container& c) static void on_entity_value_creation(const EntityValue& value) { std::stringstream stream; - XBT_DEBUG("%s: event_type=%u", __func__, PAJE_DefineEntityValue); - stream << std::fixed << std::setprecision(trace_precision) << PAJE_DefineEntityValue; + XBT_DEBUG("%s: event_type=%u", __func__, static_cast(PajeEventType::DefineEntityValue)); + stream << std::fixed << std::setprecision(trace_precision) << PajeEventType::DefineEntityValue; stream << " " << value.get_id() << " " << value.get_father()->get_id() << " " << value.get_name(); if (not value.get_color().empty()) stream << " \"" << value.get_color() << "\""; @@ -311,7 +314,8 @@ static void on_entity_value_creation(const EntityValue& value) static void on_event_creation(PajeEvent& event) { - XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, event.eventType_, trace_precision, event.timestamp_); + XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, static_cast(event.eventType_), trace_precision, + event.timestamp_); event.stream_ << std::fixed << std::setprecision(trace_precision); event.stream_ << event.eventType_ << " " << event.timestamp_ << " "; event.stream_ << event.get_type()->get_id() << " " << event.get_container()->get_id(); @@ -329,14 +333,14 @@ static void on_state_event_destruction(const StateEvent& event) *tracing_files.at(event.get_container()) << event.stream_.str() << std::endl; } -static void on_type_creation(const Type& type, e_event_type event_type) +static void on_type_creation(const Type& type, PajeEventType event_type) { - if (event_type == PAJE_DefineLinkType) + if (event_type == PajeEventType::DefineLinkType) return; // this kind of type has to be handled differently std::stringstream stream; stream << std::fixed << std::setprecision(trace_precision); - XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, event_type, trace_precision, 0.); + XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, static_cast(event_type), trace_precision, 0.); stream << event_type << " " << type.get_id() << " " << type.get_father()->get_id() << " " << type.get_name(); if (type.is_colored()) stream << " \"" << type.get_color() << "\""; @@ -347,8 +351,9 @@ static void on_type_creation(const Type& type, e_event_type event_type) static void on_link_type_creation(const Type& type, const Type& source, const Type& dest) { std::stringstream stream; - XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, PAJE_DefineLinkType, trace_precision, 0.); - stream << PAJE_DefineLinkType << " " << type.get_id() << " " << type.get_father()->get_id(); + XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, static_cast(PajeEventType::DefineLinkType), + trace_precision, 0.); + stream << PajeEventType::DefineLinkType << " " << type.get_id() << " " << type.get_father()->get_id(); stream << " " << source.get_id() << " " << dest.get_id() << " " << type.get_name(); XBT_DEBUG("Dump %s", stream.str().c_str()); tracing_file << stream.str() << std::endl; diff --git a/src/instr/instr_paje_events.cpp b/src/instr/instr_paje_events.cpp index 6ba97ee705..d469422187 100644 --- a/src/instr/instr_paje_events.cpp +++ b/src/instr/instr_paje_events.cpp @@ -13,7 +13,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_events, instr, "Paje tracing event sy namespace simgrid { namespace instr { -PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, e_event_type eventType) +PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, PajeEventType eventType) : container_(container), type_(type), timestamp_(timestamp), eventType_(eventType) { on_creation(*this); @@ -25,7 +25,7 @@ PajeEvent::~PajeEvent() on_destruction(*this); } -StateEvent::StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra) +StateEvent::StateEvent(Container* container, Type* type, PajeEventType event_type, EntityValue* value, TIData* extra) : PajeEvent::PajeEvent(container, type, SIMIX_get_clock(), event_type), value(value), extra_(extra) { #if HAVE_SMPI @@ -53,7 +53,7 @@ void LinkEvent::print() void StateEvent::print() { if (trace_format == TraceFormat::Paje) { - if (value != nullptr) // PAJE_PopState Event does not need to have a value + if (value != nullptr) // PajeEventType::PopState Event does not need to have a value stream_ << " " << value->get_id(); if (TRACE_display_sizes()) diff --git a/src/instr/instr_paje_events.hpp b/src/instr/instr_paje_events.hpp index 2527bd7266..dd24ec5a36 100644 --- a/src/instr/instr_paje_events.hpp +++ b/src/instr/instr_paje_events.hpp @@ -17,27 +17,32 @@ namespace instr { class EntityValue; class TIData; -enum e_event_type : unsigned int { - PAJE_DefineContainerType, - PAJE_DefineVariableType, - PAJE_DefineStateType, - PAJE_DefineEventType, - PAJE_DefineLinkType, - PAJE_DefineEntityValue, - PAJE_CreateContainer, - PAJE_DestroyContainer, - PAJE_SetVariable, - PAJE_AddVariable, - PAJE_SubVariable, - PAJE_SetState, - PAJE_PushState, - PAJE_PopState, - PAJE_ResetState, - PAJE_StartLink, - PAJE_EndLink, - PAJE_NewEvent +enum class PajeEventType : unsigned int { + DefineContainerType, + DefineVariableType, + DefineStateType, + DefineEventType, + DefineLinkType, + DefineEntityValue, + CreateContainer, + DestroyContainer, + SetVariable, + AddVariable, + SubVariable, + SetState, + PushState, + PopState, + ResetState, + StartLink, + EndLink, + NewEvent }; +inline std::ostream& operator<<(std::ostream& os, PajeEventType event) +{ + return os << static_cast::type>(event); +} + class PajeEvent { Container* container_; Type* type_; @@ -46,10 +51,10 @@ public: static xbt::signal on_destruction; double timestamp_; - e_event_type eventType_; + PajeEventType eventType_; std::stringstream stream_; - PajeEvent(Container* container, Type* type, double timestamp, e_event_type eventType); + PajeEvent(Container* container, Type* type, double timestamp, PajeEventType eventType); virtual ~PajeEvent(); Container* get_container() const { return container_; } @@ -63,7 +68,7 @@ class VariableEvent : public PajeEvent { double value_; public: - VariableEvent(double timestamp, Container* container, Type* type, e_event_type event_type, double value) + VariableEvent(double timestamp, Container* container, Type* type, PajeEventType event_type, double value) : PajeEvent::PajeEvent(container, type, timestamp, event_type), value_(value) { } @@ -80,7 +85,7 @@ class StateEvent : public PajeEvent { public: static xbt::signal on_destruction; - StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra); + StateEvent(Container* container, Type* type, PajeEventType event_type, EntityValue* value, TIData* extra); ~StateEvent() override { on_destruction(*this); } bool has_extra() const { return extra_ != nullptr; } void print() override; @@ -93,7 +98,7 @@ class LinkEvent : public PajeEvent { int size_ = -1; public: - LinkEvent(Container* container, Type* type, e_event_type event_type, Container* sourceContainer, + LinkEvent(Container* container, Type* type, PajeEventType event_type, Container* sourceContainer, const std::string& value, const std::string& key, int size) : PajeEvent(container, type, SIMIX_get_clock(), event_type) , endpoint_(sourceContainer) @@ -110,7 +115,7 @@ class NewEvent : public PajeEvent { public: NewEvent(double timestamp, Container* container, Type* type, EntityValue* value) - : PajeEvent::PajeEvent(container, type, timestamp, PAJE_NewEvent), value(value) + : PajeEvent::PajeEvent(container, type, timestamp, PajeEventType::NewEvent), value(value) { } void print() override; diff --git a/src/instr/instr_paje_header.cpp b/src/instr/instr_paje_header.cpp index 594462811f..73f4559fd8 100644 --- a/src/instr/instr_paje_header.cpp +++ b/src/instr/instr_paje_header.cpp @@ -45,7 +45,7 @@ void dump_comment_file(const std::string& filename) void dump_header(bool basic, bool display_sizes) { // Types - tracing_file << "%EventDef PajeDefineContainerType " << PAJE_DefineContainerType << std::endl; + tracing_file << "%EventDef PajeDefineContainerType " << PajeEventType::DefineContainerType << std::endl; tracing_file << "% Alias string" << std::endl; if (basic) tracing_file << "% ContainerType string" << std::endl; @@ -55,26 +55,26 @@ void dump_header(bool basic, bool display_sizes) tracing_file << "% Name string" << std::endl; tracing_file << "%EndEventDef" << std::endl; - tracing_file << "%EventDef PajeDefineVariableType " << PAJE_DefineVariableType << std::endl; + tracing_file << "%EventDef PajeDefineVariableType " << PajeEventType::DefineVariableType << std::endl; tracing_file << "% Alias string" << std::endl; tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl; tracing_file << "% Name string" << std::endl; tracing_file << "% Color color" << std::endl; tracing_file << "%EndEventDef" << std::endl; - tracing_file << "%EventDef PajeDefineStateType " << PAJE_DefineStateType << std::endl; + tracing_file << "%EventDef PajeDefineStateType " << PajeEventType::DefineStateType << std::endl; tracing_file << "% Alias string" << std::endl; tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl; tracing_file << "% Name string" << std::endl; tracing_file << "%EndEventDef" << std::endl; - tracing_file << "%EventDef PajeDefineEventType " << PAJE_DefineEventType << std::endl; + tracing_file << "%EventDef PajeDefineEventType " << PajeEventType::DefineEventType << std::endl; tracing_file << "% Alias string" << std::endl; tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl; tracing_file << "% Name string" << std::endl; tracing_file << "%EndEventDef" << std::endl; - tracing_file << "%EventDef PajeDefineLinkType " << PAJE_DefineLinkType << std::endl; + tracing_file << "%EventDef PajeDefineLinkType " << PajeEventType::DefineLinkType << std::endl; tracing_file << "% Alias string" << std::endl; tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl; tracing_file << "% " << (basic ? "Source" : "Start") << "ContainerType string" << std::endl; @@ -83,7 +83,7 @@ void dump_header(bool basic, bool display_sizes) tracing_file << "%EndEventDef" << std::endl; // EntityValue - tracing_file << "%EventDef PajeDefineEntityValue " << PAJE_DefineEntityValue << std::endl; + tracing_file << "%EventDef PajeDefineEntityValue " << PajeEventType::DefineEntityValue << std::endl; tracing_file << "% Alias string" << std::endl; tracing_file << "% " << (basic ? "Entity" : "") << "Type string" << std::endl; tracing_file << "% Name string" << std::endl; @@ -91,7 +91,7 @@ void dump_header(bool basic, bool display_sizes) tracing_file << "%EndEventDef" << std::endl; // Container - tracing_file << "%EventDef PajeCreateContainer " << PAJE_CreateContainer << std::endl; + tracing_file << "%EventDef PajeCreateContainer " << PajeEventType::CreateContainer << std::endl; tracing_file << "% Time date" << std::endl; tracing_file << "% Alias string" << std::endl; tracing_file << "% Type string" << std::endl; @@ -99,28 +99,28 @@ void dump_header(bool basic, bool display_sizes) tracing_file << "% Name string" << std::endl; tracing_file << "%EndEventDef" << std::endl; - tracing_file << "%EventDef PajeDestroyContainer " << PAJE_DestroyContainer << std::endl; + tracing_file << "%EventDef PajeDestroyContainer " << PajeEventType::DestroyContainer << std::endl; tracing_file << "% Time date" << std::endl; tracing_file << "% Type string" << std::endl; tracing_file << "% Name string" << std::endl; tracing_file << "%EndEventDef" << std::endl; // Variable - tracing_file << "%EventDef PajeSetVariable " << PAJE_SetVariable << std::endl; + tracing_file << "%EventDef PajeSetVariable " << PajeEventType::SetVariable << std::endl; tracing_file << "% Time date" << std::endl; tracing_file << "% Type string" << std::endl; tracing_file << "% Container string" << std::endl; tracing_file << "% Value double" << std::endl; tracing_file << "%EndEventDef" << std::endl; - tracing_file << "%EventDef PajeAddVariable " << PAJE_AddVariable << std::endl; + tracing_file << "%EventDef PajeAddVariable " << PajeEventType::AddVariable << std::endl; tracing_file << "% Time date" << std::endl; tracing_file << "% Type string" << std::endl; tracing_file << "% Container string" << std::endl; tracing_file << "% Value double" << std::endl; tracing_file << "%EndEventDef" << std::endl; - tracing_file << "%EventDef PajeSubVariable " << PAJE_SubVariable << std::endl; + tracing_file << "%EventDef PajeSubVariable " << PajeEventType::SubVariable << std::endl; tracing_file << "% Time date" << std::endl; tracing_file << "% Type string" << std::endl; tracing_file << "% Container string" << std::endl; @@ -128,14 +128,14 @@ void dump_header(bool basic, bool display_sizes) tracing_file << "%EndEventDef" << std::endl; // State - tracing_file << "%EventDef PajeSetState " << PAJE_SetState << std::endl; + tracing_file << "%EventDef PajeSetState " << PajeEventType::SetState << std::endl; tracing_file << "% Time date" << std::endl; tracing_file << "% Type string" << std::endl; tracing_file << "% Container string" << std::endl; tracing_file << "% Value string" << std::endl; tracing_file << "%EndEventDef" << std::endl; - tracing_file << "%EventDef PajePushState " << PAJE_PushState << std::endl; + tracing_file << "%EventDef PajePushState " << PajeEventType::PushState << std::endl; tracing_file << "% Time date" << std::endl; tracing_file << "% Type string" << std::endl; tracing_file << "% Container string" << std::endl; @@ -151,14 +151,14 @@ void dump_header(bool basic, bool display_sizes) #endif tracing_file << "%EndEventDef" << std::endl; - tracing_file << "%EventDef PajePopState " << PAJE_PopState << std::endl; + tracing_file << "%EventDef PajePopState " << PajeEventType::PopState << std::endl; tracing_file << "% Time date" << std::endl; tracing_file << "% Type string" << std::endl; tracing_file << "% Container string" << std::endl; tracing_file << "%EndEventDef" << std::endl; if (not basic) { - tracing_file << "%EventDef PajeResetState " << PAJE_ResetState << std::endl; + tracing_file << "%EventDef PajeResetState " << PajeEventType::ResetState << std::endl; tracing_file << "% Time date" << std::endl; tracing_file << "% Type string" << std::endl; tracing_file << "% Container string" << std::endl; @@ -166,7 +166,7 @@ void dump_header(bool basic, bool display_sizes) } // Link - tracing_file << "%EventDef PajeStartLink " << PAJE_StartLink << std::endl; + tracing_file << "%EventDef PajeStartLink " << PajeEventType::StartLink << std::endl; tracing_file << "% Time date" << std::endl; tracing_file << "% Type string" << std::endl; tracing_file << "% Container string" << std::endl; @@ -177,7 +177,7 @@ void dump_header(bool basic, bool display_sizes) tracing_file << "% Size int" << std::endl; tracing_file << "%EndEventDef" << std::endl; - tracing_file << "%EventDef PajeEndLink " << PAJE_EndLink << std::endl; + tracing_file << "%EventDef PajeEndLink " << PajeEventType::EndLink << std::endl; tracing_file << "% Time date" << std::endl; tracing_file << "% Type string" << std::endl; tracing_file << "% Container string" << std::endl; @@ -187,7 +187,7 @@ void dump_header(bool basic, bool display_sizes) tracing_file << "%EndEventDef" << std::endl; // Event - tracing_file << "%EventDef PajeNewEvent " << PAJE_NewEvent << std::endl; + tracing_file << "%EventDef PajeNewEvent " << PajeEventType::NewEvent << std::endl; tracing_file << "% Time date" << std::endl; tracing_file << "% Type string" << std::endl; tracing_file << "% Container string" << std::endl; diff --git a/src/instr/instr_paje_trace.cpp b/src/instr/instr_paje_trace.cpp index 1c6c1c407b..44dc1ea5df 100644 --- a/src/instr/instr_paje_trace.cpp +++ b/src/instr/instr_paje_trace.cpp @@ -49,11 +49,12 @@ void dump_buffer(bool force) /* internal do the instrumentation module */ void PajeEvent::insert_into_buffer() { - XBT_DEBUG("%s: insert event_type=%u, timestamp=%f, buffersize=%zu)", __func__, eventType_, timestamp_, buffer.size()); + XBT_DEBUG("%s: insert event_type=%u, timestamp=%f, buffersize=%zu)", __func__, static_cast(eventType_), + timestamp_, buffer.size()); std::vector::reverse_iterator i; for (i = buffer.rbegin(); i != buffer.rend(); ++i) { PajeEvent* e1 = *i; - XBT_DEBUG("compare to %p is of type %u; timestamp:%f", e1, e1->eventType_, e1->timestamp_); + XBT_DEBUG("compare to %p is of type %u; timestamp:%f", e1, static_cast(e1->eventType_), e1->timestamp_); if (e1->timestamp_ <= timestamp_) break; } diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index 213c45b3b1..a075804b09 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -21,7 +21,7 @@ long long int new_paje_id() return type_id++; } -Type::Type(e_event_type event_type, const std::string& name, const std::string& alias, const std::string& color, +Type::Type(PajeEventType event_type, const std::string& name, const std::string& alias, const std::string& color, Type* father) : name_(name), color_(color), father_(father) { @@ -37,17 +37,18 @@ 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(get_issuer(), this, PAJE_SetState, get_entity_value(value_name), nullptr)); + events_.push_back(new StateEvent(get_issuer(), this, PajeEventType::SetState, get_entity_value(value_name), nullptr)); } void StateType::push_event(const std::string& value_name, TIData* extra) { - events_.push_back(new StateEvent(get_issuer(), this, PAJE_PushState, get_entity_value(value_name), extra)); + events_.push_back(new StateEvent(get_issuer(), this, PajeEventType::PushState, get_entity_value(value_name), extra)); } void StateType::push_event(const std::string& value_name) { - events_.push_back(new StateEvent(get_issuer(), this, PAJE_PushState, get_entity_value(value_name), nullptr)); + events_.push_back( + new StateEvent(get_issuer(), this, PajeEventType::PushState, get_entity_value(value_name), nullptr)); } void StateType::pop_event() @@ -57,7 +58,7 @@ void StateType::pop_event() void StateType::pop_event(TIData* extra) { - events_.push_back(new StateEvent(get_issuer(), this, PAJE_PopState, nullptr, extra)); + events_.push_back(new StateEvent(get_issuer(), this, PajeEventType::PopState, nullptr, extra)); } void VariableType::instr_event(double now, double delta, const char* resource, double value) @@ -82,17 +83,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, get_issuer(), this, PAJE_SetVariable, value)); + events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PajeEventType::SetVariable, value)); } void VariableType::add_event(double timestamp, double value) { - events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PAJE_AddVariable, value)); + events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PajeEventType::AddVariable, value)); } void VariableType::sub_event(double timestamp, double value) { - events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PAJE_SubVariable, value)); + events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PajeEventType::SubVariable, value)); } void LinkType::start_event(Container* startContainer, const std::string& value, const std::string& key) @@ -102,12 +103,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(get_issuer(), this, PAJE_StartLink, startContainer, value, key, size); + new LinkEvent(get_issuer(), this, PajeEventType::StartLink, startContainer, value, key, size); } void LinkType::end_event(Container* endContainer, const std::string& value, const std::string& key) { - new LinkEvent(get_issuer(), this, PAJE_EndLink, endContainer, value, key, -1); + new LinkEvent(get_issuer(), this, PajeEventType::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 269175c1e2..9b69640ac7 100644 --- a/src/instr/instr_paje_types.hpp +++ b/src/instr/instr_paje_types.hpp @@ -30,9 +30,9 @@ protected: Container* get_issuer() const { return issuer_; } public: - static xbt::signal on_creation; + static xbt::signal on_creation; - Type(e_event_type event_type, const std::string& name, const std::string& alias, const std::string& color, + Type(PajeEventType event_type, const std::string& name, const std::string& alias, const std::string& color, Type* father); virtual ~Type() = default; @@ -63,15 +63,16 @@ public: class ContainerType : public Type { public: - explicit ContainerType(const std::string& name) : Type(PAJE_DefineContainerType, name, name, "", nullptr){}; - ContainerType(const std::string& name, Type* father) : Type(PAJE_DefineContainerType, name, name, "", father){}; + explicit ContainerType(const std::string& name) : Type(PajeEventType::DefineContainerType, name, name, "", nullptr){}; + ContainerType(const std::string& name, Type* father) + : Type(PajeEventType::DefineContainerType, name, name, "", father){}; }; class VariableType : public Type { std::vector events_; public: VariableType(const std::string& name, const std::string& color, Type* father) - : Type(PAJE_DefineVariableType, name, name, color, father) + : Type(PajeEventType::DefineVariableType, name, name, color, father) { } void instr_event(double now, double delta, const char* resource, double value); @@ -83,9 +84,9 @@ public: class ValueType : public Type { public: std::map values_; - ValueType(e_event_type event_type, const std::string& name, const std::string& alias, Type* father) + ValueType(PajeEventType event_type, const std::string& name, const std::string& alias, Type* father) : Type(event_type, name, alias, "", father){}; - ValueType(e_event_type event_type, const std::string& name, Type* father) + ValueType(PajeEventType event_type, const std::string& name, Type* father) : Type(event_type, name, name, "", father){}; ~ValueType() override = default; void add_entity_value(const std::string& name, const std::string& color); @@ -97,7 +98,7 @@ class LinkType : public ValueType { public: static xbt::signal on_creation; LinkType(const std::string& name, const Type* source, const Type* dest, const std::string& alias, Type* father) - : ValueType(PAJE_DefineLinkType, name, alias, father) + : ValueType(PajeEventType::DefineLinkType, name, alias, father) { on_creation(*this, *source, *dest); } @@ -108,13 +109,13 @@ public: class EventType : public ValueType { public: - EventType(const std::string& name, Type* father) : ValueType(PAJE_DefineEventType, name, father) {} + EventType(const std::string& name, Type* father) : ValueType(PajeEventType::DefineEventType, name, father) {} }; class StateType : public ValueType { std::vector events_; public: - StateType(const std::string& name, Type* father) : ValueType(PAJE_DefineStateType, name, father) {} + StateType(const std::string& name, Type* father) : ValueType(PajeEventType::DefineStateType, name, father) {} void set_event(const std::string& value_name); void push_event(const std::string& value_name); void push_event(const std::string& value_name, TIData* extra); diff --git a/src/instr/jedule/jedule_sd_binding.cpp b/src/instr/jedule/jedule_sd_binding.cpp index 4ca1e45820..3d8e88779a 100644 --- a/src/instr/jedule/jedule_sd_binding.cpp +++ b/src/instr/jedule/jedule_sd_binding.cpp @@ -22,7 +22,7 @@ void jedule_log_sd_event(const_SD_task_t task) simgrid::jedule::Event event(std::string(SD_task_get_name(task)), SD_task_get_start_time(task), SD_task_get_finish_time(task), "SD"); event.add_resources(*task->allocation); - my_jedule->add_event(std::move(event)); + my_jedule->add_event(event); } void jedule_sd_init() diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index e631755eb2..fa893bd00e 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -350,8 +350,7 @@ s4u::Actor* ActorImpl::restart() context::Context::self()->get_actor()->kill(this); // start the new actor - ActorImplPtr actor = - ActorImpl::create(arg.name, std::move(arg.code), arg.data, arg.host, arg.properties.get(), nullptr); + ActorImplPtr actor = ActorImpl::create(arg.name, arg.code, arg.data, arg.host, arg.properties.get(), nullptr); *actor->on_exit = std::move(*arg.on_exit); actor->set_kill_time(arg.kill_time); actor->set_auto_restart(arg.auto_restart); diff --git a/src/kernel/lmm/maxmin.hpp b/src/kernel/lmm/maxmin.hpp index f525dfa55b..5fd382799d 100644 --- a/src/kernel/lmm/maxmin.hpp +++ b/src/kernel/lmm/maxmin.hpp @@ -553,7 +553,7 @@ private: class XBT_PUBLIC FairBottleneck : public System { public: - explicit FairBottleneck(bool selective_update) : System(selective_update) {} + using System::System; void solve() final { bottleneck_solve(); } private: diff --git a/src/kernel/routing/DragonflyZone.cpp b/src/kernel/routing/DragonflyZone.cpp index b6f9584697..e310310bfe 100644 --- a/src/kernel/routing/DragonflyZone.cpp +++ b/src/kernel/routing/DragonflyZone.cpp @@ -152,7 +152,7 @@ void DragonflyZone::generate_link(const std::string& id, int numlinks, resource: linkTemplate.bandwidths.push_back(this->bw_ * numlinks); linkTemplate.latency = this->lat_; linkTemplate.policy = this->sharing_policy_; - linkTemplate.id = std::move(id); + linkTemplate.id = id; sg_platf_new_link(&linkTemplate); XBT_DEBUG("Generating link %s", linkTemplate.id.c_str()); resource::LinkImpl* link; diff --git a/src/mc/inspect/DwarfExpression.hpp b/src/mc/inspect/DwarfExpression.hpp index c6258b302f..3a94b47239 100644 --- a/src/mc/inspect/DwarfExpression.hpp +++ b/src/mc/inspect/DwarfExpression.hpp @@ -53,7 +53,7 @@ struct ExpressionContext { /** When an error happens in the execution of a DWARF expression */ class evaluation_error : public std::runtime_error { public: - explicit evaluation_error(const char* what) : std::runtime_error(what) {} + using std::runtime_error::runtime_error; }; /** A stack for evaluating a DWARF expression diff --git a/src/mc/remote/RemoteSimulation.cpp b/src/mc/remote/RemoteSimulation.cpp index 294d641ba0..ceb818df3c 100644 --- a/src/mc/remote/RemoteSimulation.cpp +++ b/src/mc/remote/RemoteSimulation.cpp @@ -535,7 +535,7 @@ void RemoteSimulation::ignore_region(std::uint64_t addr, std::size_t size) void RemoteSimulation::ignore_heap(IgnoredHeapRegion const& region) { if (ignored_heap_.empty()) { - ignored_heap_.push_back(std::move(region)); + ignored_heap_.push_back(region); return; } diff --git a/src/mc/sosp/Snapshot.cpp b/src/mc/sosp/Snapshot.cpp index 5393c8fcdf..86c806c7e9 100644 --- a/src/mc/sosp/Snapshot.cpp +++ b/src/mc/sosp/Snapshot.cpp @@ -229,7 +229,7 @@ void Snapshot::add_region(RegionType type, ObjectInformation* object_info, void* auto* region = new Region(type, start_addr, size); region->object_info(object_info); - snapshot_regions_.push_back(std::unique_ptr(std::move(region))); + snapshot_regions_.push_back(std::unique_ptr(region)); } void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr address, ReadOptions options) const diff --git a/src/mc/sosp/Snapshot_test.cpp b/src/mc/sosp/Snapshot_test.cpp index 633c89af78..f253bff778 100644 --- a/src/mc/sosp/Snapshot_test.cpp +++ b/src/mc/sosp/Snapshot_test.cpp @@ -82,11 +82,7 @@ snap_test_helper::prologue_return snap_test_helper::prologue(int n) INFO("Could not allocate destination memory"); REQUIRE(source != MAP_FAILED); - return {.size = byte_size, - .src = source, - .dstn = destination, - .region0 = std::move(region0), - .region = std::move(region)}; + return {.size = byte_size, .src = source, .dstn = destination, .region0 = region0, .region = region}; } void snap_test_helper::read_whole_region() diff --git a/src/msg/msg_legacy.cpp b/src/msg/msg_legacy.cpp index 4adb63186c..eb5ce0cb1c 100644 --- a/src/msg/msg_legacy.cpp +++ b/src/msg/msg_legacy.cpp @@ -415,15 +415,15 @@ sg_vm_t MSG_vm_create_multicore(sg_host_t pm, const char* name, int coreAmount) { return sg_vm_create_multicore(pm, name, coreAmount); } -int MSG_vm_is_created(sg_vm_t vm) +int MSG_vm_is_created(const_sg_vm_t vm) { return sg_vm_is_created(vm); } -int MSG_vm_is_running(sg_vm_t vm) +int MSG_vm_is_running(const_sg_vm_t vm) { return sg_vm_is_running(vm); } -int MSG_vm_is_suspended(sg_vm_t vm) +int MSG_vm_is_suspended(const_sg_vm_t vm) { return sg_vm_is_suspended(vm); } diff --git a/src/plugins/host_dvfs.cpp b/src/plugins/host_dvfs.cpp index 82c38aa728..57bf368fc8 100644 --- a/src/plugins/host_dvfs.cpp +++ b/src/plugins/host_dvfs.cpp @@ -140,7 +140,7 @@ public: */ class Performance : public Governor { public: - explicit Performance(simgrid::s4u::Host* ptr) : Governor(ptr) {} + using Governor::Governor; std::string get_name() const override { return "Performance"; } void update() override { get_host()->set_pstate(get_min_pstate()); } @@ -158,7 +158,7 @@ public: */ class Powersave : public Governor { public: - explicit Powersave(simgrid::s4u::Host* ptr) : Governor(ptr) {} + using Governor::Governor; std::string get_name() const override { return "Powersave"; } void update() override { get_host()->set_pstate(get_max_pstate()); } @@ -181,7 +181,7 @@ class OnDemand : public Governor { double freq_up_threshold_ = 0.80; public: - explicit OnDemand(simgrid::s4u::Host* ptr) : Governor(ptr) {} + using Governor::Governor; std::string get_name() const override { return "OnDemand"; } void update() override @@ -229,7 +229,7 @@ class Conservative : public Governor { double freq_down_threshold_ = .2; public: - explicit Conservative(simgrid::s4u::Host* ptr) : Governor(ptr) {} + using Governor::Governor; std::string get_name() const override { return "Conservative"; } void update() override diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index 6813e18e18..f1bc4f79b6 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -231,19 +231,19 @@ void sg_vm_set_bound(sg_vm_t vm, double bound) } /** @brief Returns whether the given VM has just created, not running. */ -int sg_vm_is_created(sg_vm_t vm) +int sg_vm_is_created(const_sg_vm_t vm) { return vm->get_state() == simgrid::s4u::VirtualMachine::state::CREATED; } /** @brief Returns whether the given VM is currently running */ -int sg_vm_is_running(sg_vm_t vm) +int sg_vm_is_running(const_sg_vm_t vm) { return vm->get_state() == simgrid::s4u::VirtualMachine::state::RUNNING; } /** @brief Returns whether the given VM is currently suspended, not running. */ -int sg_vm_is_suspended(sg_vm_t vm) +int sg_vm_is_suspended(const_sg_vm_t vm) { return vm->get_state() == simgrid::s4u::VirtualMachine::state::SUSPENDED; } diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 5588ce955f..1fd96f9383 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -499,13 +499,13 @@ void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, const char simgrid::kernel::actor::ActorCode function; if (code) function = simgrid::xbt::wrap_main(code, argc, argv); - actor->start(std::move(function)); + actor->start(function); } sg_actor_t sg_actor_create(const char* name, sg_host_t host, xbt_main_func_t code, int argc, const char* const* argv) { simgrid::kernel::actor::ActorCode function = simgrid::xbt::wrap_main(code, argc, argv); - return simgrid::s4u::Actor::init(name, host)->start(std::move(function)).get(); + return simgrid::s4u::Actor::init(name, host)->start(function).get(); } void sg_actor_set_stacksize(sg_actor_t actor, unsigned size) diff --git a/src/s4u/s4u_Engine.cpp b/src/s4u/s4u_Engine.cpp index 7737a2b16d..f7f8b717cb 100644 --- a/src/s4u/s4u_Engine.cpp +++ b/src/s4u/s4u_Engine.cpp @@ -96,7 +96,7 @@ void Engine::register_function(const std::string& name, int (*code)(int, char**) kernel::actor::ActorCodeFactory code_factory = [code](std::vector args) { return xbt::wrap_main(code, std::move(args)); }; - register_function(name, std::move(code_factory)); + register_function(name, code_factory); } void Engine::register_default(int (*code)(int, char**)) // XBT_ATTRIB_DEPRECATED_v329 { @@ -109,16 +109,16 @@ void Engine::register_function(const std::string& name, const std::function args) { return xbt::wrap_main(code, std::move(args)); }; - register_function(name, std::move(code_factory)); + register_function(name, code_factory); } /** Registers the main function of an actor that will be launched from the deployment file */ void Engine::register_function(const std::string& name, const std::function)>& code) { - kernel::actor::ActorCodeFactory code_factory = [code](std::vector args) { + kernel::actor::ActorCodeFactory code_factory = [code{code}](std::vector args) mutable { return std::bind(std::move(code), std::move(args)); }; - register_function(name, std::move(code_factory)); + register_function(name, code_factory); } /** Registers a function as the default main function of actors * diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 590aada22f..02af4c9fa0 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -430,7 +430,7 @@ static void smpi_init_privatization_dlopen(const std::string& executable) // load the library once to add it to the local libs, to get the absolute path void* libhandle = dlopen(libname.c_str(), RTLD_LAZY); xbt_assert(libhandle != nullptr, - "Cannot dlopen %s - check your settings in smpi/privatize-libs", libname.c_str()); + "Cannot dlopen %s - check your settings in smpi/privatize-libs", libname.c_str()); // get library name from path std::string fullpath = libname; #if not defined(__APPLE__) && not defined(__HAIKU__) @@ -479,9 +479,10 @@ static void smpi_init_privatization_dlopen(const std::string& executable) target_libs.push_back(target_lib); XBT_DEBUG("copy lib %s to %s, with size %lld", libpath.c_str(), target_lib.c_str(), (long long)fdin_size2); smpi_copy_file(libpath, target_lib, fdin_size2); - void* handle = dlopen(target_lib.c_str(), RTLD_LAZY | RTLD_LOCAL | WANT_RTLD_DEEPBIND); - xbt_assert(handle != nullptr, "dlopen of library %s failed: %s (errno: %d -- %s)", target_lib.c_str(), - dlerror(), errno, strerror(errno)); + + std::string sedcommand = "sed -i -e 's/" + libname + "/" + target_lib + "/g' " + target_executable; + int status = system(sedcommand.c_str()); + xbt_assert(status == 0, "error while applying sed command %s \n", sedcommand.c_str()); } } diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 20a039421f..2f235881e0 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -113,7 +113,7 @@ std::vector HostImpl::get_disks() const void HostImpl::set_disks(const std::vector& disks, s4u::Host* host) { - disks_ = std::move(disks); + disks_ = disks; for (auto d : disks_) d->set_host(host); } diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 0215897243..4ac9b2f1b8 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -27,7 +27,7 @@ namespace resource { */ class XBT_PUBLIC CpuModel : public Model { public: - explicit CpuModel(Model::UpdateAlgo algo) : Model(algo) {} + using Model::Model; /** * @brief Create a Cpu @@ -176,8 +176,7 @@ public: */ static xbt::signal on_state_change; - CpuAction(Model* model, double cost, bool failed) : Action(model, cost, failed) {} - CpuAction(Model* model, double cost, bool failed, lmm::Variable* var) : Action(model, cost, failed, var) {} + using Action::Action; void set_state(Action::State state) override; diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index 42354ab83e..e5b1e638f7 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -60,8 +60,7 @@ class NetworkCm02Action : public NetworkAction { friend Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate); public: - NetworkCm02Action(Model* model, s4u::Host& src, s4u::Host& dst, double cost, bool failed) - : NetworkAction(model, src, dst, cost, failed){}; + using NetworkAction::NetworkAction; ~NetworkCm02Action() override = default; void update_remains_lazy(double now) override; }; diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 9fffd5b88f..5ff4cf26c5 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -35,7 +35,7 @@ public: static config::Flag cfg_tcp_gamma; static config::Flag cfg_crosstraffic; - explicit NetworkModel(Model::UpdateAlgo algo) : Model(algo) {} + using Model::Model; NetworkModel(const NetworkModel&) = delete; NetworkModel& operator=(const NetworkModel&) = delete; ~NetworkModel() override; diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 9095e590dd..42f498c0aa 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -467,7 +467,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor) XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->get_cname(), start_time); simgrid::simix::Timer::set(start_time, [arg, auto_restart]() { simgrid::kernel::actor::ActorImplPtr new_actor = simgrid::kernel::actor::ActorImpl::create( - arg->name.c_str(), std::move(arg->code), arg->data, arg->host, arg->properties.get(), nullptr); + arg->name.c_str(), arg->code, arg->data, arg->host, arg->properties.get(), nullptr); if (arg->kill_time >= 0) new_actor->set_kill_time(arg->kill_time); if (auto_restart) @@ -479,7 +479,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor) try { simgrid::kernel::actor::ActorImplPtr new_actor = nullptr; - new_actor = simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), std::move(code), nullptr, host, + new_actor = simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), code, nullptr, host, arg->properties.get(), nullptr); /* The actor creation will fail if the host is currently dead, but that's fine */ if (arg->kill_time >= 0) diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index c486699284..2fcff2f40b 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -73,7 +73,7 @@ void surf_parse_assert_netpoint(const std::string& hostname, const std::string& break; } } - surf_parse_error(std::move(msg)); + surf_parse_error(msg); } double surf_parse_get_double(const std::string& s) @@ -786,7 +786,7 @@ void ETag_surfxml_config() for (std::string key : keys) { if (simgrid::config::is_default(key.c_str())) { std::string cfg = key + ":" + current_property_set->at(key); - simgrid::config::set_parse(std::move(cfg)); + simgrid::config::set_parse(cfg); } else XBT_INFO("The custom configuration '%s' is already defined by user!", key.c_str()); } diff --git a/teshsuite/mc/random-bug/random-bug.cpp b/teshsuite/mc/random-bug/random-bug.cpp index 76cc5975db..01a9dd8ff8 100644 --- a/teshsuite/mc/random-bug/random-bug.cpp +++ b/teshsuite/mc/random-bug/random-bug.cpp @@ -10,7 +10,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(random_bug, "For this example"); -enum { ABORT, ASSERT, PRINTF } behavior; +enum class Behavior { ABORT, ASSERT, PRINTF }; + +Behavior behavior; /** A fake application with a bug occurring for some random values */ static void app() @@ -18,12 +20,12 @@ static void app() int x = MC_random(0, 5); int y = MC_random(0, 5); - if (behavior == ASSERT) { + if (behavior == Behavior::ASSERT) { MC_assert(x != 3 || y != 4); - } else if (behavior == PRINTF) { + } else if (behavior == Behavior::PRINTF) { if (x == 3 && y == 4) XBT_ERROR("Error reached"); - } else { // behavior == ABORT + } else { // behavior == Behavior::ABORT abort(); } } @@ -35,13 +37,13 @@ int main(int argc, char* argv[]) xbt_assert(argc == 3, "Usage: random-bug raise|assert "); if (strcmp(argv[1], "abort") == 0) { XBT_INFO("Behavior: abort"); - behavior = ABORT; + behavior = Behavior::ABORT; } else if (strcmp(argv[1], "assert") == 0) { XBT_INFO("Behavior: assert"); - behavior = ASSERT; + behavior = Behavior::ASSERT; } else if (strcmp(argv[1], "printf") == 0) { XBT_INFO("Behavior: printf"); - behavior = PRINTF; + behavior = Behavior::PRINTF; } else { xbt_die("Please use either 'abort', 'assert' or 'printf' as first parameter, to specify what to do when the error " "is found."); diff --git a/teshsuite/s4u/cloud-sharing/cloud-sharing.cpp b/teshsuite/s4u/cloud-sharing/cloud-sharing.cpp index 853b08dd37..5d86a64577 100644 --- a/teshsuite/s4u/cloud-sharing/cloud-sharing.cpp +++ b/teshsuite/s4u/cloud-sharing/cloud-sharing.cpp @@ -42,7 +42,7 @@ static int computation_fun(std::vector argv) static void run_test_process(const std::string& name, simgrid::s4u::Host* location, int size) { std::vector arg = {std::to_string(size)}; - simgrid::s4u::Actor::create(std::move(name), location, computation_fun, arg); + simgrid::s4u::Actor::create(name, location, computation_fun, arg); } static void test_energy_consumption(const std::string& name, int nb_cores) diff --git a/tools/cmake/Flags.cmake b/tools/cmake/Flags.cmake index 3e92f6061a..484f48789a 100644 --- a/tools/cmake/Flags.cmake +++ b/tools/cmake/Flags.cmake @@ -22,14 +22,17 @@ if(enable_compile_warnings) set(warnCFLAGS "${warnCFLAGS} -Wclobbered -Wno-error=clobbered -Wno-unused-local-typedefs -Wno-error=attributes -Wno-error=maybe-uninitialized") endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Intel") - # ignore remark #1418: external function definition with no prior declaration + # ignore remarks: + # 191: type qualifier is meaningless on cast type + # 1418: external function definition with no prior declaration # 2196: routine is both "inline" and "noinline" + # 2651: attribute does not apply to any entity # 3179: deprecated conversion of string literal to char* (should be const char*) - # 191: type qualifier is meaningless on cast type + # set as warning: # 597: entity-kind "entity" will not be called for implicit or explicit conversions # 2330: argument of type "type" is incompatible with parameter of type "type" (dropping qualifiers) # 11003: no IR in object file xxxx; was the source file compiled with xxxx - set(warnCFLAGS "${warnCFLAGS} -diag-disable=1418,191,2196,3179 -diag-warning=2330,597,11003") + set(warnCFLAGS "${warnCFLAGS} -diag-disable=191,1418,2196,2651,3179 -diag-warning=597,2330,11003") endif() set(warnCXXFLAGS "${warnCFLAGS} -Wall -Wextra -Wunused -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing")