From: Martin Quinson Date: Sun, 10 Sep 2017 13:20:21 +0000 (+0200) Subject: Merge pull request #218 from Takishipp/MSG2S4U X-Git-Tag: v3_17~152 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a3d08dd00246eb26ced68c5b0e046096706bbe23?hp=41ceaff7af49c608aa9d14d95d7b8736b37187a9 Merge pull request #218 from Takishipp/MSG2S4U first attempt to convert async-waitany msg version to s4u (doesn't work yet) --- diff --git a/doc/doxygen/module-s4u.doc b/doc/doxygen/module-s4u.doc index 7ee18cfaae..abd1c3c833 100644 --- a/doc/doxygen/module-s4u.doc +++ b/doc/doxygen/module-s4u.doc @@ -6,9 +6,11 @@ The S4U API is currently under heavy work, but will eventually deprecate the MSG and SimDag APIs. Everything that you can do in SimGrid will be possible in S4U. -@warning S4U is not ready for public use yet. You should not go - that path unless you know what you are doing. If unsure, - proceed to @ref MSG_API instead. +@warning S4U is not as rock stable as the rest of SimGrid yet. + You are really welcome to test it, but be warned that the API + may change without notice between releases. This is however + the way to go if you want to create a new long-term project. + If you want to play safe, proceed to @ref MSG_API instead. Unsurprisingly, the S4U interface matches the concepts presented in @ref starting_components "the introduction". You should read this page diff --git a/doc/doxygen/options.doc b/doc/doxygen/options.doc index 98f91ccf2b..e0eb74791a 100644 --- a/doc/doxygen/options.doc +++ b/doc/doxygen/options.doc @@ -316,7 +316,7 @@ setting on regular (less constrained) scenarios so it is off by default. \subsubsection options_model_network_gamma Maximal TCP window size The analytical models need to know the maximal TCP window size to take -the TCP congestion mechanism into account. This is set to 20000 by +the TCP congestion mechanism into account. This is set to 4194304 by default, but can be changed using the \b network/TCP-gamma item. On linux, this value can be retrieved using the following diff --git a/examples/s4u/README.doc b/examples/s4u/README.doc index 228552eb29..6e14a5ed7f 100644 --- a/examples/s4u/README.doc +++ b/examples/s4u/README.doc @@ -1,9 +1,9 @@ S4U (Simgrid for you) is the next interface of SimGrid, expected to be released with SimGrid 4.0. -Even if it's in a very preliminary state so far, you are welcome to -try it and report any interface glitches that you see. Be however -warned that the interface will be modified until its final release. -You will have to adapt your code on the way. +Even if it is not completely rock stable yet, it may well already fit +your needs. You are welcome to try it and report any interface +glitches that you see. Be however warned that the interface may change +until its final release. You will have to adapt your code on the way. This file follows the Doxygen syntax to be included in the documentation, but it should remain readable directly. diff --git a/examples/s4u/app-bittorrent/s4u_tracker.cpp b/examples/s4u/app-bittorrent/s4u_tracker.cpp index 7ddd5e095a..1b8e3e4290 100644 --- a/examples/s4u/app-bittorrent/s4u_tracker.cpp +++ b/examples/s4u/app-bittorrent/s4u_tracker.cpp @@ -31,8 +31,8 @@ Tracker::Tracker(std::vector args) void Tracker::operator()() { simgrid::s4u::CommPtr comm = nullptr; + void* received; while (simgrid::s4u::Engine::getClock() < deadline) { - void* received; if (comm == nullptr) comm = mailbox->get_async(&received); if (comm->test()) { diff --git a/examples/s4u/dht-chord/node.cpp b/examples/s4u/dht-chord/node.cpp index b39c9f749d..d97b6b1c33 100644 --- a/examples/s4u/dht-chord/node.cpp +++ b/examples/s4u/dht-chord/node.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2016. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -236,13 +236,13 @@ void Node::checkPredecessor() try { comm->wait(timeout); XBT_DEBUG("Received the answer to my 'Predecessor Alive': my predecessor %d is alive", pred_id_); + delete static_cast(data); } catch (xbt_ex& e) { if (e.category == timeout_error) { XBT_DEBUG("Failed to receive the answer to my 'Predecessor Alive' request"); pred_id_ = -1; } } - delete message; } /* Asks its predecessor to a remote node diff --git a/examples/smpi/NAS/dt.c b/examples/smpi/NAS/dt.c index 45398c9a87..c98a0d34a9 100644 --- a/examples/smpi/NAS/dt.c +++ b/examples/smpi/NAS/dt.c @@ -240,7 +240,6 @@ static DGraph *buildWH(const char cls){ AttachNode(dg,nd); } totComparators=0; - numPrevLayerNodes=numLayerNodes; while(numLayerNodes>maxInDeg){ numLayerNodes=numLayerNodes/maxInDeg; if(numLayerNodes*maxInDegval[i]=weight*b->val[i]; a->val[i+1]=weight*b->val[i+1]; a->val[i+2]=weight*b->val[i+2]; @@ -668,7 +666,7 @@ int main(int argc,char **argv ){ dg=buildBH(class); }else if(strncmp(argv[3],"WH",2)==0){ dg=buildWH(class); - }else if(strncmp(argv[3],"SH",2)==0){ + }else /* (strncmp(argv[3],"SH",2)==0) */ { dg=buildSH(class); } @@ -677,7 +675,7 @@ int main(int argc,char **argv ){ if(my_rank==0) fprintf(stderr,"Not enough timers. Node timeing is off. \n"); } - if(dg->numNodes>comm_size){ + if(dg->numNodes && dg->numNodes>comm_size){ if(my_rank==0){ fprintf(stderr,"** The number of MPI processes should not be less than \n"); fprintf(stderr,"** the number of nodes in the graph\n"); diff --git a/examples/smpi/NAS/ep.c b/examples/smpi/NAS/ep.c index 24257dc1b2..a7b8d50fae 100644 --- a/examples/smpi/NAS/ep.c +++ b/examples/smpi/NAS/ep.c @@ -73,7 +73,6 @@ int main(int argc, char **argv) { fprintf(stdout," Number of random numbers generated: %s\n",size); fprintf(stdout," Number of active processes: %d\n",no_nodes); } - verified = FALSE; /* Compute the number of "batches" of random number pairs generated per processor. Adjust if the number of processors * does not evenly divide the total number */ @@ -99,7 +98,6 @@ int main(int argc, char **argv) { for (i=0;i<2*nk;i++) { x[i] = -1e99; } - Mops = log(sqrt(abs(1))); /* Synchronize before placing time stamp */ MPI_Barrier( MPI_COMM_WORLD ); @@ -147,12 +145,12 @@ int main(int argc, char **argv) { for (i=1;i<=100 && !stop;i++) { ik = kk / 2; if (2 * ik != kk) { - t3 = randlc(&t1, &t2); + randlc(&t1, &t2); } if (ik==0) stop = TRUE; else { - t3 = randlc(&t2, &t2); + randlc(&t2, &t2); kk = ik; } } diff --git a/examples/smpi/NAS/is.c b/examples/smpi/NAS/is.c index 7314dee222..b68196515a 100644 --- a/examples/smpi/NAS/is.c +++ b/examples/smpi/NAS/is.c @@ -124,7 +124,7 @@ static double find_my_seed( int kn, /* my processor rank, 0<=kn<=num pro double a ) /* Ran num gen mult, try 1220703125.00 */ { long i; - double t1,t2,t3,an; + double t1,t2,an; long mq,nq,kk,ik; nq = nn / np; @@ -145,13 +145,12 @@ static double find_my_seed( int kn, /* my processor rank, 0<=kn<=num pro for( i=1; i<=100; i++ ){ ik = kk / 2; if( 2 * ik != kk ) - t3 = randlc( &t1, &t2 ); + randlc( &t1, &t2 ); if( ik == 0 ) break; - t3 = randlc( &t2, &t2 ); + randlc( &t2, &t2 ); kk = ik; } - an=t3;//added to silence paranoid compilers return t1; } diff --git a/include/xbt/ex.hpp b/include/xbt/ex.hpp index efd8eee333..7e649738af 100644 --- a/include/xbt/ex.hpp +++ b/include/xbt/ex.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2015. The SimGrid Team. +/* Copyright (c) 2005-2017. The SimGrid Team. * All rights reserved. */ /* Copyright (c) 2002-2004 Ralf S. Engelschall */ @@ -79,7 +79,7 @@ struct XBT_PUBLIC() xbt_ex : simgrid::xbt::WithContextException(throwpoint, simgrid::xbt::backtrace()) {} - ~xbt_ex() = default; + ~xbt_ex(); /** Category (what went wrong) */ xbt_errcat_t category = unknown_error; diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 532f1cff49..7d7a121737 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -34,7 +34,6 @@ class Action; typedef simgrid::surf::Model surf_Model; typedef simgrid::surf::CpuModel surf_CpuModel; -typedef simgrid::surf::Cpu surf_Cpu; typedef simgrid::surf::HostModel surf_HostModel; typedef simgrid::surf::NetworkModel surf_NetworkModel; typedef simgrid::surf::StorageModel surf_StorageModel; @@ -45,12 +44,10 @@ typedef simgrid::surf::Action surf_Action; typedef struct surf_Model surf_Model; typedef struct surf_CpuModel surf_CpuModel; -typedef struct surf_Cpu surf_Cpu; typedef struct surf_HostModel surf_HostModel; typedef struct surf_NetworkModel surf_NetworkModel; typedef struct surf_StorageModel surf_StorageModel; typedef struct surf_Resource surf_Resource; -typedef struct surf_Host surf_Host; typedef struct surf_Action surf_Action; #endif diff --git a/src/include/xbt/parmap.hpp b/src/include/xbt/parmap.hpp index dd5037f7aa..00f4b8c94b 100644 --- a/src/include/xbt/parmap.hpp +++ b/src/include/xbt/parmap.hpp @@ -90,7 +90,6 @@ private: */ virtual void worker_wait(unsigned) = 0; - protected: Parmap& parmap; }; @@ -225,7 +224,7 @@ template void Parmap::apply(void (*fun)(T), const std::vector */ template boost::optional Parmap::next() { - unsigned index = this->index++; + unsigned index = this->index.fetch_add(1, std::memory_order_relaxed); if (index < this->data->size()) return (*this->data)[index]; else @@ -237,11 +236,11 @@ template boost::optional Parmap::next() */ template void Parmap::work() { - unsigned index = this->index++; unsigned length = this->data->size(); + unsigned index = this->index.fetch_add(1, std::memory_order_relaxed); while (index < length) { this->fun((*this->data)[index]); - index = this->index++; + index = this->index.fetch_add(1, std::memory_order_relaxed); } } diff --git a/src/instr/instr_config.cpp b/src/instr/instr_config.cpp index a3318319cf..3e229a12c2 100644 --- a/src/instr/instr_config.cpp +++ b/src/instr/instr_config.cpp @@ -63,7 +63,7 @@ static int trace_precision; static bool trace_configured = false; static bool trace_active = false; -static type_t rootType = nullptr; /* the root type */ +static simgrid::instr::Type* rootType = nullptr; /* the root type */ instr_fmt_type_t instr_fmt_type = instr_fmt_paje; diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index a65032c113..3f079eb995 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -153,7 +153,7 @@ void TRACE_declare_mark(const char *mark_type) } XBT_DEBUG("MARK,declare %s", mark_type); - PJ_type_event_new(mark_type, PJ_type_get_root()); + simgrid::instr::Type::eventNew(mark_type, PJ_type_get_root()); declared_marks.insert(mark_type); } @@ -183,7 +183,7 @@ void TRACE_declare_mark_value_with_color (const char *mark_type, const char *mar if (not mark_value) THROWF (tracing_error, 1, "mark_value is nullptr"); - type_t type = PJ_type_get (mark_type, PJ_type_get_root()); + simgrid::instr::Type* type = PJ_type_get(mark_type, PJ_type_get_root()); if (not type) { THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type); } @@ -193,7 +193,7 @@ void TRACE_declare_mark_value_with_color (const char *mark_type, const char *mar mark_color = white; XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color); - value rett(mark_value, mark_color, type); + simgrid::instr::Value rett(mark_value, mark_color, type); } /** \ingroup TRACE_mark @@ -239,13 +239,14 @@ void TRACE_mark(const char *mark_type, const char *mark_value) THROWF (tracing_error, 1, "mark_value is nullptr"); //check if mark_type is already declared - type_t type = PJ_type_get (mark_type, PJ_type_get_root()); + simgrid::instr::Type* type = PJ_type_get(mark_type, PJ_type_get_root()); if (not type) { THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type); } XBT_DEBUG("MARK %s %s", mark_type, mark_value); - new NewEvent(MSG_get_clock(), PJ_container_get_root(), type, value::get(mark_value, type)); + new simgrid::instr::NewEvent(MSG_get_clock(), PJ_container_get_root(), type, + simgrid::instr::Value::get(mark_value, type)); } /** \ingroup TRACE_mark @@ -282,16 +283,16 @@ static void instr_user_variable(double time, const char* resource, const char* v char valuestr[100]; snprintf(valuestr, 100, "%g", value); container_t container = PJ_container_get(resource); - type_t type = PJ_type_get (variable, container->type); + simgrid::instr::Type* type = PJ_type_get(variable, container->type_); switch (what){ case INSTR_US_SET: - new SetVariableEvent(time, container, type, value); + new simgrid::instr::SetVariableEvent(time, container, type, value); break; case INSTR_US_ADD: - new AddVariableEvent(time, container, type, value); + new simgrid::instr::AddVariableEvent(time, container, type, value); break; case INSTR_US_SUB: - new SubVariableEvent(time, container, type, value); + new simgrid::instr::SubVariableEvent(time, container, type, value); break; default: THROW_IMPOSSIBLE; @@ -945,10 +946,10 @@ void TRACE_host_state_declare_value (const char *state, const char *value, const void TRACE_host_set_state(const char* host, const char* state, const char* value_str) { container_t container = PJ_container_get(host); - type_t type = PJ_type_get (state, container->type); - value* val = - value::get_or_new(value_str, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */ - new SetStateEvent(MSG_get_clock(), container, type, val); + simgrid::instr::Type* type = PJ_type_get(state, container->type_); + simgrid::instr::Value* val = simgrid::instr::Value::get_or_new( + value_str, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */ + new simgrid::instr::SetStateEvent(MSG_get_clock(), container, type, val); } /** \ingroup TRACE_user_variables @@ -965,10 +966,10 @@ void TRACE_host_set_state(const char* host, const char* state, const char* value void TRACE_host_push_state(const char* host, const char* state, const char* value_str) { container_t container = PJ_container_get(host); - type_t type = PJ_type_get (state, container->type); - value* val = - value::get_or_new(value_str, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */ - new PushStateEvent(MSG_get_clock(), container, type, val); + simgrid::instr::Type* type = PJ_type_get(state, container->type_); + simgrid::instr::Value* val = simgrid::instr::Value::get_or_new( + value_str, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */ + new simgrid::instr::PushStateEvent(MSG_get_clock(), container, type, val); } /** \ingroup TRACE_user_variables @@ -984,8 +985,8 @@ void TRACE_host_push_state(const char* host, const char* state, const char* valu void TRACE_host_pop_state (const char *host, const char *state) { container_t container = PJ_container_get(host); - type_t type = PJ_type_get (state, container->type); - new PopStateEvent(MSG_get_clock(), container, type); + simgrid::instr::Type* type = PJ_type_get(state, container->type_); + new simgrid::instr::PopStateEvent(MSG_get_clock(), container, type); } /** \ingroup TRACE_API diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index d65e46cba9..9208684f97 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -38,118 +38,132 @@ void PJ_container_set_root (container_t root) rootContainer = root; } -container_t PJ_container_new (const char *name, e_container_types kind, container_t father) +simgrid::instr::Container::Container(const char* name, simgrid::instr::e_container_types kind, Container* father) + : name_(xbt_strdup(name)), father_(father) { - if (name == nullptr){ - THROWF (tracing_error, 0, "can't create a container with a nullptr name"); - } + xbt_assert(name != nullptr, "Container name cannot be nullptr"); static long long int container_id = 0; - char id_str[INSTR_DEFAULT_STR_SIZE]; - snprintf (id_str, INSTR_DEFAULT_STR_SIZE, "%lld", container_id); + id_ = bprintf("%lld", container_id); // id (or alias) of the container container_id++; - container_t newContainer = xbt_new0(s_container, 1); - newContainer->name = xbt_strdup (name); // name of the container - newContainer->id = xbt_strdup (id_str); // id (or alias) of the container - newContainer->father = father; - sg_host_t sg_host = sg_host_by_name(name); - //Search for network_element_t switch (kind){ - case INSTR_HOST: - newContainer->netpoint = sg_host->pimpl_netpoint; - xbt_assert(newContainer->netpoint, "Element '%s' not found", name); + case simgrid::instr::INSTR_HOST: + this->netpoint_ = sg_host_by_name(name)->pimpl_netpoint; + xbt_assert(this->netpoint_, "Element '%s' not found", name); break; - case INSTR_ROUTER: - newContainer->netpoint = simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(name); - xbt_assert(newContainer->netpoint, "Element '%s' not found", name); + case simgrid::instr::INSTR_ROUTER: + this->netpoint_ = simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(name); + xbt_assert(this->netpoint_, "Element '%s' not found", name); break; - case INSTR_AS: - newContainer->netpoint = simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(name); - xbt_assert(newContainer->netpoint, "Element '%s' not found", name); + case simgrid::instr::INSTR_AS: + this->netpoint_ = simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(name); + xbt_assert(this->netpoint_, "Element '%s' not found", name); break; default: - newContainer->netpoint = nullptr; + this->netpoint_ = nullptr; break; } - // level depends on level of father - if (newContainer->father){ - newContainer->level = newContainer->father->level+1; - XBT_DEBUG("new container %s, child of %s", name, father->name); - }else{ - newContainer->level = 0; + if (father_) { + this->level_ = father_->level_ + 1; + XBT_DEBUG("new container %s, child of %s", name, father->name_); } + // type definition (method depends on kind of this new container) - newContainer->kind = kind; - if (newContainer->kind == INSTR_AS){ + this->kind_ = kind; + if (this->kind_ == simgrid::instr::INSTR_AS) { //if this container is of an AS, its type name depends on its level char as_typename[INSTR_DEFAULT_STR_SIZE]; - snprintf (as_typename, INSTR_DEFAULT_STR_SIZE, "L%d", newContainer->level); - if (newContainer->father){ - newContainer->type = PJ_type_get_or_null (as_typename, newContainer->father->type); - if (newContainer->type == nullptr){ - newContainer->type = PJ_type_container_new (as_typename, newContainer->father->type); + snprintf(as_typename, INSTR_DEFAULT_STR_SIZE, "L%d", this->level_); + if (this->father_) { + this->type_ = simgrid::instr::Type::getOrNull(as_typename, this->father_->type_); + if (this->type_ == nullptr) { + this->type_ = simgrid::instr::Type::containerNew(as_typename, this->father_->type_); } }else{ - newContainer->type = PJ_type_container_new ("0", nullptr); + this->type_ = simgrid::instr::Type::containerNew("0", nullptr); } }else{ //otherwise, the name is its kind char typeNameBuff[INSTR_DEFAULT_STR_SIZE]; - switch (newContainer->kind){ - case INSTR_HOST: + switch (this->kind_) { + case simgrid::instr::INSTR_HOST: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "HOST"); break; - case INSTR_LINK: + case simgrid::instr::INSTR_LINK: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "LINK"); break; - case INSTR_ROUTER: + case simgrid::instr::INSTR_ROUTER: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "ROUTER"); break; - case INSTR_SMPI: + case simgrid::instr::INSTR_SMPI: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "MPI"); break; - case INSTR_MSG_PROCESS: + case simgrid::instr::INSTR_MSG_PROCESS: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "MSG_PROCESS"); break; - case INSTR_MSG_VM: + case simgrid::instr::INSTR_MSG_VM: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "MSG_VM"); break; - case INSTR_MSG_TASK: + case simgrid::instr::INSTR_MSG_TASK: snprintf (typeNameBuff, INSTR_DEFAULT_STR_SIZE, "MSG_TASK"); break; default: THROWF (tracing_error, 0, "new container kind is unknown."); break; } - type_t type = PJ_type_get_or_null (typeNameBuff, newContainer->father->type); + simgrid::instr::Type* type = simgrid::instr::Type::getOrNull(typeNameBuff, this->father_->type_); if (type == nullptr){ - newContainer->type = PJ_type_container_new (typeNameBuff, newContainer->father->type); + this->type_ = simgrid::instr::Type::containerNew(typeNameBuff, this->father_->type_); }else{ - newContainer->type = type; + this->type_ = type; } } - newContainer->children = xbt_dict_new_homogeneous(nullptr); - if (newContainer->father){ - xbt_dict_set(newContainer->father->children, newContainer->name, newContainer, nullptr); - LogContainerCreation(newContainer); + this->children_ = xbt_dict_new_homogeneous(nullptr); + if (this->father_) { + xbt_dict_set(this->father_->children_, this->name_, this, nullptr); + LogContainerCreation(this); } //register all kinds by name - if (xbt_dict_get_or_null(allContainers, newContainer->name) != nullptr){ - THROWF(tracing_error, 1, "container %s already present in allContainers data structure", newContainer->name); + if (xbt_dict_get_or_null(allContainers, this->name_) != nullptr) { + THROWF(tracing_error, 1, "container %s already present in allContainers data structure", this->name_); } - xbt_dict_set (allContainers, newContainer->name, newContainer, nullptr); - XBT_DEBUG("Add container name '%s'",newContainer->name); + xbt_dict_set(allContainers, this->name_, this, nullptr); + XBT_DEBUG("Add container name '%s'", this->name_); //register NODE types for triva configuration - if (newContainer->kind == INSTR_HOST || newContainer->kind == INSTR_LINK || newContainer->kind == INSTR_ROUTER) { - trivaNodeTypes.insert(newContainer->type->name); + if (this->kind_ == simgrid::instr::INSTR_HOST || this->kind_ == simgrid::instr::INSTR_LINK || + this->kind_ == simgrid::instr::INSTR_ROUTER) { + trivaNodeTypes.insert(this->type_->name_); } - return newContainer; +} +simgrid::instr::Container::~Container() +{ + XBT_DEBUG("destroy container %s", name_); + + // obligation to dump previous events because they might + // reference the container that is about to be destroyed + TRACE_last_timestamp_to_dump = surf_get_clock(); + TRACE_paje_dump_buffer(1); + + // trace my destruction + if (not TRACE_disable_destroy() && this != PJ_container_get_root()) { + // do not trace the container destruction if user requests + // or if the container is root + LogContainerDestruction(this); + } + + // remove it from allContainers data structure + xbt_dict_remove(allContainers, name_); + + // free + xbt_free(name_); + xbt_free(id_); + xbt_dict_free(&children_); } container_t PJ_container_get (const char *name) @@ -177,58 +191,26 @@ void PJ_container_remove_from_parent (container_t child) THROWF (tracing_error, 0, "can't remove from parent with a nullptr child"); } - container_t parent = child->father; + container_t parent = child->father_; if (parent){ - XBT_DEBUG("removeChildContainer (%s) FromContainer (%s) ", - child->name, - parent->name); - xbt_dict_remove (parent->children, child->name); + XBT_DEBUG("removeChildContainer (%s) FromContainer (%s) ", child->name_, parent->name_); + xbt_dict_remove(parent->children_, child->name_); } } -void PJ_container_free (container_t container) -{ - if (container == nullptr){ - THROWF (tracing_error, 0, "trying to free a nullptr container"); - } - XBT_DEBUG("destroy container %s", container->name); - - //obligation to dump previous events because they might - //reference the container that is about to be destroyed - TRACE_last_timestamp_to_dump = surf_get_clock(); - TRACE_paje_dump_buffer(1); - - //trace my destruction - if (not TRACE_disable_destroy() && container != PJ_container_get_root()) { - //do not trace the container destruction if user requests - //or if the container is root - LogContainerDestruction(container); - } - - //remove it from allContainers data structure - xbt_dict_remove (allContainers, container->name); - - //free - xbt_free (container->name); - xbt_free (container->id); - xbt_dict_free (&container->children); - xbt_free (container); - container = nullptr; -} - static void recursiveDestroyContainer (container_t container) { if (container == nullptr){ THROWF (tracing_error, 0, "trying to recursively destroy a nullptr container"); } - XBT_DEBUG("recursiveDestroyContainer %s", container->name); + XBT_DEBUG("recursiveDestroyContainer %s", container->name_); xbt_dict_cursor_t cursor = nullptr; container_t child; char *child_name; - xbt_dict_foreach(container->children, cursor, child_name, child) { + xbt_dict_foreach (container->children_, cursor, child_name, child) { recursiveDestroyContainer (child); } - PJ_container_free (container); + delete container; } void PJ_container_free_all () diff --git a/src/instr/instr_paje_header.cpp b/src/instr/instr_paje_header.cpp index d0b48b1853..4f49363a9b 100644 --- a/src/instr/instr_paje_header.cpp +++ b/src/instr/instr_paje_header.cpp @@ -13,7 +13,7 @@ extern FILE *tracing_file; static void TRACE_header_PajeDefineContainerType (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeDefineContainerType %d\n", PAJE_DefineContainerType); + fprintf(tracing_file, "%%EventDef PajeDefineContainerType %d\n", simgrid::instr::PAJE_DefineContainerType); fprintf(tracing_file, "%% Alias string\n"); if (basic){ fprintf(tracing_file, "%% ContainerType string\n"); @@ -26,7 +26,7 @@ static void TRACE_header_PajeDefineContainerType (int basic, int size) static void TRACE_header_PajeDefineVariableType (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeDefineVariableType %d\n", PAJE_DefineVariableType); + fprintf(tracing_file, "%%EventDef PajeDefineVariableType %d\n", simgrid::instr::PAJE_DefineVariableType); fprintf(tracing_file, "%% Alias string\n"); if (basic){ fprintf(tracing_file, "%% ContainerType string\n"); @@ -40,7 +40,7 @@ static void TRACE_header_PajeDefineVariableType (int basic, int size) static void TRACE_header_PajeDefineStateType (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeDefineStateType %d\n", PAJE_DefineStateType); + fprintf(tracing_file, "%%EventDef PajeDefineStateType %d\n", simgrid::instr::PAJE_DefineStateType); fprintf(tracing_file, "%% Alias string\n"); if (basic){ fprintf(tracing_file, "%% ContainerType string\n"); @@ -53,7 +53,7 @@ static void TRACE_header_PajeDefineStateType (int basic, int size) static void TRACE_header_PajeDefineEventType (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeDefineEventType %d\n", PAJE_DefineEventType); + fprintf(tracing_file, "%%EventDef PajeDefineEventType %d\n", simgrid::instr::PAJE_DefineEventType); fprintf(tracing_file, "%% Alias string\n"); if (basic){ fprintf(tracing_file, "%% ContainerType string\n"); @@ -66,7 +66,7 @@ static void TRACE_header_PajeDefineEventType (int basic, int size) static void TRACE_header_PajeDefineLinkType (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeDefineLinkType %d\n", PAJE_DefineLinkType); + fprintf(tracing_file, "%%EventDef PajeDefineLinkType %d\n", simgrid::instr::PAJE_DefineLinkType); fprintf(tracing_file, "%% Alias string\n"); if (basic){ fprintf(tracing_file, "%% ContainerType string\n"); @@ -83,7 +83,7 @@ static void TRACE_header_PajeDefineLinkType (int basic, int size) static void TRACE_header_PajeDefineEntityValue (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeDefineEntityValue %d\n", PAJE_DefineEntityValue); + fprintf(tracing_file, "%%EventDef PajeDefineEntityValue %d\n", simgrid::instr::PAJE_DefineEntityValue); fprintf(tracing_file, "%% Alias string\n"); if (basic){ fprintf(tracing_file, "%% EntityType string\n"); @@ -97,7 +97,7 @@ static void TRACE_header_PajeDefineEntityValue (int basic, int size) static void TRACE_header_PajeCreateContainer (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeCreateContainer %d\n", PAJE_CreateContainer); + fprintf(tracing_file, "%%EventDef PajeCreateContainer %d\n", simgrid::instr::PAJE_CreateContainer); fprintf(tracing_file, "%% Time date\n"); fprintf(tracing_file, "%% Alias string\n"); fprintf(tracing_file, "%% Type string\n"); @@ -108,7 +108,7 @@ static void TRACE_header_PajeCreateContainer (int basic, int size) static void TRACE_header_PajeDestroyContainer (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeDestroyContainer %d\n", PAJE_DestroyContainer); + fprintf(tracing_file, "%%EventDef PajeDestroyContainer %d\n", simgrid::instr::PAJE_DestroyContainer); fprintf(tracing_file, "%% Time date\n"); fprintf(tracing_file, "%% Type string\n"); fprintf(tracing_file, "%% Name string\n"); @@ -117,7 +117,7 @@ static void TRACE_header_PajeDestroyContainer (int basic, int size) static void TRACE_header_PajeSetVariable (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeSetVariable %d\n", PAJE_SetVariable); + fprintf(tracing_file, "%%EventDef PajeSetVariable %d\n", simgrid::instr::PAJE_SetVariable); fprintf(tracing_file, "%% Time date\n"); fprintf(tracing_file, "%% Type string\n"); fprintf(tracing_file, "%% Container string\n"); @@ -127,7 +127,7 @@ static void TRACE_header_PajeSetVariable (int basic, int size) static void TRACE_header_PajeAddVariable (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeAddVariable %d\n", PAJE_AddVariable); + fprintf(tracing_file, "%%EventDef PajeAddVariable %d\n", simgrid::instr::PAJE_AddVariable); fprintf(tracing_file, "%% Time date\n"); fprintf(tracing_file, "%% Type string\n"); fprintf(tracing_file, "%% Container string\n"); @@ -137,7 +137,7 @@ static void TRACE_header_PajeAddVariable (int basic, int size) static void TRACE_header_PajeSubVariable (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeSubVariable %d\n", PAJE_SubVariable); + fprintf(tracing_file, "%%EventDef PajeSubVariable %d\n", simgrid::instr::PAJE_SubVariable); fprintf(tracing_file, "%% Time date\n"); fprintf(tracing_file, "%% Type string\n"); fprintf(tracing_file, "%% Container string\n"); @@ -148,7 +148,7 @@ static void TRACE_header_PajeSubVariable (int basic, int size) static void TRACE_header_PajeSetState (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeSetState %d\n", PAJE_SetState); + fprintf(tracing_file, "%%EventDef PajeSetState %d\n", simgrid::instr::PAJE_SetState); fprintf(tracing_file, "%% Time date\n"); fprintf(tracing_file, "%% Type string\n"); fprintf(tracing_file, "%% Container string\n"); @@ -158,7 +158,7 @@ static void TRACE_header_PajeSetState (int basic, int size) static void TRACE_header_PajePushState (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajePushState %d\n", PAJE_PushState); + fprintf(tracing_file, "%%EventDef PajePushState %d\n", simgrid::instr::PAJE_PushState); fprintf(tracing_file, "%% Time date\n"); fprintf(tracing_file, "%% Type string\n"); fprintf(tracing_file, "%% Container string\n"); @@ -179,7 +179,7 @@ static void TRACE_header_PajePushState (int basic, int size) static void TRACE_header_PajePopState (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajePopState %d\n", PAJE_PopState); + fprintf(tracing_file, "%%EventDef PajePopState %d\n", simgrid::instr::PAJE_PopState); fprintf(tracing_file, "%% Time date\n"); fprintf(tracing_file, "%% Type string\n"); fprintf(tracing_file, "%% Container string\n"); @@ -190,7 +190,7 @@ static void TRACE_header_PajeResetState (int basic, int size) { if (basic) return; - fprintf(tracing_file, "%%EventDef PajeResetState %d\n", PAJE_ResetState); + fprintf(tracing_file, "%%EventDef PajeResetState %d\n", simgrid::instr::PAJE_ResetState); fprintf(tracing_file, "%% Time date\n"); fprintf(tracing_file, "%% Type string\n"); fprintf(tracing_file, "%% Container string\n"); @@ -199,7 +199,7 @@ static void TRACE_header_PajeResetState (int basic, int size) static void TRACE_header_PajeStartLink (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeStartLink %d\n", PAJE_StartLink); + fprintf(tracing_file, "%%EventDef PajeStartLink %d\n", simgrid::instr::PAJE_StartLink); fprintf(tracing_file, "%% Time date\n"); fprintf(tracing_file, "%% Type string\n"); fprintf(tracing_file, "%% Container string\n"); @@ -216,7 +216,7 @@ static void TRACE_header_PajeStartLink (int basic, int size) static void TRACE_header_PajeEndLink (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeEndLink %d\n", PAJE_EndLink); + fprintf(tracing_file, "%%EventDef PajeEndLink %d\n", simgrid::instr::PAJE_EndLink); fprintf(tracing_file, "%% Time date\n"); fprintf(tracing_file, "%% Type string\n"); fprintf(tracing_file, "%% Container string\n"); @@ -232,7 +232,7 @@ static void TRACE_header_PajeEndLink (int basic, int size) static void TRACE_header_PajeNewEvent (int basic, int size) { - fprintf(tracing_file, "%%EventDef PajeNewEvent %d\n", PAJE_NewEvent); + fprintf(tracing_file, "%%EventDef PajeNewEvent %d\n", simgrid::instr::PAJE_NewEvent); fprintf(tracing_file, "%% Time date\n"); fprintf(tracing_file, "%% Type string\n"); fprintf(tracing_file, "%% Container string\n"); diff --git a/src/instr/instr_paje_trace.cpp b/src/instr/instr_paje_trace.cpp index 6e9df5552f..8d10295cb1 100644 --- a/src/instr/instr_paje_trace.cpp +++ b/src/instr/instr_paje_trace.cpp @@ -27,8 +27,8 @@ FILE *tracing_file = nullptr; static xbt_dict_t tracing_files = nullptr; // TI specific static double prefix=0.0; // TI specific -std::vector buffer; -void buffer_debug(std::vector *buf); +std::vector buffer; +void buffer_debug(std::vector* buf); void dump_comment (const char *comment) { @@ -74,9 +74,9 @@ void TRACE_paje_dump_buffer (int force) } buffer.clear(); }else{ - std::vector::iterator i = buffer.begin(); + std::vector::iterator i = buffer.begin(); for (auto const& event : buffer) { - double head_timestamp = event->timestamp; + double head_timestamp = event->timestamp_; if (head_timestamp > TRACE_last_timestamp_to_dump) break; event->print(); @@ -88,8 +88,9 @@ void TRACE_paje_dump_buffer (int force) XBT_DEBUG("%s: ends", __FUNCTION__); } -void buffer_debug(std::vector *buf); -void buffer_debug(std::vector *buf) { +void buffer_debug(std::vector* buf); +void buffer_debug(std::vector* buf) +{ return; XBT_DEBUG(">>>>>> Dump the state of the buffer. %zu events", buf->size()); for (auto const& event : *buf) { @@ -109,17 +110,18 @@ static void print_row() { stream.clear(); } -static void print_timestamp(PajeEvent* event) { +static void print_timestamp(simgrid::instr::PajeEvent* event) +{ stream << " "; /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */ - if (event->timestamp < 1e-12) + if (event->timestamp_ < 1e-12) stream << 0; else - stream << event->timestamp; + stream << event->timestamp_; } /* internal do the instrumentation module */ -static void insert_into_buffer (PajeEvent* tbi) +static void insert_into_buffer(simgrid::instr::PajeEvent* tbi) { if (TRACE_buffer() == 0){ tbi->print (); @@ -128,14 +130,13 @@ static void insert_into_buffer (PajeEvent* tbi) } buffer_debug(&buffer); - XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)", - __FUNCTION__, (int)tbi->event_type, tbi->timestamp, buffer.size()); - std::vector::reverse_iterator i; + XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)", __FUNCTION__, (int)tbi->eventType_, + tbi->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 %d; timestamp:%f", e1, - (int)e1->event_type, e1->timestamp); - if (e1->timestamp <= tbi->timestamp) + simgrid::instr::PajeEvent* e1 = *i; + XBT_DEBUG("compare to %p is of type %d; timestamp:%f", e1, (int)e1->eventType_, e1->timestamp_); + if (e1->timestamp_ <= tbi->timestamp_) break; } if (i == buffer.rend()) @@ -150,10 +151,9 @@ static void insert_into_buffer (PajeEvent* tbi) buffer_debug(&buffer); } -PajeEvent:: ~PajeEvent() +simgrid::instr::PajeEvent::~PajeEvent() { - XBT_DEBUG("%s not implemented for %p: event_type=%d, timestamp=%f", __FUNCTION__, - this, (int)event_type, timestamp); + XBT_DEBUG("%s not implemented for %p: event_type=%d, timestamp=%f", __FUNCTION__, this, (int)eventType_, timestamp_); } void TRACE_paje_start() { @@ -192,15 +192,16 @@ void TRACE_paje_end() { XBT_DEBUG("Filename %s is closed", filename); } -void DefineContainerEvent(type_t type) +void LogContainerTypeDefinition(simgrid::instr::Type* type) { - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, PAJE_DefineContainerType); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType); //print it if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineContainerType, TRACE_precision(), 0.); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType, + TRACE_precision(), 0.); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << PAJE_DefineContainerType; - stream << " " << type->id << " " << type->father->id << " " << type->name; + stream << simgrid::instr::PAJE_DefineContainerType; + stream << " " << type->id_ << " " << type->father_->id_ << " " << type->name_; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -210,22 +211,21 @@ void DefineContainerEvent(type_t type) //-- } - - -void LogVariableTypeDefinition(type_t type) +void LogVariableTypeDefinition(simgrid::instr::Type* type) { - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, PAJE_DefineVariableType); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType); //print it if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineVariableType, TRACE_precision(), 0.); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << PAJE_DefineVariableType; - stream << " " << type->id << " " << type->father->id << " " << type->name; - if (type->color) - stream << " \"" << type->color << "\""; - print_row(); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType, + TRACE_precision(), 0.); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << simgrid::instr::PAJE_DefineVariableType; + stream << " " << type->id_ << " " << type->father_->id_ << " " << type->name_; + if (type->color_) + stream << " \"" << type->color_ << "\""; + print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ } else { @@ -233,16 +233,16 @@ if (instr_fmt_type == instr_fmt_paje) { } } - -void LogStateTypeDefinition(type_t type) +void LogStateTypeDefinition(simgrid::instr::Type* type) { //print it if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineStateType, TRACE_precision(), 0.); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << PAJE_DefineStateType; - stream << " " << type->id << " " << type->father->id << " " << type->name; - print_row(); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineStateType, TRACE_precision(), + 0.); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << simgrid::instr::PAJE_DefineStateType; + stream << " " << type->id_ << " " << type->father_->id_ << " " << type->name_; + print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ } else { @@ -250,15 +250,15 @@ if (instr_fmt_type == instr_fmt_paje) { } } - -void LogDefineEventType(type_t type) +void LogDefineEventType(simgrid::instr::Type* type) { //print it if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineEventType, TRACE_precision(), 0.); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineEventType, + TRACE_precision(), 0.); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << PAJE_DefineEventType; - stream << " " << type->id << " " << type->father->id << " " << type->name; + stream << simgrid::instr::PAJE_DefineEventType; + stream << " " << type->id_ << " " << type->father_->id_ << " " << type->name_; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -267,16 +267,18 @@ void LogDefineEventType(type_t type) } } -void LogLinkTypeDefinition(type_t type, type_t source, type_t dest) +void LogLinkTypeDefinition(simgrid::instr::Type* type, simgrid::instr::Type* source, simgrid::instr::Type* dest) { - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, PAJE_DefineLinkType); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType); //print it if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineLinkType, TRACE_precision(), 0.); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << PAJE_DefineLinkType; - stream << " " << type->id << " " << type->father->id << " " << source->id << " " << dest->id << " " << type->name; - print_row(); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType, TRACE_precision(), + 0.); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << simgrid::instr::PAJE_DefineLinkType; + stream << " " << type->id_ << " " << type->father_->id_ << " " << source->id_ << " " << dest->id_ << " " + << type->name_; + print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ } else { @@ -284,16 +286,16 @@ if (instr_fmt_type == instr_fmt_paje) { } } -void LogEntityValue(value* val) +void LogEntityValue(simgrid::instr::Value* val) { - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, PAJE_DefineEntityValue); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineEntityValue); //print it if (instr_fmt_type == instr_fmt_paje) { stream << std::fixed << std::setprecision(TRACE_precision()); - stream << PAJE_DefineEntityValue; - stream << " " << val->id << " " << val->father->id << " " << val->name; - if (val->color) - stream << " \"" << val->color << "\""; + stream << simgrid::instr::PAJE_DefineEntityValue; + stream << " " << val->id_ << " " << val->father_->id_ << " " << val->name_; + if (val->color_) + stream << " \"" << val->color_ << "\""; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -305,21 +307,21 @@ if (instr_fmt_type == instr_fmt_paje) { void LogContainerCreation (container_t container) { - double timestamp = SIMIX_get_clock(); + double timestamp = SIMIX_get_clock(); - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, PAJE_CreateContainer,timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_CreateContainer, timestamp); -if (instr_fmt_type == instr_fmt_paje) { + if (instr_fmt_type == instr_fmt_paje) { stream << std::fixed << std::setprecision(TRACE_precision()); - stream << PAJE_CreateContainer; + stream << simgrid::instr::PAJE_CreateContainer; stream << " "; /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */ if (timestamp < 1e-12) stream << 0; else stream << timestamp; - stream << " " << container->id << " " << container->type->id << " " << container->father->id << " \"" - << container->name << "\""; + stream << " " << container->id_ << " " << container->type_->id_ << " " << container->father_->id_ << " \"" + << container->name_ << "\""; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { @@ -334,7 +336,7 @@ if (instr_fmt_type == instr_fmt_paje) { if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || ti_unique_file == nullptr) { char* folder_name = bprintf("%s_files", TRACE_get_filename()); - char* filename = bprintf("%s/%f_%s.txt", folder_name, prefix, container->name); + char* filename = bprintf("%s/%f_%s.txt", folder_name, prefix, container->name_); #ifdef WIN32 _mkdir(folder_name); #else @@ -348,7 +350,7 @@ if (instr_fmt_type == instr_fmt_paje) { xbt_free(filename); } - xbt_dict_set(tracing_files, container->name, (void*)ti_unique_file, nullptr); + xbt_dict_set(tracing_files, container->name_, (void*)ti_unique_file, nullptr); } else { THROW_IMPOSSIBLE; } @@ -358,51 +360,51 @@ void LogContainerDestruction(container_t container) { double timestamp = SIMIX_get_clock(); - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, PAJE_DestroyContainer, timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, simgrid::instr::PAJE_DestroyContainer, timestamp); -if (instr_fmt_type == instr_fmt_paje) { + if (instr_fmt_type == instr_fmt_paje) { stream << std::fixed << std::setprecision(TRACE_precision()); - stream << PAJE_DestroyContainer; + stream << simgrid::instr::PAJE_DestroyContainer; stream << " "; /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */ if (timestamp < 1e-12) stream << 0; else stream << timestamp; - stream << " " << container->type->id << " " << container->id; + stream << " " << container->type_->id_ << " " << container->id_; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || xbt_dict_length(tracing_files) == 1) { - FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, container->name); + FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, container->name_); fclose(f); } - xbt_dict_remove(tracing_files, container->name); + xbt_dict_remove(tracing_files, container->name_); } else { THROW_IMPOSSIBLE; } } - -SetVariableEvent::SetVariableEvent (double timestamp, container_t container, type_t type, double value) +simgrid::instr::SetVariableEvent::SetVariableEvent(double timestamp, container_t container, Type* type, double value) { - this->event_type = PAJE_SetVariable; - this->timestamp = timestamp; + this->eventType_ = PAJE_SetVariable; + this->timestamp_ = timestamp; this->type = type; this->container = container; this->value = value; - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_); insert_into_buffer (this); } -void SetVariableEvent::print() { +void simgrid::instr::SetVariableEvent::print() +{ if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << (int)this->eventType_; print_timestamp(this); - stream << " " << type->id << " " << container->id << " " << value; + stream << " " << type->id_ << " " << container->id_ << " " << value; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -411,26 +413,28 @@ void SetVariableEvent::print() { } } -AddVariableEvent::AddVariableEvent (double timestamp, container_t container, type_t type, double value) +simgrid::instr::AddVariableEvent::AddVariableEvent(double timestamp, container_t container, simgrid::instr::Type* type, + double value) { - this->event_type = PAJE_AddVariable; - this->timestamp = timestamp; + this->eventType_ = PAJE_AddVariable; + this->timestamp_ = timestamp; this->type = type; this->container = container; this->value = value; - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_); insert_into_buffer (this); } -void AddVariableEvent::print() { +void simgrid::instr::AddVariableEvent::print() +{ if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << (int)this->eventType_; print_timestamp(this); - stream << " " << type->id << " " << container->id << " " << value; + stream << " " << type->id_ << " " << container->id_ << " " << value; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -439,26 +443,27 @@ void AddVariableEvent::print() { } } -SubVariableEvent::SubVariableEvent (double timestamp, container_t container, type_t type, double value) +simgrid::instr::SubVariableEvent::SubVariableEvent(double timestamp, container_t container, Type* type, double value) { - this->event_type = PAJE_SubVariable; - this->timestamp = timestamp; + this->eventType_ = PAJE_SubVariable; + this->timestamp_ = timestamp; this->type = type; this->container = container; this->value = value; - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_); insert_into_buffer (this); } -void SubVariableEvent::print() { +void simgrid::instr::SubVariableEvent::print() +{ if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << (int)this->eventType_; print_timestamp(this); - stream << " " << type->id << " " << container->id << " " << value; + stream << " " << type->id_ << " " << container->id_ << " " << value; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -467,10 +472,10 @@ void SubVariableEvent::print() { } } -SetStateEvent::SetStateEvent(double timestamp, container_t container, type_t type, value* val) +simgrid::instr::SetStateEvent::SetStateEvent(double timestamp, container_t container, Type* type, Value* val) { - this->event_type = PAJE_SetState; - this->timestamp = timestamp; + this->eventType_ = PAJE_SetState; + this->timestamp_ = timestamp; this->type = type; this->container = container; this->val = val; @@ -483,19 +488,20 @@ SetStateEvent::SetStateEvent(double timestamp, container_t container, type_t typ } #endif - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_); insert_into_buffer (this); } -void SetStateEvent::print() { +void simgrid::instr::SetStateEvent::print() +{ if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << (int)this->eventType_; print_timestamp(this); - stream << " " << type->id << " " << container->id; - stream << " " << val->id; + stream << " " << type->id_ << " " << container->id_; + stream << " " << val->id_; #if HAVE_SMPI if (xbt_cfg_get_boolean("smpi/trace-call-location")) { stream << " \"" << filename << "\" " << linenumber; @@ -509,10 +515,11 @@ void SetStateEvent::print() { } } -PushStateEvent::PushStateEvent(double timestamp, container_t container, type_t type, value* val, void* extra) +simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* val, + void* extra) { - this->event_type = PAJE_PushState; - this->timestamp = timestamp; + this->eventType_ = PAJE_PushState; + this->timestamp_ = timestamp; this->type = type; this->container = container; this->val = val; @@ -526,22 +533,23 @@ PushStateEvent::PushStateEvent(double timestamp, container_t container, type_t t } #endif - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_); insert_into_buffer (this); } -PushStateEvent::PushStateEvent(double timestamp, container_t container, type_t type, value* val) +simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* val) : PushStateEvent(timestamp, container, type, val, nullptr) {} -void PushStateEvent::print() { +void simgrid::instr::PushStateEvent::print() +{ if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << (int)this->eventType_; print_timestamp(this); - stream << " " << type->id << " " << container->id; - stream << " " << val->id; + stream << " " << type->id_ << " " << container->id_; + stream << " " << val->id_; if (TRACE_display_sizes()) { stream << " "; @@ -572,12 +580,12 @@ void PushStateEvent::print() { char* process_id = nullptr; // FIXME: dirty extract "rank-" from the name, as we want the bare process id here - if (strstr(container->name, "rank-") == nullptr) - process_id = xbt_strdup(container->name); + if (strstr(container->name_, "rank-") == nullptr) + process_id = xbt_strdup(container->name_); else - process_id = xbt_strdup(container->name + 5); + process_id = xbt_strdup(container->name_ + 5); - FILE* trace_file = (FILE*)xbt_dict_get(tracing_files, container->name); + FILE* trace_file = (FILE*)xbt_dict_get(tracing_files, container->name_); switch (extra->type) { case TRACING_INIT: @@ -682,7 +690,7 @@ void PushStateEvent::print() { case TRACING_SSEND: case TRACING_ISSEND: default: - XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", val->name); + XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", val->name_); break; } @@ -698,26 +706,26 @@ void PushStateEvent::print() { } } - -PopStateEvent::PopStateEvent (double timestamp, container_t container, type_t type) +simgrid::instr::PopStateEvent::PopStateEvent(double timestamp, container_t container, Type* type) { - this->event_type = PAJE_PopState; - this->timestamp = timestamp; + this->eventType_ = PAJE_PopState; + this->timestamp_ = timestamp; this->type = type; this->container = container; - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_); insert_into_buffer (this); } -void PopStateEvent::print() { +void simgrid::instr::PopStateEvent::print() +{ if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << (int)this->eventType_; print_timestamp(this); - stream << " " << type->id << " " << container->id; + stream << " " << type->id_ << " " << container->id_; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -726,26 +734,27 @@ void PopStateEvent::print() { } } -ResetStateEvent::ResetStateEvent (double timestamp, container_t container, type_t type) +simgrid::instr::ResetStateEvent::ResetStateEvent(double timestamp, container_t container, Type* type) { - this->event_type = PAJE_ResetState; - this->timestamp = timestamp; + this->eventType_ = PAJE_ResetState; + this->timestamp_ = timestamp; this->type = type; this->container = container; - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_); insert_into_buffer (this); delete[] this; } -void ResetStateEvent::print() { +void simgrid::instr::ResetStateEvent::print() +{ if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << (int)this->eventType_; print_timestamp(this); - stream << " " << type->id << " " << container->id; + stream << " " << type->id_ << " " << container->id_; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -754,21 +763,22 @@ void ResetStateEvent::print() { } } -StartLinkEvent::~StartLinkEvent() +simgrid::instr::StartLinkEvent::~StartLinkEvent() { free(value); free(key); } -StartLinkEvent::StartLinkEvent (double timestamp, container_t container, - type_t type, container_t sourceContainer, const char *value, const char *key) - : StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1) +simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type, + container_t sourceContainer, const char* value, const char* key) + : StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1) {} -StartLinkEvent::StartLinkEvent (double timestamp, container_t container, type_t type, container_t sourceContainer, - const char *value, const char *key, int size) +simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type, + container_t sourceContainer, const char* value, const char* key, + int size) { - event_type = PAJE_StartLink; - this->timestamp = timestamp; + eventType_ = PAJE_StartLink; + this->timestamp_ = timestamp; this->type = type; this->container = container; this->sourceContainer = sourceContainer; @@ -776,20 +786,20 @@ StartLinkEvent::StartLinkEvent (double timestamp, container_t container, type_t this->key = xbt_strdup(key); this->size = size; - XBT_DEBUG("%s: event_type=%d, timestamp=%f, value:%s", __FUNCTION__, - (int)event_type, this->timestamp, this->value); + XBT_DEBUG("%s: event_type=%d, timestamp=%f, value:%s", __FUNCTION__, (int)eventType_, this->timestamp_, this->value); insert_into_buffer (this); } -void StartLinkEvent::print() { +void simgrid::instr::StartLinkEvent::print() +{ if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << (int)this->eventType_; print_timestamp(this); - stream << " " << type->id << " " << container->id << " " << value; - stream << " " << sourceContainer->id << " " << key; + stream << " " << type->id_ << " " << container->id_ << " " << value; + stream << " " << sourceContainer->id_ << " " << key; if (TRACE_display_sizes()) { stream << " " << size; @@ -802,35 +812,36 @@ void StartLinkEvent::print() { } } -EndLinkEvent::EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer, - const char *value, const char *key) +simgrid::instr::EndLinkEvent::EndLinkEvent(double timestamp, container_t container, Type* type, + container_t destContainer, const char* value, const char* key) { - this->event_type = PAJE_EndLink; - this->timestamp = timestamp; + this->eventType_ = PAJE_EndLink; + this->timestamp_ = timestamp; this->type = type; this->container = container; this->destContainer = destContainer; this->value = xbt_strdup(value); this->key = xbt_strdup(key); - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_); insert_into_buffer (this); } -EndLinkEvent::~EndLinkEvent() +simgrid::instr::EndLinkEvent::~EndLinkEvent() { free(value); free(key); } -void EndLinkEvent::print() { +void simgrid::instr::EndLinkEvent::print() +{ if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << (int)this->eventType_; print_timestamp(this); - stream << " " << type->id << " " << container->id << " " << value; - stream << " " << destContainer->id << " " << key; + stream << " " << type->id_ << " " << container->id_ << " " << value; + stream << " " << destContainer->id_ << " " << key; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -839,26 +850,27 @@ void EndLinkEvent::print() { } } -NewEvent::NewEvent(double timestamp, container_t container, type_t type, value* val) +simgrid::instr::NewEvent::NewEvent(double timestamp, container_t container, Type* type, Value* val) { - this->event_type = PAJE_NewEvent; - this->timestamp = timestamp; + this->eventType_ = PAJE_NewEvent; + this->timestamp_ = timestamp; this->type = type; this->container = container; this->val = val; - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)eventType_, this->timestamp_); insert_into_buffer (this); } -void NewEvent::print () { +void simgrid::instr::NewEvent::print() +{ if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)eventType_, TRACE_precision(), timestamp_); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << (int)this->eventType_; print_timestamp(this); - stream << " " << type->id << " " << container->id << " " << val->id; + stream << " " << type->id_ << " " << container->id_ << " " << val->id_; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index 792fc4ce5e..2ee897097a 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -8,94 +8,91 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_types, instr, "Paje tracing event system (types)"); -static type_t rootType = nullptr; /* the root type */ +static simgrid::instr::Type* rootType = nullptr; /* the root type */ void PJ_type_release () { rootType = nullptr; } -type_t PJ_type_get_root () +simgrid::instr::Type* PJ_type_get_root() { return rootType; } -static type_t newType (const char *typeNameBuff, const char *key, const char *color, e_entity_types kind, type_t father) +simgrid::instr::Type::Type(const char* typeNameBuff, const char* key, const char* color, e_entity_types kind, + Type* father) + : kind_(kind), father_(father) { if (typeNameBuff == nullptr || key == nullptr){ THROWF(tracing_error, 0, "can't create a new type with name or key equal nullptr"); } - type_t ret = xbt_new0(s_type, 1); - ret->name = xbt_strdup (typeNameBuff); - ret->father = father; - ret->kind = kind; - ret->children = xbt_dict_new_homogeneous(nullptr); - ret->values = xbt_dict_new_homogeneous(nullptr); - ret->color = xbt_strdup (color); + this->name_ = xbt_strdup(typeNameBuff); + this->children_ = xbt_dict_new_homogeneous(nullptr); + this->values_ = xbt_dict_new_homogeneous(nullptr); + this->color_ = xbt_strdup(color); char str_id[INSTR_DEFAULT_STR_SIZE]; snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id()); - ret->id = xbt_strdup (str_id); + this->id_ = xbt_strdup(str_id); if (father != nullptr){ - xbt_dict_set (father->children, key, ret, nullptr); - XBT_DEBUG("new type %s, child of %s", typeNameBuff, father->name); + xbt_dict_set(father->children_, key, this, nullptr); + XBT_DEBUG("new type %s, child of %s", typeNameBuff, father->name_); } - return ret; } -void PJ_type_free (type_t type) +void PJ_type_free(simgrid::instr::Type* type) { - value* val; + simgrid::instr::Value* val; char *value_name; xbt_dict_cursor_t cursor = nullptr; - xbt_dict_foreach (type->values, cursor, value_name, val) { - XBT_DEBUG("free value %s, child of %s", val->name, val->father->name); + xbt_dict_foreach (type->values_, cursor, value_name, val) { + XBT_DEBUG("free value %s, child of %s", val->name_, val->father_->name_); xbt_free(val); } - xbt_dict_free (&type->values); - xbt_free (type->name); - xbt_free (type->id); - xbt_free (type->color); - xbt_dict_free (&type->children); - xbt_free (type); - type = nullptr; + xbt_dict_free(&type->values_); + xbt_free(type->name_); + xbt_free(type->id_); + xbt_free(type->color_); + xbt_dict_free(&type->children_); + delete type; } -void recursiveDestroyType (type_t type) +void recursiveDestroyType(simgrid::instr::Type* type) { - XBT_DEBUG("recursiveDestroyType %s", type->name); + XBT_DEBUG("recursiveDestroyType %s", type->name_); xbt_dict_cursor_t cursor = nullptr; - type_t child; + simgrid::instr::Type* child; char *child_name; - xbt_dict_foreach(type->children, cursor, child_name, child) { + xbt_dict_foreach (type->children_, cursor, child_name, child) { recursiveDestroyType (child); } PJ_type_free(type); } -type_t PJ_type_get (const char *name, type_t father) +simgrid::instr::Type* PJ_type_get(const char* name, simgrid::instr::Type* father) { - type_t ret = PJ_type_get_or_null (name, father); + simgrid::instr::Type* ret = simgrid::instr::Type::getOrNull(name, father); if (ret == nullptr){ - THROWF (tracing_error, 2, "type with name (%s) not found in father type (%s)", name, father->name); + THROWF(tracing_error, 2, "type with name (%s) not found in father type (%s)", name, father->name_); } return ret; } -type_t PJ_type_get_or_null (const char *name, type_t father) +simgrid::instr::Type* simgrid::instr::Type::getOrNull(const char* name, simgrid::instr::Type* father) { if (name == nullptr || father == nullptr){ THROWF (tracing_error, 0, "can't get type with a nullptr name or from a nullptr father"); } - type_t ret = nullptr; - type_t child; + simgrid::instr::Type* ret = nullptr; + simgrid::instr::Type* child; char *child_name; xbt_dict_cursor_t cursor = nullptr; - xbt_dict_foreach(father->children, cursor, child_name, child) { - if (strcmp (child->name, name) == 0){ + xbt_dict_foreach (father->children_, cursor, child_name, child) { + if (strcmp(child->name_, name) == 0) { if (ret != nullptr){ THROWF (tracing_error, 0, "there are two children types with the same name?"); }else{ @@ -106,80 +103,77 @@ type_t PJ_type_get_or_null (const char *name, type_t father) return ret; } -type_t PJ_type_container_new (const char *name, type_t father) +simgrid::instr::Type* simgrid::instr::Type::containerNew(const char* name, simgrid::instr::Type* father) { if (name == nullptr){ THROWF (tracing_error, 0, "can't create a container type with a nullptr name"); } - type_t ret = newType(name, name, nullptr, TYPE_CONTAINER, father); + simgrid::instr::Type* ret = new simgrid::instr::Type(name, name, nullptr, TYPE_CONTAINER, father); if (father == nullptr) { rootType = ret; } else { - XBT_DEBUG("ContainerType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); - DefineContainerEvent(ret); + XBT_DEBUG("ContainerType %s(%s), child of %s(%s)", ret->name_, ret->id_, father->name_, father->id_); + LogContainerTypeDefinition(ret); } return ret; } -type_t PJ_type_event_new (const char *name, type_t father) +simgrid::instr::Type* simgrid::instr::Type::eventNew(const char* name, simgrid::instr::Type* father) { if (name == nullptr){ THROWF (tracing_error, 0, "can't create an event type with a nullptr name"); } - type_t ret = newType (name, name, nullptr, TYPE_EVENT, father); - XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); + Type* ret = new Type (name, name, nullptr, TYPE_EVENT, father); + XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->name_, ret->id_, father->name_, father->id_); LogDefineEventType(ret); return ret; } -type_t PJ_type_variable_new (const char *name, const char *color, type_t father) +simgrid::instr::Type* simgrid::instr::Type::variableNew(const char* name, const char* color, + simgrid::instr::Type* father) { if (name == nullptr){ THROWF (tracing_error, 0, "can't create a variable type with a nullptr name"); } - type_t ret = nullptr; + Type* ret = nullptr; if (not color) { char white[INSTR_DEFAULT_STR_SIZE] = "1 1 1"; - ret = newType (name, name, white, TYPE_VARIABLE, father); + ret = new Type (name, name, white, TYPE_VARIABLE, father); }else{ - ret = newType (name, name, color, TYPE_VARIABLE, father); + ret = new Type (name, name, color, TYPE_VARIABLE, father); } - XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); + XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->name_, ret->id_, father->name_, father->id_); LogVariableTypeDefinition (ret); return ret; } -type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest) +simgrid::instr::Type* simgrid::instr::Type::linkNew(const char* name, Type* father, Type* source, Type* dest) { if (name == nullptr){ THROWF (tracing_error, 0, "can't create a link type with a nullptr name"); } - type_t ret = nullptr; - char key[INSTR_DEFAULT_STR_SIZE]; - snprintf (key, INSTR_DEFAULT_STR_SIZE, "%s-%s-%s", name, source->id, dest->id); - ret = newType (name, key, nullptr, TYPE_LINK, father); - XBT_DEBUG("LinkType %s(%s), child of %s(%s) %s(%s)->%s(%s)", ret->name, ret->id, father->name, father->id, - source->name, source->id, dest->name, dest->id); + snprintf(key, INSTR_DEFAULT_STR_SIZE, "%s-%s-%s", name, source->id_, dest->id_); + Type* ret = new Type(name, key, nullptr, TYPE_LINK, father); + XBT_DEBUG("LinkType %s(%s), child of %s(%s) %s(%s)->%s(%s)", ret->name_, ret->id_, father->name_, father->id_, + source->name_, source->id_, dest->name_, dest->id_); LogLinkTypeDefinition(ret, source, dest); return ret; } -type_t PJ_type_state_new (const char *name, type_t father) +simgrid::instr::Type* simgrid::instr::Type::stateNew(const char* name, Type* father) { if (name == nullptr){ THROWF (tracing_error, 0, "can't create a state type with a nullptr name"); } - type_t ret = nullptr; - - ret = newType (name, name, nullptr, TYPE_STATE, father); - XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); + Type* ret = new Type(name, name, nullptr, TYPE_STATE, father); + XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->name_, ret->id_, father->name_, father->id_); LogStateTypeDefinition(ret); return ret; } diff --git a/src/instr/instr_paje_values.cpp b/src/instr/instr_paje_values.cpp index 84152ec3af..066d77f3c5 100644 --- a/src/instr/instr_paje_values.cpp +++ b/src/instr/instr_paje_values.cpp @@ -10,26 +10,26 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event system (values)"); -value::value(const char* name, const char* color, type_t father) +simgrid::instr::Value::Value(const char* name, const char* color, simgrid::instr::Type* father) { if (name == nullptr || father == nullptr){ THROWF (tracing_error, 0, "can't create a value with a nullptr name (or a nullptr father)"); } - this->ret = xbt_new0(value, 1); - this->ret->name = xbt_strdup (name); - this->ret->father = father; - this->ret->color = xbt_strdup (color); + this->ret_ = xbt_new0(Value, 1); + this->ret_->name_ = xbt_strdup(name); + this->ret_->father_ = father; + this->ret_->color_ = xbt_strdup(color); char str_id[INSTR_DEFAULT_STR_SIZE]; snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id()); - this->ret->id = xbt_strdup (str_id); + this->ret_->id_ = xbt_strdup(str_id); - xbt_dict_set (father->values, name, ret, nullptr); - XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name); - LogEntityValue(this->ret); + xbt_dict_set(father->values_, name, ret_, nullptr); + XBT_DEBUG("new value %s, child of %s", ret_->name_, ret_->father_->name_); + LogEntityValue(this->ret_); }; -value::~value() +simgrid::instr::Value::~Value() { /* FIXME: this should be cleanable xbt_free(name); @@ -38,30 +38,31 @@ value::~value() */ } -value* value::get_or_new(const char* name, const char* color, type_t father) +simgrid::instr::Value* simgrid::instr::Value::get_or_new(const char* name, const char* color, + simgrid::instr::Type* father) { - value* ret = 0; + Value* ret = 0; try { - ret = value::get(name, father); + ret = Value::get(name, father); } catch(xbt_ex& e) { - value rett(name, color, father); - ret = rett.ret; + Value rett(name, color, father); + ret = rett.ret_; } return ret; } -value* value::get(const char* name, type_t father) +simgrid::instr::Value* simgrid::instr::Value::get(const char* name, Type* father) { if (name == nullptr || father == nullptr){ THROWF (tracing_error, 0, "can't get a value with a nullptr name (or a nullptr father)"); } - if (father->kind == TYPE_VARIABLE) - THROWF(tracing_error, 0, "variables can't have different values (%s)", father->name); - value* ret = (value*)xbt_dict_get_or_null(father->values, name); + if (father->kind_ == TYPE_VARIABLE) + THROWF(tracing_error, 0, "variables can't have different values (%s)", father->name_); + Value* ret = (Value*)xbt_dict_get_or_null(father->values_, name); if (ret == nullptr) { - THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name, father->name); + THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name, father->name_); } return ret; } diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index a2a6b153bc..ea77f8bda7 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -14,8 +14,6 @@ #include "src/internal_config.h" #include -SG_BEGIN_DECL() - /* Need to define function drand48 for Windows */ /* FIXME: use _drand48() defined in src/surf/random_mgr.c instead */ #ifdef _WIN32 @@ -27,6 +25,8 @@ SG_BEGIN_DECL() #include "xbt/graph.h" #include "xbt/dict.h" +namespace simgrid { +namespace instr { typedef enum { PAJE_DefineContainerType, PAJE_DefineVariableType, @@ -57,33 +57,39 @@ typedef enum { } e_entity_types; //-------------------------------------------------- -class s_type; -typedef s_type *type_t; -class s_type { - public: - char *id; - char *name; - char *color; - e_entity_types kind; - s_type *father; - xbt_dict_t children; - xbt_dict_t values; //valid for all types except variable and container -}; -typedef s_type s_type_t; +class Type { +public: + char* id_; + char* name_; + char* color_; + + e_entity_types kind_; + Type* father_; + xbt_dict_t children_; + xbt_dict_t values_; // valid for all types except variable and container + Type(const char* typeNameBuff, const char* key, const char* color, e_entity_types kind, Type* father); + static Type* getOrNull(const char* name, Type* father); + static Type* containerNew(const char* name, Type* father); + static Type* eventNew(const char* name, Type* father); + static Type* variableNew(const char* name, const char* color, Type* father); + static Type* linkNew(const char* name, Type* father, Type* source, Type* dest); + static Type* stateNew(const char* name, Type* father); +}; //-------------------------------------------------- -class value { +class Value { public: - char *id; - char *name; - char *color; - type_t father; - value* ret; - value(const char* name, const char* color, type_t father); - ~value(); - static value* get_or_new(const char* name, const char* color, type_t father); - static value* get(const char* name, type_t father); + char* id_; + char* name_; + char* color_; + + Type* father_; + Value* ret_; + Value(const char* name, const char* color, Type* father); + ~Value(); + static Value* get_or_new(const char* name, const char* color, Type* father); + static Value* get(const char* name, Type* father); }; @@ -100,172 +106,163 @@ typedef enum { } e_container_types; //-------------------------------------------------- -class s_container; -typedef s_container *container_t; -class s_container { - public: - sg_netpoint_t netpoint; - char *name; /* Unique name of this container */ - char *id; /* Unique id of this container */ - type_t type; /* Type of this container */ - int level; /* Level in the hierarchy, root level is 0 */ - e_container_types kind; /* This container is of what kind */ - s_container *father; - xbt_dict_t children; +class Container { +public: + Container(const char* name, simgrid::instr::e_container_types kind, Container* father); + virtual ~Container(); + + sg_netpoint_t netpoint_; + char* name_; /* Unique name of this container */ + char* id_; /* Unique id of this container */ + Type* type_; /* Type of this container */ + int level_ = 0; /* Level in the hierarchy, root level is 0 */ + e_container_types kind_; /* This container is of what kind */ + Container* father_; + xbt_dict_t children_; }; -typedef s_container s_container_t; //-------------------------------------------------- class PajeEvent { public: - double timestamp; - e_event_type event_type; - virtual void print() = 0; - void *data; - virtual ~PajeEvent(); + double timestamp_; + e_event_type eventType_; + virtual void print() = 0; + virtual ~PajeEvent(); }; //-------------------------------------------------- - -class DefineVariableTypeEvent : public PajeEvent -{ - public: - type_t type; - DefineVariableTypeEvent(type_t type); - void print() override; -}; -//-------------------------------------------------- - -class DefineStateTypeEvent : public PajeEvent { - type_t type; - public: - DefineStateTypeEvent(type_t type); - void print() override; -}; - - class SetVariableEvent : public PajeEvent { private: - container_t container; - type_t type; - double value; + Container* container; + Type* type; + double value; + public: - SetVariableEvent (double timestamp, container_t container, type_t type, double value); - void print() override; + SetVariableEvent(double timestamp, Container* container, Type* type, double value); + void print() override; }; - class AddVariableEvent:public PajeEvent { private: - container_t container; - type_t type; - double value; + Container* container; + Type* type; + double value; + public: - AddVariableEvent (double timestamp, container_t container, type_t type, double value); - void print() override; + AddVariableEvent(double timestamp, Container* container, Type* type, double value); + void print() override; }; - //-------------------------------------------------- class SubVariableEvent : public PajeEvent { private: - container_t container; - type_t type; - double value; + Container* container; + Type* type; + double value; + public: - SubVariableEvent(double timestamp, container_t container, type_t type, double value); - void print() override; + SubVariableEvent(double timestamp, Container* container, Type* type, double value); + void print() override; }; //-------------------------------------------------- class SetStateEvent : public PajeEvent { private: - container_t container; - type_t type; - value* val; - const char* filename; - int linenumber; + Container* container; + Type* type; + Value* val; + const char* filename; + int linenumber; + public: - SetStateEvent(double timestamp, container_t container, type_t type, value* val); + SetStateEvent(double timestamp, Container* container, Type* type, Value* val); void print() override; }; class PushStateEvent : public PajeEvent { public: - container_t container; - type_t type; - value* val; - int size; - const char* filename; - int linenumber; - void* extra_; + Container* container; + Type* type; + Value* val; + int size; + const char* filename; + int linenumber; + void* extra_; + public: - PushStateEvent(double timestamp, container_t container, type_t type, value* val); - PushStateEvent(double timestamp, container_t container, type_t type, value* val, void* extra); + PushStateEvent(double timestamp, Container* container, Type* type, Value* val); + PushStateEvent(double timestamp, Container* container, Type* type, Value* val, void* extra); void print() override; }; class PopStateEvent : public PajeEvent { - container_t container; - type_t type; - public: - PopStateEvent (double timestamp, container_t container, type_t type); + Container* container; + Type* type; + +public: + PopStateEvent(double timestamp, Container* container, Type* type); void print() override; }; class ResetStateEvent : public PajeEvent { - container_t container; - type_t type; - public: - ResetStateEvent (double timestamp, container_t container, type_t type); + Container* container; + Type* type; + +public: + ResetStateEvent(double timestamp, Container* container, Type* type); void print() override; }; class StartLinkEvent : public PajeEvent { public: - container_t container; - type_t type; - container_t sourceContainer; - char *value; - char *key; - int size; + Container* container; + Type* type; + Container* sourceContainer; + char* value; + char* key; + int size; + public: ~StartLinkEvent(); - StartLinkEvent(double timestamp, container_t container, type_t type, container_t sourceContainer, const char* value, + StartLinkEvent(double timestamp, Container* container, Type* type, Container* sourceContainer, const char* value, const char* key); - StartLinkEvent(double timestamp, container_t container, type_t type, container_t sourceContainer, const char* value, + StartLinkEvent(double timestamp, Container* container, Type* type, Container* sourceContainer, const char* value, const char* key, int size); void print() override; }; class EndLinkEvent : public PajeEvent { - container_t container; - type_t type; - container_t destContainer; + Container* container; + Type* type; + Container* destContainer; char *value; char *key; public: - EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer, - const char *value, const char *key); - ~EndLinkEvent(); - void print() override; + EndLinkEvent(double timestamp, Container* container, Type* type, Container* destContainer, const char* value, + const char* key); + ~EndLinkEvent(); + void print() override; }; class NewEvent : public PajeEvent { public: - container_t container; - type_t type; - value* val; - -public: - NewEvent(double timestamp, container_t container, type_t type, value* val); - void print() override; + Container* container; + Type* type; + Value* val; + public: + NewEvent(double timestamp, Container* container, Type* type, Value* val); + void print() override; }; +} +} // namespace simgrid::instr +typedef simgrid::instr::Container* container_t; + +SG_BEGIN_DECL() extern XBT_PRIVATE std::set created_categories; extern XBT_PRIVATE std::set declared_marks; @@ -331,29 +328,21 @@ extern XBT_PRIVATE std::set trivaEdgeTypes; XBT_PRIVATE long long int instr_new_paje_id (); XBT_PRIVATE void PJ_container_alloc (); XBT_PRIVATE void PJ_container_release (); -XBT_PUBLIC(container_t) PJ_container_new (const char *name, e_container_types kind, container_t father); XBT_PUBLIC(container_t) PJ_container_get (const char *name); XBT_PUBLIC(container_t) PJ_container_get_or_null (const char *name); XBT_PUBLIC(container_t) PJ_container_get_root (); XBT_PUBLIC(void) PJ_container_set_root (container_t root); -XBT_PUBLIC(void) PJ_container_free (container_t container); XBT_PUBLIC(void) PJ_container_free_all (void); XBT_PUBLIC(void) PJ_container_remove_from_parent (container_t container); /* instr_paje_types.c */ XBT_PRIVATE void PJ_type_release (); -XBT_PUBLIC(type_t) PJ_type_get_root (); -XBT_PRIVATE type_t PJ_type_container_new (const char *name, type_t father); -XBT_PRIVATE type_t PJ_type_event_new (const char *name, type_t father); -type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest); -XBT_PRIVATE XBT_PRIVATE type_t PJ_type_variable_new (const char *name, const char *color, type_t father); -XBT_PRIVATE type_t PJ_type_state_new (const char *name, type_t father); -XBT_PUBLIC(type_t) PJ_type_get (const char *name, const type_t father); -XBT_PUBLIC(type_t) PJ_type_get_or_null (const char *name, type_t father); -XBT_PRIVATE XBT_PRIVATE void PJ_type_free (type_t type); +XBT_PUBLIC(simgrid::instr::Type*) PJ_type_get_root(); +XBT_PUBLIC(simgrid::instr::Type*) PJ_type_get(const char* name, simgrid::instr::Type* father); +XBT_PRIVATE XBT_PRIVATE void PJ_type_free(simgrid::instr::Type* type); /* instr_config.c */ -XBT_PRIVATE void recursiveDestroyType (type_t type); +XBT_PRIVATE void recursiveDestroyType(simgrid::instr::Type* type); XBT_PRIVATE void TRACE_TI_start(); XBT_PRIVATE void TRACE_TI_end(); @@ -427,13 +416,13 @@ extern instr_fmt_type_t instr_fmt_type; SG_END_DECL() -void DefineContainerEvent(type_t type); -void LogVariableTypeDefinition(type_t type); -void LogStateTypeDefinition(type_t type); -void LogLinkTypeDefinition(type_t type, type_t source, type_t dest); -void LogEntityValue(value* val); +void LogContainerTypeDefinition(simgrid::instr::Type* type); +void LogVariableTypeDefinition(simgrid::instr::Type* type); +void LogStateTypeDefinition(simgrid::instr::Type* type); +void LogLinkTypeDefinition(simgrid::instr::Type* type, simgrid::instr::Type* source, simgrid::instr::Type* dest); +void LogEntityValue(simgrid::instr::Value* val); void LogContainerCreation (container_t container); void LogContainerDestruction (container_t container); -void LogDefineEventType(type_t type); +void LogDefineEventType(simgrid::instr::Type* type); #endif diff --git a/src/instr/instr_resource_utilization.cpp b/src/instr/instr_resource_utilization.cpp index 7606f22e5c..bca73a0973 100644 --- a/src/instr/instr_resource_utilization.cpp +++ b/src/instr/instr_resource_utilization.cpp @@ -28,17 +28,17 @@ static void __TRACE_surf_check_variable_set_to_zero(double now, const char *vari // check if key exists: if it doesn't, set the variable to zero and mark this in the dict if (platform_variables.find(key) == platform_variables.end()) { container_t container = PJ_container_get (resource); - type_t type = PJ_type_get (variable, container->type); - new SetVariableEvent (now, container, type, 0); + simgrid::instr::Type* type = PJ_type_get(variable, container->type_); + new simgrid::instr::SetVariableEvent(now, container, type, 0); platform_variables[key] = std::string(""); } } -static void instr_event (double now, double delta, type_t variable, container_t resource, double value) +static void instr_event(double now, double delta, simgrid::instr::Type* variable, container_t resource, double value) { - __TRACE_surf_check_variable_set_to_zero(now, variable->name, resource->name); - new AddVariableEvent(now, resource, variable, value); - new SubVariableEvent(now + delta, resource, variable, value); + __TRACE_surf_check_variable_set_to_zero(now, variable->name_, resource->name_); + new simgrid::instr::AddVariableEvent(now, resource, variable, value); + new simgrid::instr::SubVariableEvent(now + delta, resource, variable, value); } /* TRACE_surf_link_set_utilization: entry point from SimGrid */ @@ -54,7 +54,7 @@ void TRACE_surf_link_set_utilization(const char *resource, const char *category, if (TRACE_uncategorized()){ XBT_DEBUG("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now+delta, resource, value); container_t container = PJ_container_get (resource); - type_t type = PJ_type_get ("bandwidth_used", container->type); + simgrid::instr::Type* type = PJ_type_get("bandwidth_used", container->type_); instr_event (now, delta, type, container, value); } @@ -67,7 +67,7 @@ void TRACE_surf_link_set_utilization(const char *resource, const char *category, snprintf (category_type, INSTR_DEFAULT_STR_SIZE, "b%s", category); XBT_DEBUG("CAT LINK [%f - %f] %s %s %f", now, now+delta, resource, category_type, value); container_t container = PJ_container_get (resource); - type_t type = PJ_type_get (category_type, container->type); + simgrid::instr::Type* type = PJ_type_get(category_type, container->type_); instr_event (now, delta, type, container, value); } } @@ -83,7 +83,7 @@ void TRACE_surf_host_set_utilization(const char *resource, const char *category, //trace uncategorized host utilization if (TRACE_uncategorized()){ XBT_DEBUG("UNCAT HOST [%f - %f] %s power_used %f", now, now+delta, resource, value); - type_t type = PJ_type_get ("power_used", container->type); + simgrid::instr::Type* type = PJ_type_get("power_used", container->type_); instr_event (now, delta, type, container, value); } @@ -95,7 +95,7 @@ void TRACE_surf_host_set_utilization(const char *resource, const char *category, char category_type[INSTR_DEFAULT_STR_SIZE]; snprintf (category_type, INSTR_DEFAULT_STR_SIZE, "p%s", category); XBT_DEBUG("CAT HOST [%f - %f] %s %s %f", now, now+delta, resource, category_type, value); - type_t type = PJ_type_get (category_type, container->type); + simgrid::instr::Type* type = PJ_type_get(category_type, container->type_); instr_event (now, delta, type, container, value); } } diff --git a/src/kernel/routing/DijkstraZone.cpp b/src/kernel/routing/DijkstraZone.cpp index 8808698485..2d978c90bf 100644 --- a/src/kernel/routing/DijkstraZone.cpp +++ b/src/kernel/routing/DijkstraZone.cpp @@ -337,20 +337,23 @@ void DijkstraZone::addRoute(sg_platf_route_cbarg_t route) // Symmetrical YES if (route->symmetrical == true) { - if (not route->gw_dst && not route->gw_src) - XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dstName, srcName); - else - XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", dstName, route->gw_dst->name().c_str(), srcName, - route->gw_src->name().c_str()); xbt_dynar_t nodes = xbt_graph_get_nodes(routeGraph_); xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src->id(), xbt_node_t); xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst->id(), xbt_node_t); xbt_edge_t edge = xbt_graph_get_edge(routeGraph_, node_e_v, node_s_v); - if (edge) - THROWF(arg_error, 0, "Route from %s@%s to %s@%s already exists", dstName, route->gw_dst->name().c_str(), srcName, + if (not route->gw_dst || not route->gw_src){ + XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dstName, srcName); + if (edge) + THROWF(arg_error, 0, "Route from %s to %s already exists", dstName, srcName); + } else { + XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", dstName, route->gw_dst->name().c_str(), srcName, + route->gw_src->name().c_str()); + if (edge) + THROWF(arg_error, 0, "Route from %s@%s to %s@%s already exists", dstName, route->gw_dst->name().c_str(), srcName, route->gw_src->name().c_str()); + } if (route->gw_dst && route->gw_src) { NetPoint* gw_tmp = route->gw_src; diff --git a/src/kernel/routing/DragonflyZone.cpp b/src/kernel/routing/DragonflyZone.cpp index 2b76d0b7d1..e5f08466ce 100644 --- a/src/kernel/routing/DragonflyZone.cpp +++ b/src/kernel/routing/DragonflyZone.cpp @@ -161,7 +161,7 @@ void DragonflyZone::generateRouters() } } -void DragonflyZone::createLink(std::string id, int numlinks, surf::LinkImpl** linkup, surf::LinkImpl** linkdown) +void DragonflyZone::createLink(const std::string& id, int numlinks, surf::LinkImpl** linkup, surf::LinkImpl** linkdown) { *linkup = nullptr; *linkdown = nullptr; @@ -364,8 +364,6 @@ void DragonflyZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_c route->link_list->push_back(currentRouter->blackLinks_[targetCoords[1]]); if (latency) *latency += currentRouter->blackLinks_[targetCoords[1]]->latency(); - currentRouter = routers_[targetCoords[0] * (numChassisPerGroup_ * numBladesPerChassis_) + - targetCoords[1] * numBladesPerChassis_ + targetCoords[2]]; } } diff --git a/src/kernel/routing/DragonflyZone.hpp b/src/kernel/routing/DragonflyZone.hpp index ceeeda348f..6feea64578 100644 --- a/src/kernel/routing/DragonflyZone.hpp +++ b/src/kernel/routing/DragonflyZone.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2016. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2014-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -68,7 +68,7 @@ public: void seal() override; void generateRouters(); void generateLinks(); - void createLink(std::string id, int numlinks, surf::LinkImpl** linkup, surf::LinkImpl** linkdown); + void createLink(const std::string& id, int numlinks, surf::LinkImpl** linkup, surf::LinkImpl** linkdown); private: void rankId_to_coords(int rankId, unsigned int (*coords)[4]); diff --git a/src/kernel/routing/FloydZone.cpp b/src/kernel/routing/FloydZone.cpp index 7c5997237e..e680281214 100644 --- a/src/kernel/routing/FloydZone.cpp +++ b/src/kernel/routing/FloydZone.cpp @@ -140,7 +140,7 @@ void FloydZone::addRoute(sg_platf_route_cbarg_t route) route->gw_dst = gw_tmp; } - if (not route->gw_src && not route->gw_dst) + if (not route->gw_src || not route->gw_dst) XBT_DEBUG("Load Route from \"%s\" to \"%s\"", route->dst->name().c_str(), route->src->name().c_str()); else XBT_DEBUG("Load NetzoneRoute from \"%s(%s)\" to \"%s(%s)\"", route->dst->name().c_str(), route->gw_src->name().c_str(), diff --git a/src/kernel/routing/FullZone.cpp b/src/kernel/routing/FullZone.cpp index ece81d3e50..429f07908b 100644 --- a/src/kernel/routing/FullZone.cpp +++ b/src/kernel/routing/FullZone.cpp @@ -106,7 +106,7 @@ void FullZone::addRoute(sg_platf_route_cbarg_t route) route->gw_src = route->gw_dst; route->gw_dst = gw_tmp; } - if (route->gw_dst) // inter-zone route (to adapt the error message, if any) + if (route->gw_dst && route->gw_src) // inter-zone route (to adapt the error message, if any) xbt_assert( nullptr == TO_ROUTE_FULL(dst->id(), src->id()), "The route between %s@%s and %s@%s already exists. You should not declare the reverse path as symmetrical.", diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index fb5db13cdb..5c237168ca 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -179,7 +179,7 @@ void RoutedZone::addRouteCheckParams(sg_platf_route_cbarg_t route) const char* srcName = src->cname(); const char* dstName = dst->cname(); - if (not route->gw_dst && not route->gw_src) { + if (not route->gw_dst || not route->gw_src) { XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName); xbt_assert(src, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, srcName); xbt_assert(dst, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, dstName); diff --git a/src/kernel/routing/VivaldiZone.cpp b/src/kernel/routing/VivaldiZone.cpp index 77ff837c53..d1ea847b99 100644 --- a/src/kernel/routing/VivaldiZone.cpp +++ b/src/kernel/routing/VivaldiZone.cpp @@ -70,8 +70,8 @@ void VivaldiZone::setPeerLink(NetPoint* netpoint, double bw_in, double bw_out, s std::string link_up = "link_" + netpoint->name() + "_UP"; std::string link_down = "link_" + netpoint->name() + "_DOWN"; - surf::LinkImpl* linkUp = surf_network_model->createLink(link_up.c_str(), bw_out, 0, SURF_LINK_SHARED); - surf::LinkImpl* linkDown = surf_network_model->createLink(link_down.c_str(), bw_in, 0, SURF_LINK_SHARED); + surf::LinkImpl* linkUp = surf_network_model->createLink(link_up, bw_out, 0, SURF_LINK_SHARED); + surf::LinkImpl* linkDown = surf_network_model->createLink(link_down, bw_in, 0, SURF_LINK_SHARED); privateLinks_.insert({netpoint->id(), {linkUp, linkDown}}); } diff --git a/src/mc/mc_unw.cpp b/src/mc/mc_unw.cpp index ebe8c8ec89..7566b5a809 100644 --- a/src/mc/mc_unw.cpp +++ b/src/mc/mc_unw.cpp @@ -259,7 +259,7 @@ void UnwindContext::initialize(simgrid::mc::RemoteClient* process, unw_context_t # endif #else // Do we need to do any fixup like this? - #error Target CPU type is not handled. +# error Target CPU type is not handled. #endif } diff --git a/src/mc/mc_unw_vmread.cpp b/src/mc/mc_unw_vmread.cpp index f9115be55e..48d822c2e2 100644 --- a/src/mc/mc_unw_vmread.cpp +++ b/src/mc/mc_unw_vmread.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2015. The SimGrid Team. +/* Copyright (c) 2015-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ struct _UPT_info { static inline pid_t _UPT_getpid(void* arg) { - struct _UPT_info* info = (_UPT_info*) arg; + struct _UPT_info* info = static_cast<_UPT_info*>(arg); return info->pid; } diff --git a/src/msg/instr_msg_process.cpp b/src/msg/instr_msg_process.cpp index 3ce2884820..af391fb2d6 100644 --- a/src/msg/instr_msg_process.cpp +++ b/src/msg/instr_msg_process.cpp @@ -37,8 +37,8 @@ void TRACE_msg_process_change_host(msg_process_t process, msg_host_t new_host) //start link container_t msg = PJ_container_get (instr_process_id(process, str, len)); - type_t type = PJ_type_get ("MSG_PROCESS_LINK", PJ_type_get_root()); - new StartLinkEvent (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key); + simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_LINK", PJ_type_get_root()); + new simgrid::instr::StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key); //destroy existing container of this process TRACE_msg_process_destroy (MSG_process_get_name (process), MSG_process_get_PID (process)); @@ -49,7 +49,7 @@ void TRACE_msg_process_change_host(msg_process_t process, msg_host_t new_host) //end link msg = PJ_container_get(instr_process_id(process, str, len)); type = PJ_type_get ("MSG_PROCESS_LINK", PJ_type_get_root()); - new EndLinkEvent (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key); + new simgrid::instr::EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key); } } @@ -60,7 +60,8 @@ void TRACE_msg_process_create (const char *process_name, int process_pid, msg_ho char str[INSTR_DEFAULT_STR_SIZE]; container_t host_container = PJ_container_get(host->getCname()); - PJ_container_new(instr_process_id_2(process_name, process_pid, str, len), INSTR_MSG_PROCESS, host_container); + new simgrid::instr::Container(instr_process_id_2(process_name, process_pid, str, len), + simgrid::instr::INSTR_MSG_PROCESS, host_container); } } @@ -73,7 +74,7 @@ void TRACE_msg_process_destroy (const char *process_name, int process_pid) container_t process = PJ_container_get_or_null(instr_process_id_2(process_name, process_pid, str, len)); if (process) { PJ_container_remove_from_parent (process); - PJ_container_free (process); + delete process; } } } @@ -93,9 +94,9 @@ void TRACE_msg_process_suspend(msg_process_t process) char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(process, str, len)); - type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - value* val = value::get("suspend", type); - new PushStateEvent(MSG_get_clock(), process_container, type, val); + simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_); + simgrid::instr::Value* val = simgrid::instr::Value::get("suspend", type); + new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val); } } @@ -106,8 +107,8 @@ void TRACE_msg_process_resume(msg_process_t process) char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(process, str, len)); - type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - new PopStateEvent (MSG_get_clock(), process_container, type); + simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_); + new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type); } } @@ -118,9 +119,9 @@ void TRACE_msg_process_sleep_in(msg_process_t process) char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(process, str, len)); - type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - value* val = value::get("sleep", type); - new PushStateEvent(MSG_get_clock(), process_container, type, val); + simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_); + simgrid::instr::Value* val = simgrid::instr::Value::get("sleep", type); + new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val); } } @@ -131,7 +132,7 @@ void TRACE_msg_process_sleep_out(msg_process_t process) char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(process, str, len)); - type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - new PopStateEvent (MSG_get_clock(), process_container, type); + simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_); + new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type); } } diff --git a/src/msg/instr_msg_task.cpp b/src/msg/instr_msg_task.cpp index 1ac51f1190..8b35b94e3d 100644 --- a/src/msg/instr_msg_task.cpp +++ b/src/msg/instr_msg_task.cpp @@ -53,9 +53,9 @@ void TRACE_msg_task_execute_start(msg_task_t task) char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); - type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - value* val = value::get("task_execute", type); - new PushStateEvent(MSG_get_clock(), process_container, type, val); + simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_); + simgrid::instr::Value* val = simgrid::instr::Value::get("task_execute", type); + new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val); } } @@ -68,8 +68,8 @@ void TRACE_msg_task_execute_end(msg_task_t task) char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); - type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - new PopStateEvent (MSG_get_clock(), process_container, type); + simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_); + new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type); } } @@ -93,9 +93,9 @@ void TRACE_msg_task_get_start() char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); - type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - value* val = value::get("receive", type); - new PushStateEvent(MSG_get_clock(), process_container, type, val); + simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_); + simgrid::instr::Value* val = simgrid::instr::Value::get("receive", type); + new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val); } } @@ -108,13 +108,13 @@ void TRACE_msg_task_get_end(double start_time, msg_task_t task) char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); - type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - new PopStateEvent (MSG_get_clock(), process_container, type); + simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_); + new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type); char key[INSTR_DEFAULT_STR_SIZE]; snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter); type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root()); - new EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key); + new simgrid::instr::EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key); } } @@ -128,14 +128,14 @@ int TRACE_msg_task_put_start(msg_task_t task) char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); - type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - value* val = value::get("send", type); - new PushStateEvent(MSG_get_clock(), process_container, type, val); + simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_); + simgrid::instr::Value* val = simgrid::instr::Value::get("send", type); + new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val); char key[INSTR_DEFAULT_STR_SIZE]; snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter); type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root()); - new StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key); + new simgrid::instr::StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key); } return 1; @@ -150,7 +150,7 @@ void TRACE_msg_task_put_end() char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); - type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - new PopStateEvent (MSG_get_clock(), process_container, type); + simgrid::instr::Type* type = PJ_type_get("MSG_PROCESS_STATE", process_container->type_); + new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type); } } diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index 8e46105ce7..be46babecb 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -173,7 +173,7 @@ void MSG_vm_destroy(msg_vm_t vm) if (TRACE_msg_vm_is_enabled()) { container_t container = PJ_container_get(vm->getCname()); PJ_container_remove_from_parent(container); - PJ_container_free(container); + delete container; } } @@ -187,9 +187,9 @@ void MSG_vm_start(msg_vm_t vm) vm->start(); if (TRACE_msg_vm_is_enabled()) { container_t vm_container = PJ_container_get(vm->getCname()); - type_t type = PJ_type_get("MSG_VM_STATE", vm_container->type); - value* val = value::get_or_new("start", "0 0 1", type); // start is blue - new PushStateEvent(MSG_get_clock(), vm_container, type, val); + simgrid::instr::Type* type = PJ_type_get("MSG_VM_STATE", vm_container->type_); + simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("start", "0 0 1", type); // start is blue + new simgrid::instr::PushStateEvent(MSG_get_clock(), vm_container, type, val); } } @@ -296,21 +296,22 @@ static int migration_rx_fun(int argc, char *argv[]) // start link container_t msg = PJ_container_get(vm->getCname()); - type_t type = PJ_type_get("MSG_VM_LINK", PJ_type_get_root()); - new StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key); + simgrid::instr::Type* type = PJ_type_get("MSG_VM_LINK", PJ_type_get_root()); + new simgrid::instr::StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key); // destroy existing container of this vm container_t existing_container = PJ_container_get(vm->getCname()); PJ_container_remove_from_parent(existing_container); - PJ_container_free(existing_container); + delete existing_container; // create new container on the new_host location - PJ_container_new(vm->getCname(), INSTR_MSG_VM, PJ_container_get(ms->dst_pm->getCname())); + new simgrid::instr::Container(vm->getCname(), simgrid::instr::INSTR_MSG_VM, + PJ_container_get(ms->dst_pm->getCname())); // end link msg = PJ_container_get(vm->getCname()); type = PJ_type_get("MSG_VM_LINK", PJ_type_get_root()); - new EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key); + new simgrid::instr::EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key); } // Inform the SRC that the migration has been correctly performed @@ -774,9 +775,9 @@ void MSG_vm_suspend(msg_vm_t vm) if (TRACE_msg_vm_is_enabled()) { container_t vm_container = PJ_container_get(vm->getCname()); - type_t type = PJ_type_get("MSG_VM_STATE", vm_container->type); - value* val = value::get_or_new("suspend", "1 0 0", type); // suspend is red - new PushStateEvent(MSG_get_clock(), vm_container, type, val); + simgrid::instr::Type* type = PJ_type_get("MSG_VM_STATE", vm_container->type_); + simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("suspend", "1 0 0", type); // suspend is red + new simgrid::instr::PushStateEvent(MSG_get_clock(), vm_container, type, val); } } @@ -791,8 +792,8 @@ void MSG_vm_resume(msg_vm_t vm) if (TRACE_msg_vm_is_enabled()) { container_t vm_container = PJ_container_get(vm->getCname()); - type_t type = PJ_type_get("MSG_VM_STATE", vm_container->type); - new PopStateEvent(MSG_get_clock(), vm_container, type); + simgrid::instr::Type* type = PJ_type_get("MSG_VM_STATE", vm_container->type_); + new simgrid::instr::PopStateEvent(MSG_get_clock(), vm_container, type); } } diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index 7915262a08..14c29fec3d 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -33,7 +33,7 @@ VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm, int coreAmount) if (TRACE_msg_vm_is_enabled()) { container_t host_container = PJ_container_get(pm->getCname()); - PJ_container_new(name, INSTR_MSG_VM, host_container); + new simgrid::instr::Container(name, simgrid::instr::INSTR_MSG_VM, host_container); } } diff --git a/src/simdag/sd_daxloader.cpp b/src/simdag/sd_daxloader.cpp index 110716bb2c..ac5d691fcc 100644 --- a/src/simdag/sd_daxloader.cpp +++ b/src/simdag/sd_daxloader.cpp @@ -15,11 +15,11 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_daxparse, sd, "Parsing DAX files"); extern "C" { - #undef CLEANUP - #include "dax_dtd.h" - #define register /* g++ don't like register, so don't say it */ - #include "dax_dtd.c" - #undef register +# undef CLEANUP +# include "dax_dtd.h" +# define register /* g++ don't like register, so don't say it */ +# include "dax_dtd.c" +# undef register } /* Ensure that transfer tasks have unique names even though a file is used several times */ diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 1babc159c4..dd8daa8d6f 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -54,11 +54,13 @@ std::unique_ptr simix_global; static xbt_heap_t simix_timers = nullptr; /** @brief Timer datatype */ -typedef struct s_smx_timer { +typedef class s_smx_timer { double date = 0.0; - simgrid::xbt::Task callback; + s_smx_timer() = default; - s_smx_timer()=default; +public: + simgrid::xbt::Task callback; + double getDate() { return date; } s_smx_timer(double date, simgrid::xbt::Task callback) : date(date), callback(std::move(callback)) {} } s_smx_timer_t; @@ -573,12 +575,12 @@ smx_timer_t SIMIX_timer_set(double date, simgrid::xbt::Task callback) /** @brief cancels a timer that was added earlier */ void SIMIX_timer_remove(smx_timer_t timer) { - xbt_heap_rm_elm(simix_timers, timer, timer->date); + xbt_heap_rm_elm(simix_timers, timer, timer->getDate()); } /** @brief Returns the date at which the timer will trigger (or 0 if nullptr timer) */ double SIMIX_timer_get_date(smx_timer_t timer) { - return timer?timer->date:0; + return timer ? timer->getDate() : 0; } /** diff --git a/src/smpi/bindings/smpi_pmpi_group.cpp b/src/smpi/bindings/smpi_pmpi_group.cpp index 8adeecc422..587c11bfd0 100644 --- a/src/smpi/bindings/smpi_pmpi_group.cpp +++ b/src/smpi/bindings/smpi_pmpi_group.cpp @@ -136,9 +136,8 @@ int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup) } else { if (n == 0) { *newgroup = group; - if (group != MPI_COMM_WORLD->group() - && group != MPI_COMM_SELF->group() && group != MPI_GROUP_EMPTY) - group->ref(); + if (group != MPI_COMM_WORLD->group() && group != MPI_COMM_SELF->group() && group != MPI_GROUP_EMPTY) + group->ref(); return MPI_SUCCESS; } else if (n == group->size()) { *newgroup = MPI_GROUP_EMPTY; diff --git a/src/smpi/bindings/smpi_pmpi_request.cpp b/src/smpi/bindings/smpi_pmpi_request.cpp index 926b55c349..39683f8459 100644 --- a/src/smpi/bindings/smpi_pmpi_request.cpp +++ b/src/smpi/bindings/smpi_pmpi_request.cpp @@ -613,8 +613,7 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status) } else if (*request == MPI_REQUEST_NULL) { retval = MPI_SUCCESS; } else { - - int rank = (request!=nullptr && (*request)->comm() != MPI_COMM_NULL) ? smpi_process()->index() : -1; + int rank = (*request)->comm() != MPI_COMM_NULL ? smpi_process()->index() : -1; int src_traced = (*request)->src(); int dst_traced = (*request)->dst(); @@ -646,6 +645,9 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta if (index == nullptr) return MPI_ERR_ARG; + if (count <= 0) + return MPI_SUCCESS; + smpi_bench_end(); //save requests information for tracing typedef struct { @@ -655,10 +657,8 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta int tag; MPI_Comm comm; } savedvalstype; - savedvalstype* savedvals=nullptr; - if(count>0){ - savedvals = xbt_new0(savedvalstype, count); - } + savedvalstype* savedvals = xbt_new0(savedvalstype, count); + for (int i = 0; i < count; i++) { MPI_Request req = requests[i]; //already received requests are no longer valid if (req) { diff --git a/src/smpi/bindings/smpi_pmpi_win.cpp b/src/smpi/bindings/smpi_pmpi_win.cpp index 983ed259e2..03b8438e66 100644 --- a/src/smpi/bindings/smpi_pmpi_win.cpp +++ b/src/smpi/bindings/smpi_pmpi_win.cpp @@ -190,7 +190,8 @@ int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, } else if ((origin_count < 0 || target_count < 0) || (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) { + } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) || + ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else { int rank = smpi_process()->index(); @@ -224,7 +225,8 @@ int PMPI_Rget( void *origin_addr, int origin_count, MPI_Datatype origin_datatype } else if ((origin_count < 0 || target_count < 0) || (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) { + } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) || + ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else if(request == nullptr){ retval = MPI_ERR_REQUEST; @@ -259,7 +261,8 @@ int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, } else if ((origin_count < 0 || target_count < 0) || (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) { + } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) || + ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else { int rank = smpi_process()->index(); @@ -295,7 +298,8 @@ int PMPI_Rput( void *origin_addr, int origin_count, MPI_Datatype origin_datatype } else if ((origin_count < 0 || target_count < 0) || (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) { + } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) || + ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else if(request == nullptr){ retval = MPI_ERR_REQUEST; @@ -332,7 +336,8 @@ int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da } else if ((origin_count < 0 || target_count < 0) || (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) { + } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) || + ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else if (op == MPI_OP_NULL) { retval = MPI_ERR_OP; @@ -367,7 +372,8 @@ int PMPI_Raccumulate( void *origin_addr, int origin_count, MPI_Datatype origin_d } else if ((origin_count < 0 || target_count < 0) || (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((not origin_datatype->is_valid()) || (not target_datatype->is_valid())) { + } else if (((origin_datatype == MPI_DATATYPE_NULL) || (target_datatype == MPI_DATATYPE_NULL)) || + ((not origin_datatype->is_valid()) || (not target_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else if (op == MPI_OP_NULL) { retval = MPI_ERR_OP; @@ -406,8 +412,8 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){ (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) || (result_addr==nullptr && result_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((origin_datatype != MPI_DATATYPE_NULL && not origin_datatype->is_valid()) || - (not target_datatype->is_valid()) || (not result_datatype->is_valid())) { + } else if (((target_datatype == MPI_DATATYPE_NULL) || (result_datatype == MPI_DATATYPE_NULL)) || + (((origin_datatype != MPI_DATATYPE_NULL) && (not origin_datatype->is_valid())) || (not target_datatype->is_valid()) || (not result_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else if (op == MPI_OP_NULL) { retval = MPI_ERR_OP; @@ -447,8 +453,8 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){ (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) || (result_addr==nullptr && result_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((origin_datatype != MPI_DATATYPE_NULL && not origin_datatype->is_valid()) || - (not target_datatype->is_valid()) || (not result_datatype->is_valid())) { + } else if (((target_datatype == MPI_DATATYPE_NULL) || (result_datatype == MPI_DATATYPE_NULL)) || + (((origin_datatype != MPI_DATATYPE_NULL) && (not origin_datatype->is_valid())) || (not target_datatype->is_valid()) || (not result_datatype->is_valid()))) { retval = MPI_ERR_TYPE; } else if (op == MPI_OP_NULL) { retval = MPI_ERR_OP; @@ -490,7 +496,7 @@ int PMPI_Compare_and_swap(void *origin_addr, void *compare_addr, retval = MPI_ERR_ARG; } else if (origin_addr==nullptr || result_addr==nullptr || compare_addr==nullptr){ retval = MPI_ERR_COUNT; - } else if (not datatype->is_valid()) { + } else if ((datatype == MPI_DATATYPE_NULL) || (not datatype->is_valid())) { retval = MPI_ERR_TYPE; } else { int rank = smpi_process()->index(); diff --git a/src/smpi/colls/coll_tuned_topo.cpp b/src/smpi/colls/coll_tuned_topo.cpp index aa797a9884..db88a997bb 100644 --- a/src/smpi/colls/coll_tuned_topo.cpp +++ b/src/smpi/colls/coll_tuned_topo.cpp @@ -52,7 +52,10 @@ static int calculate_num_nodes_up_to_level( int fanout, int level ) { /* just use geometric progression formula for sum: a^0+a^1+...a^(n-1) = (a^n-1)/(a-1) */ - return ((pown(fanout,level) - 1)/(fanout - 1)); + if(fanout > 1) + return ((pown(fanout,level) - 1)/(fanout - 1)); + else + return 0; // is this right ? } /* diff --git a/src/smpi/colls/smpi_automatic_selector.cpp b/src/smpi/colls/smpi_automatic_selector.cpp index 3ffffa0278..df6832b729 100644 --- a/src/smpi/colls/smpi_automatic_selector.cpp +++ b/src/smpi/colls/smpi_automatic_selector.cpp @@ -16,14 +16,15 @@ #define TRACE_AUTO_COLL(cat) \ if (TRACE_is_enabled()) { \ - type_t type = PJ_type_get_or_null(#cat, PJ_type_get_root()); \ + simgrid::instr::Type* type = simgrid::instr::Type::getOrNull(#cat, PJ_type_get_root()); \ if (not type) { \ - type = PJ_type_event_new(#cat, PJ_type_get_root()); \ + type = simgrid::instr::Type::eventNew(#cat, PJ_type_get_root()); \ } \ char cont_name[25]; \ snprintf(cont_name, 25, "rank-%d", smpi_process()->index()); \ - value* val = value::get_or_new(Colls::mpi_coll_##cat##_description[i].name, "1.0 1.0 1.0", type); \ - new NewEvent(SIMIX_get_clock(), PJ_container_get(cont_name), type, val); \ + simgrid::instr::Value* val = \ + simgrid::instr::Value::get_or_new(Colls::mpi_coll_##cat##_description[i].name, "1.0 1.0 1.0", type); \ + new simgrid::instr::NewEvent(SIMIX_get_clock(), PJ_container_get(cont_name), type, val); \ } #define AUTOMATIC_COLL_BENCH(cat, ret, args, args2) \ diff --git a/src/smpi/colls/smpi_default_selector.cpp b/src/smpi/colls/smpi_default_selector.cpp index d3736cc81b..f218a4efcb 100644 --- a/src/smpi/colls/smpi_default_selector.cpp +++ b/src/smpi/colls/smpi_default_selector.cpp @@ -213,6 +213,8 @@ int Coll_reduce_default::reduce(void *sendbuf, void *recvbuf, int count, MPI_Dat int rank = comm->rank(); int size = comm->size(); + if(size==0) + return MPI_ERR_COMM; //non commutative case, use a working algo from openmpi if (op != MPI_OP_NULL && not op->is_commutative()) { return Coll_reduce_ompi_basic_linear::reduce(sendtmpbuf, recvbuf, count, datatype, op, root, comm); diff --git a/src/smpi/colls/smpi_mvapich2_selector.cpp b/src/smpi/colls/smpi_mvapich2_selector.cpp index 837584f694..1d6978c3a1 100644 --- a/src/smpi/colls/smpi_mvapich2_selector.cpp +++ b/src/smpi/colls/smpi_mvapich2_selector.cpp @@ -64,7 +64,7 @@ int Coll_alltoall_mvapich2::alltoall( void *sendbuf, int sendcount, ||nbytes > mv2_alltoall_thresholds_table[conf_index][range].in_place_algo_table[range_threshold].max ) { tmp_buf = (char *)smpi_get_tmp_sendbuffer( comm_size * recvcount * recvtype_size ); - mpi_errno = Datatype::copy((char *)recvbuf, + Datatype::copy((char *)recvbuf, comm_size*recvcount, recvtype, (char *)tmp_buf, comm_size*recvcount, recvtype); @@ -622,11 +622,9 @@ int Coll_bcast_mvapich2::bcast(void *buffer, { shmem_comm = comm->get_intra_comm(); if (not is_contig || not is_homogeneous) { - mpi_errno = MPIR_Bcast_tune_inter_node_helper_MV2(tmp_buf, nbytes, MPI_BYTE, root, comm); + MPIR_Bcast_tune_inter_node_helper_MV2(tmp_buf, nbytes, MPI_BYTE, root, comm); } else { - mpi_errno = - MPIR_Bcast_tune_inter_node_helper_MV2(buffer, count, datatype, root, - comm); + MPIR_Bcast_tune_inter_node_helper_MV2(buffer, count, datatype, root, comm); } /* We are now done with the inter-node phase */ @@ -847,7 +845,7 @@ int Coll_reduce_scatter_mvapich2::reduce_scatter(void *sendbuf, void *recvbuf, i while (pof2 < comm_size) pof2 <<= 1; if (pof2 == comm_size && is_block_regular) { /* noncommutative, pof2 size, and block regular */ - mpi_errno = MPIR_Reduce_scatter_non_comm_MV2(sendbuf, recvbuf, + MPIR_Reduce_scatter_non_comm_MV2(sendbuf, recvbuf, recvcnts, datatype, op, comm); } diff --git a/src/smpi/include/smpi_info.hpp b/src/smpi/include/smpi_info.hpp index 2812182e34..61eccb2272 100644 --- a/src/smpi/include/smpi_info.hpp +++ b/src/smpi/include/smpi_info.hpp @@ -10,14 +10,14 @@ #include "smpi/smpi.h" #include "smpi_f2c.hpp" #include -#include +#include namespace simgrid{ namespace smpi{ class Info : public F2C{ private: - std::unordered_map map_; + std::map map_; int refcount_ = 1; public: diff --git a/src/smpi/internals/instr_smpi.cpp b/src/smpi/internals/instr_smpi.cpp index 579f03eba6..288a8e3267 100644 --- a/src/smpi/internals/instr_smpi.cpp +++ b/src/smpi/internals/instr_smpi.cpp @@ -199,7 +199,7 @@ void TRACE_smpi_init(int rank) #if HAVE_PAPI container_t container = #endif - PJ_container_new(str, INSTR_SMPI, father); + new simgrid::instr::Container(str, simgrid::instr::INSTR_SMPI, father); #if HAVE_PAPI papi_counter_t counters = smpi_process()->papi_counters(); @@ -208,8 +208,8 @@ void TRACE_smpi_init(int rank) * Check whether this variable already exists or not. Otherwise, it will be created * multiple times but only the last one would be used... */ - if (PJ_type_get_or_null(it.first.c_str(), container->type) == nullptr) { - PJ_type_variable_new(it.first.c_str(), nullptr, container->type); + if (s_type::getOrNull(it.first.c_str(), container->type_) == nullptr) { + Type::variableNew(it.first.c_str(), nullptr, container->type_); } } #endif @@ -223,7 +223,7 @@ void TRACE_smpi_finalize(int rank) char str[INSTR_DEFAULT_STR_SIZE]; container_t container = PJ_container_get(smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE)); PJ_container_remove_from_parent (container); - PJ_container_free (container); + delete container; } void TRACE_smpi_collective_in(int rank, const char *operation, instr_extra_data extra) @@ -236,10 +236,10 @@ void TRACE_smpi_collective_in(int rank, const char *operation, instr_extra_data char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_STATE", container->type); + simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_); const char *color = instr_find_color (operation); - value* val = value::get_or_new(operation, color, type); - new PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast(extra)); + simgrid::instr::Value* val = simgrid::instr::Value::get_or_new(operation, color, type); + new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast(extra)); } void TRACE_smpi_collective_out(int rank, const char *operation) @@ -250,9 +250,9 @@ void TRACE_smpi_collective_out(int rank, const char *operation) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_STATE", container->type); + simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_); - new PopStateEvent (SIMIX_get_clock(), container, type); + new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type); } void TRACE_smpi_computing_init(int rank) @@ -264,9 +264,10 @@ void TRACE_smpi_computing_init(int rank) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get(str); - type_t type = PJ_type_get("MPI_STATE", container->type); + simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_); const char* color = instr_find_color("computing"); - new PushStateEvent(SIMIX_get_clock(), container, type, value::get_or_new("computing", color, type)); + new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, + simgrid::instr::Value::get_or_new("computing", color, type)); } void TRACE_smpi_computing_in(int rank, instr_extra_data extra) @@ -280,9 +281,9 @@ void TRACE_smpi_computing_in(int rank, instr_extra_data extra) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_STATE", container->type); - value* val = value::get_or_new("computing", nullptr, type); - new PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast(extra)); + simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_); + simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("computing", nullptr, type); + new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast(extra)); } void TRACE_smpi_computing_out(int rank) @@ -292,8 +293,8 @@ void TRACE_smpi_computing_out(int rank) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_STATE", container->type); - new PopStateEvent (SIMIX_get_clock(), container, type); + simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_); + new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type); } void TRACE_smpi_sleeping_init(int rank) @@ -305,10 +306,10 @@ void TRACE_smpi_sleeping_init(int rank) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_STATE", container->type); + simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_); const char *color = instr_find_color ("sleeping"); - value* val = value::get_or_new("sleeping", color, type); - new PushStateEvent(SIMIX_get_clock(), container, type, val); + simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("sleeping", color, type); + new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val); } void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra) @@ -322,9 +323,9 @@ void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_STATE", container->type); - value* val = value::get_or_new("sleeping", nullptr, type); - new PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast(extra)); + simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_); + simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("sleeping", nullptr, type); + new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast(extra)); } void TRACE_smpi_sleeping_out(int rank) @@ -334,8 +335,8 @@ void TRACE_smpi_sleeping_out(int rank) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_STATE", container->type); - new PopStateEvent (SIMIX_get_clock(), container, type); + simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_); + new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type); } void TRACE_smpi_testing_in(int rank, instr_extra_data extra) @@ -349,9 +350,9 @@ void TRACE_smpi_testing_in(int rank, instr_extra_data extra) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_STATE", container->type); - value* val = value::get_or_new("test", nullptr, type); - new PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast(extra)); + simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_); + simgrid::instr::Value* val = simgrid::instr::Value::get_or_new("test", nullptr, type); + new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast(extra)); } void TRACE_smpi_testing_out(int rank) @@ -361,8 +362,8 @@ void TRACE_smpi_testing_out(int rank) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_STATE", container->type); - new PopStateEvent (SIMIX_get_clock(), container, type); + simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_); + new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type); } void TRACE_smpi_ptp_in(int rank, const char *operation, instr_extra_data extra) @@ -375,10 +376,10 @@ void TRACE_smpi_ptp_in(int rank, const char *operation, instr_extra_data extra) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_STATE", container->type); + simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_); const char *color = instr_find_color (operation); - value* val = value::get_or_new(operation, color, type); - new PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast(extra)); + simgrid::instr::Value* val = simgrid::instr::Value::get_or_new(operation, color, type); + new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, type, val, static_cast(extra)); } void TRACE_smpi_ptp_out(int rank, int dst, const char *operation) @@ -389,9 +390,9 @@ void TRACE_smpi_ptp_out(int rank, int dst, const char *operation) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_STATE", container->type); + simgrid::instr::Type* type = PJ_type_get("MPI_STATE", container->type_); - new PopStateEvent (SIMIX_get_clock(), container, type); + new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type); } void TRACE_smpi_send(int rank, int src, int dst, int tag, int size) @@ -405,9 +406,9 @@ void TRACE_smpi_send(int rank, int src, int dst, int tag, int size) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(src, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_LINK", PJ_type_get_root()); + simgrid::instr::Type* type = PJ_type_get("MPI_LINK", PJ_type_get_root()); XBT_DEBUG("Send tracing from %d to %d, tag %d, with key %s", src, dst, tag, key); - new StartLinkEvent (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key, size); + new simgrid::instr::StartLinkEvent(SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key, size); } void TRACE_smpi_recv(int src, int dst, int tag) @@ -421,7 +422,7 @@ void TRACE_smpi_recv(int src, int dst, int tag) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(dst, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("MPI_LINK", PJ_type_get_root()); + simgrid::instr::Type* type = PJ_type_get("MPI_LINK", PJ_type_get_root()); XBT_DEBUG("Recv tracing from %d to %d, tag %d, with key %s", src, dst, tag, key); - new EndLinkEvent (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key); + new simgrid::instr::EndLinkEvent(SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key); } diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index aa46baa987..1ccc8bfbae 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -605,10 +605,11 @@ int smpi_main(const char* executable, int argc, char *argv[]) // Load the copy and resolve the entry point: void* handle = dlopen(target_executable.c_str(), RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND); + int saved_errno = errno; if (xbt_cfg_get_boolean("smpi/keep-temps") == false) unlink(target_executable.c_str()); if (handle == nullptr) - xbt_die("dlopen failed: %s (errno: %d -- %s)", dlerror(), errno, strerror(errno)); + xbt_die("dlopen failed: %s (errno: %d -- %s)", dlerror(), saved_errno, strerror(saved_errno)); smpi_entry_point_type entry_point = smpi_resolve_function(handle); if (not entry_point) xbt_die("Could not resolve entry point"); diff --git a/src/smpi/internals/smpi_memory.cpp b/src/smpi/internals/smpi_memory.cpp index 4fce186361..d816b3c653 100644 --- a/src/smpi/internals/smpi_memory.cpp +++ b/src/smpi/internals/smpi_memory.cpp @@ -108,8 +108,8 @@ void smpi_really_switch_data_segment(int dest) int smpi_is_privatization_file(char* file) { - const std::string buffer_path {"/dev/shm/my-buffer-"}; - return buffer_path.compare(file) == 0; + const std::string buffer_path("/dev/shm/my-buffer-"); + return buffer_path.compare(0, std::string::npos, file, buffer_path.length()) == 0; } void smpi_initialize_global_memory_segments() diff --git a/src/smpi/mpi/smpi_group.cpp b/src/smpi/mpi/smpi_group.cpp index 580d0d688e..a3b3446dc4 100644 --- a/src/smpi/mpi/smpi_group.cpp +++ b/src/smpi/mpi/smpi_group.cpp @@ -127,10 +127,8 @@ int Group::incl(int n, int* ranks, MPI_Group* newgroup) *newgroup = MPI_GROUP_EMPTY; } else if (n == size_) { *newgroup = this; - if(this!= MPI_COMM_WORLD->group() - && this != MPI_COMM_SELF->group() - && this != MPI_GROUP_EMPTY) - this->ref(); + if (this != MPI_COMM_WORLD->group() && this != MPI_COMM_SELF->group() && this != MPI_GROUP_EMPTY) + this->ref(); } else { *newgroup = new Group(n); for (i = 0; i < n; i++) { diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index 4f57f6d864..b0c0af6c50 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -508,8 +508,8 @@ int Request::test(MPI_Request * request, MPI_Status * status) { if (flag) { finish_wait(request,status); nsleeps=1;//reset the number of sleeps we will do next time - if (*request != MPI_REQUEST_NULL && ((*request)->flags_ & PERSISTENT)==0) - *request = MPI_REQUEST_NULL; + if (*request != MPI_REQUEST_NULL && ((*request)->flags_ & PERSISTENT) == 0) + *request = MPI_REQUEST_NULL; } else if (xbt_cfg_get_boolean("smpi/grow-injected-times")){ nsleeps++; } @@ -885,7 +885,7 @@ int Request::waitsome(int incount, MPI_Request requests[], int *indices, MPI_Sta status[index] = *pstat; } if (requests[index] != MPI_REQUEST_NULL && (requests[index]->flags_ & NON_PERSISTENT)) - requests[index]=MPI_REQUEST_NULL; + requests[index] = MPI_REQUEST_NULL; }else{ return MPI_UNDEFINED; } diff --git a/src/smpi/mpi/smpi_win.cpp b/src/smpi/mpi/smpi_win.cpp index f9761085cf..02c7765ea1 100644 --- a/src/smpi/mpi/smpi_win.cpp +++ b/src/smpi/mpi/smpi_win.cpp @@ -413,7 +413,7 @@ int Win::compare_and_swap(void *origin_addr, void *compare_addr, } XBT_DEBUG("Entering MPI_Compare_and_swap with %d", target_rank); - MPI_Request req; + MPI_Request req = MPI_REQUEST_NULL; xbt_mutex_acquire(send_win->atomic_mut_); get(result_addr, 1, datatype, target_rank, target_disp, 1, datatype, &req); diff --git a/src/smpi/smpirun.in b/src/smpi/smpirun.in index 750e28f0a0..3229f71cb8 100755 --- a/src/smpi/smpirun.in +++ b/src/smpi/smpirun.in @@ -25,7 +25,7 @@ SPEED="${DEFAULT_SPEED}" PRIVATIZE="--cfg=smpi/privatization:@HAVE_PRIVATIZATION@" -SIMOPTS="--cfg=surf/precision:1e-9 --cfg=network/model:SMPI --cfg=network/TCP-gamma:4194304" +SIMOPTS="--cfg=surf/precision:1e-9 --cfg=network/model:SMPI" #usage to print the way this script should be called usage () { diff --git a/src/surf/instr_routing.cpp b/src/surf/instr_routing.cpp index 7996735e02..1106ad91da 100644 --- a/src/surf/instr_routing.cpp +++ b/src/surf/instr_routing.cpp @@ -28,23 +28,23 @@ static const char *instr_node_name (xbt_node_t node) static container_t lowestCommonAncestor (container_t a1, container_t a2) { //this is only an optimization (since most of a1 and a2 share the same parent) - if (a1->father == a2->father) - return a1->father; + if (a1->father_ == a2->father_) + return a1->father_; //create an array with all ancestors of a1 std::vector ancestors_a1; - container_t p = a1->father; + container_t p = a1->father_; while (p){ ancestors_a1.push_back(p); - p = p->father; + p = p->father_; } //create an array with all ancestors of a2 std::vector ancestors_a2; - p = a2->father; + p = a2->father_; while (p){ ancestors_a2.push_back(p); - p = p->father; + p = p->father_; } //find the lowest ancestor @@ -68,7 +68,7 @@ static container_t lowestCommonAncestor (container_t a1, container_t a2) static void linkContainers (container_t src, container_t dst, xbt_dict_t filter) { //ignore loopback - if (strcmp (src->name, "__loopback__") == 0 || strcmp (dst->name, "__loopback__") == 0){ + if (strcmp(src->name_, "__loopback__") == 0 || strcmp(dst->name_, "__loopback__") == 0) { XBT_DEBUG (" linkContainers: ignoring loopback link"); return; } @@ -83,14 +83,14 @@ static void linkContainers (container_t src, container_t dst, xbt_dict_t filter) //check if we already register this pair (we only need one direction) char aux1[INSTR_DEFAULT_STR_SIZE]; char aux2[INSTR_DEFAULT_STR_SIZE]; - snprintf (aux1, INSTR_DEFAULT_STR_SIZE, "%s%s", src->name, dst->name); - snprintf (aux2, INSTR_DEFAULT_STR_SIZE, "%s%s", dst->name, src->name); + snprintf(aux1, INSTR_DEFAULT_STR_SIZE, "%s%s", src->name_, dst->name_); + snprintf(aux2, INSTR_DEFAULT_STR_SIZE, "%s%s", dst->name_, src->name_); if (xbt_dict_get_or_null (filter, aux1)){ - XBT_DEBUG (" linkContainers: already registered %s <-> %s (1)", src->name, dst->name); + XBT_DEBUG(" linkContainers: already registered %s <-> %s (1)", src->name_, dst->name_); return; } if (xbt_dict_get_or_null (filter, aux2)){ - XBT_DEBUG (" linkContainers: already registered %s <-> %s (2)", dst->name, src->name); + XBT_DEBUG(" linkContainers: already registered %s <-> %s (2)", dst->name_, src->name_); return; } @@ -101,17 +101,15 @@ static void linkContainers (container_t src, container_t dst, xbt_dict_t filter) //declare type char link_typename[INSTR_DEFAULT_STR_SIZE]; - snprintf (link_typename, INSTR_DEFAULT_STR_SIZE, "%s-%s%s-%s%s", - father->type->name, - src->type->name, src->type->id, - dst->type->name, dst->type->id); - type_t link_type = PJ_type_get_or_null (link_typename, father->type); + snprintf(link_typename, INSTR_DEFAULT_STR_SIZE, "%s-%s%s-%s%s", father->type_->name_, src->type_->name_, + src->type_->id_, dst->type_->name_, dst->type_->id_); + simgrid::instr::Type* link_type = simgrid::instr::Type::getOrNull(link_typename, father->type_); if (link_type == nullptr){ - link_type = PJ_type_link_new (link_typename, father->type, src->type, dst->type); + link_type = simgrid::instr::Type::linkNew(link_typename, father->type_, src->type_, dst->type_); } //register EDGE types for triva configuration - trivaEdgeTypes.insert(link_type->name); + trivaEdgeTypes.insert(link_type->name_); //create the link static long long counter = 0; @@ -120,10 +118,10 @@ static void linkContainers (container_t src, container_t dst, xbt_dict_t filter) snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter); counter++; - new StartLinkEvent(SIMIX_get_clock(), father, link_type, src, "topology", key); - new EndLinkEvent(SIMIX_get_clock(), father, link_type, dst, "topology", key); + new simgrid::instr::StartLinkEvent(SIMIX_get_clock(), father, link_type, src, "topology", key); + new simgrid::instr::EndLinkEvent(SIMIX_get_clock(), father, link_type, dst, "topology", key); - XBT_DEBUG (" linkContainers %s <-> %s", src->name, dst->name); + XBT_DEBUG(" linkContainers %s <-> %s", src->name_, dst->name_); } static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t container, xbt_dict_t filter) @@ -136,7 +134,7 @@ static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t if (not netzone->getChildren()->empty()) { //bottom-up recursion for (auto const& nz_son : *netzone->getChildren()) { - container_t child_container = static_cast(xbt_dict_get(container->children, nz_son->getCname())); + container_t child_container = static_cast(xbt_dict_get(container->children_, nz_son->getCname())); recursiveGraphExtraction(nz_son, child_container, filter); } } @@ -169,16 +167,16 @@ static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone) if (PJ_container_get_root() == nullptr){ PJ_container_alloc (); - container_t root = PJ_container_new (id, INSTR_AS, nullptr); + container_t root = new simgrid::instr::Container(id, simgrid::instr::INSTR_AS, nullptr); PJ_container_set_root (root); if (TRACE_smpi_is_enabled()) { - type_t mpi = PJ_type_get_or_null ("MPI", root->type); + simgrid::instr::Type* mpi = simgrid::instr::Type::getOrNull("MPI", root->type_); if (mpi == nullptr){ - mpi = PJ_type_container_new("MPI", root->type); + mpi = simgrid::instr::Type::containerNew("MPI", root->type_); if (not TRACE_smpi_is_grouped()) - PJ_type_state_new ("MPI_STATE", mpi); - PJ_type_link_new ("MPI_LINK", PJ_type_get_root(), mpi, mpi); + simgrid::instr::Type::stateNew("MPI_STATE", mpi); + simgrid::instr::Type::linkNew("MPI_LINK", PJ_type_get_root(), mpi, mpi); } } @@ -190,7 +188,7 @@ static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone) if (TRACE_needs_platform()){ container_t father = currentContainer.back(); - container_t container = PJ_container_new (id, INSTR_AS, father); + container_t container = new simgrid::instr::Container(id, simgrid::instr::INSTR_AS, father); currentContainer.push_back(container); } } @@ -211,24 +209,24 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link) double bandwidth_value = link.bandwidth(); double latency_value = link.latency(); - container_t container = PJ_container_new(link.name(), INSTR_LINK, father); + container_t container = new simgrid::instr::Container(link.name(), simgrid::instr::INSTR_LINK, father); if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) { - type_t bandwidth = PJ_type_get_or_null("bandwidth", container->type); + simgrid::instr::Type* bandwidth = simgrid::instr::Type::getOrNull("bandwidth", container->type_); if (bandwidth == nullptr) { - bandwidth = PJ_type_variable_new("bandwidth", nullptr, container->type); + bandwidth = simgrid::instr::Type::variableNew("bandwidth", nullptr, container->type_); } - type_t latency = PJ_type_get_or_null("latency", container->type); + simgrid::instr::Type* latency = simgrid::instr::Type::getOrNull("latency", container->type_); if (latency == nullptr) { - latency = PJ_type_variable_new("latency", nullptr, container->type); + latency = simgrid::instr::Type::variableNew("latency", nullptr, container->type_); } - new SetVariableEvent(0, container, bandwidth, bandwidth_value); - new SetVariableEvent(0, container, latency, latency_value); + new simgrid::instr::SetVariableEvent(0, container, bandwidth, bandwidth_value); + new simgrid::instr::SetVariableEvent(0, container, latency, latency_value); } if (TRACE_uncategorized()) { - type_t bandwidth_used = PJ_type_get_or_null("bandwidth_used", container->type); + simgrid::instr::Type* bandwidth_used = simgrid::instr::Type::getOrNull("bandwidth_used", container->type_); if (bandwidth_used == nullptr) { - PJ_type_variable_new("bandwidth_used", "0.5 0.5 0.5", container->type); + simgrid::instr::Type::variableNew("bandwidth_used", "0.5 0.5 0.5", container->type_); } } } @@ -236,59 +234,59 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link) static void sg_instr_new_host(simgrid::s4u::Host& host) { container_t father = currentContainer.back(); - container_t container = PJ_container_new(host.getCname(), INSTR_HOST, father); + container_t container = new simgrid::instr::Container(host.getCname(), simgrid::instr::INSTR_HOST, father); if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) { - type_t speed = PJ_type_get_or_null ("power", container->type); + simgrid::instr::Type* speed = simgrid::instr::Type::getOrNull("power", container->type_); if (speed == nullptr){ - speed = PJ_type_variable_new ("power", nullptr, container->type); + speed = simgrid::instr::Type::variableNew("power", nullptr, container->type_); } double current_speed_state = host.getSpeed(); - new SetVariableEvent (0, container, speed, current_speed_state); + new simgrid::instr::SetVariableEvent(0, container, speed, current_speed_state); } if (TRACE_uncategorized()){ - type_t speed_used = PJ_type_get_or_null ("power_used", container->type); + simgrid::instr::Type* speed_used = simgrid::instr::Type::getOrNull("power_used", container->type_); if (speed_used == nullptr){ - PJ_type_variable_new ("power_used", "0.5 0.5 0.5", container->type); + simgrid::instr::Type::variableNew("power_used", "0.5 0.5 0.5", container->type_); } } if (TRACE_smpi_is_enabled() && TRACE_smpi_is_grouped()){ - type_t mpi = PJ_type_get_or_null ("MPI", container->type); + simgrid::instr::Type* mpi = simgrid::instr::Type::getOrNull("MPI", container->type_); if (mpi == nullptr){ - mpi = PJ_type_container_new("MPI", container->type); - PJ_type_state_new ("MPI_STATE", mpi); + mpi = simgrid::instr::Type::containerNew("MPI", container->type_); + simgrid::instr::Type::stateNew("MPI_STATE", mpi); } } if (TRACE_msg_process_is_enabled()) { - type_t msg_process = PJ_type_get_or_null ("MSG_PROCESS", container->type); + simgrid::instr::Type* msg_process = simgrid::instr::Type::getOrNull("MSG_PROCESS", container->type_); if (msg_process == nullptr){ - msg_process = PJ_type_container_new("MSG_PROCESS", container->type); - type_t state = PJ_type_state_new ("MSG_PROCESS_STATE", msg_process); - value PJ_value("suspend", "1 0 1", state); - value::get_or_new("sleep", "1 1 0", state); - value::get_or_new("receive", "1 0 0", state); - value::get_or_new("send", "0 0 1", state); - value::get_or_new("task_execute", "0 1 1", state); - PJ_type_link_new ("MSG_PROCESS_LINK", PJ_type_get_root(), msg_process, msg_process); - PJ_type_link_new ("MSG_PROCESS_TASK_LINK", PJ_type_get_root(), msg_process, msg_process); + msg_process = simgrid::instr::Type::containerNew("MSG_PROCESS", container->type_); + simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_PROCESS_STATE", msg_process); + simgrid::instr::Value PJ_value("suspend", "1 0 1", state); + simgrid::instr::Value::get_or_new("sleep", "1 1 0", state); + simgrid::instr::Value::get_or_new("receive", "1 0 0", state); + simgrid::instr::Value::get_or_new("send", "0 0 1", state); + simgrid::instr::Value::get_or_new("task_execute", "0 1 1", state); + simgrid::instr::Type::linkNew("MSG_PROCESS_LINK", PJ_type_get_root(), msg_process, msg_process); + simgrid::instr::Type::linkNew("MSG_PROCESS_TASK_LINK", PJ_type_get_root(), msg_process, msg_process); } } if (TRACE_msg_vm_is_enabled()) { - type_t msg_vm = PJ_type_get_or_null ("MSG_VM", container->type); + simgrid::instr::Type* msg_vm = simgrid::instr::Type::getOrNull("MSG_VM", container->type_); if (msg_vm == nullptr){ - msg_vm = PJ_type_container_new("MSG_VM", container->type); - type_t state = PJ_type_state_new ("MSG_VM_STATE", msg_vm); - value PJ_value("suspend", "1 0 1", state); - value::get_or_new("sleep", "1 1 0", state); - value::get_or_new("receive", "1 0 0", state); - value::get_or_new("send", "0 0 1", state); - value::get_or_new("task_execute", "0 1 1", state); - PJ_type_link_new ("MSG_VM_LINK", PJ_type_get_root(), msg_vm, msg_vm); - PJ_type_link_new ("MSG_VM_PROCESS_LINK", PJ_type_get_root(), msg_vm, msg_vm); + msg_vm = simgrid::instr::Type::containerNew("MSG_VM", container->type_); + simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_VM_STATE", msg_vm); + simgrid::instr::Value PJ_value("suspend", "1 0 1", state); + simgrid::instr::Value::get_or_new("sleep", "1 1 0", state); + simgrid::instr::Value::get_or_new("receive", "1 0 0", state); + simgrid::instr::Value::get_or_new("send", "0 0 1", state); + simgrid::instr::Value::get_or_new("task_execute", "0 1 1", state); + simgrid::instr::Type::linkNew("MSG_VM_LINK", PJ_type_get_root(), msg_vm, msg_vm); + simgrid::instr::Type::linkNew("MSG_VM_PROCESS_LINK", PJ_type_get_root(), msg_vm, msg_vm); } } @@ -300,7 +298,7 @@ static void sg_instr_new_router(simgrid::kernel::routing::NetPoint * netpoint) return; if (TRACE_is_enabled() && TRACE_needs_platform()) { container_t father = currentContainer.back(); - PJ_container_new(netpoint->cname(), INSTR_ROUTER, father); + new simgrid::instr::Container(netpoint->cname(), simgrid::instr::INSTR_ROUTER, father); } } @@ -334,27 +332,27 @@ void instr_routing_define_callbacks () /* * user categories support */ -static void recursiveNewVariableType (const char *new_typename, const char *color, type_t root) +static void recursiveNewVariableType(const char* new_typename, const char* color, simgrid::instr::Type* root) { - if (not strcmp(root->name, "HOST")) { + if (not strcmp(root->name_, "HOST")) { char tnstr[INSTR_DEFAULT_STR_SIZE]; snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename); - PJ_type_variable_new (tnstr, color, root); + simgrid::instr::Type::variableNew(tnstr, color, root); } - if (not strcmp(root->name, "MSG_VM")) { + if (not strcmp(root->name_, "MSG_VM")) { char tnstr[INSTR_DEFAULT_STR_SIZE]; snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename); - PJ_type_variable_new (tnstr, color, root); + simgrid::instr::Type::variableNew(tnstr, color, root); } - if (not strcmp(root->name, "LINK")) { + if (not strcmp(root->name_, "LINK")) { char tnstr[INSTR_DEFAULT_STR_SIZE]; snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "b%s", new_typename); - PJ_type_variable_new (tnstr, color, root); + simgrid::instr::Type::variableNew(tnstr, color, root); } xbt_dict_cursor_t cursor = nullptr; - type_t child_type; + simgrid::instr::Type* child_type; char *name; - xbt_dict_foreach(root->children, cursor, name, child_type) { + xbt_dict_foreach (root->children_, cursor, name, child_type) { recursiveNewVariableType (new_typename, color, child_type); } } @@ -364,15 +362,16 @@ void instr_new_variable_type (const char *new_typename, const char *color) recursiveNewVariableType (new_typename, color, PJ_type_get_root()); } -static void recursiveNewUserVariableType (const char *father_type, const char *new_typename, const char *color, type_t root) +static void recursiveNewUserVariableType(const char* father_type, const char* new_typename, const char* color, + simgrid::instr::Type* root) { - if (not strcmp(root->name, father_type)) { - PJ_type_variable_new (new_typename, color, root); + if (not strcmp(root->name_, father_type)) { + simgrid::instr::Type::variableNew(new_typename, color, root); } xbt_dict_cursor_t cursor = nullptr; - type_t child_type; + simgrid::instr::Type* child_type; char *name; - xbt_dict_foreach(root->children, cursor, name, child_type) { + xbt_dict_foreach (root->children_, cursor, name, child_type) { recursiveNewUserVariableType (father_type, new_typename, color, child_type); } } @@ -382,15 +381,15 @@ void instr_new_user_variable_type (const char *father_type, const char *new_typ recursiveNewUserVariableType (father_type, new_typename, color, PJ_type_get_root()); } -static void recursiveNewUserStateType (const char *father_type, const char *new_typename, type_t root) +static void recursiveNewUserStateType(const char* father_type, const char* new_typename, simgrid::instr::Type* root) { - if (not strcmp(root->name, father_type)) { - PJ_type_state_new (new_typename, root); + if (not strcmp(root->name_, father_type)) { + simgrid::instr::Type::stateNew(new_typename, root); } xbt_dict_cursor_t cursor = nullptr; - type_t child_type; + simgrid::instr::Type* child_type; char *name; - xbt_dict_foreach(root->children, cursor, name, child_type) { + xbt_dict_foreach (root->children_, cursor, name, child_type) { recursiveNewUserStateType (father_type, new_typename, child_type); } } @@ -400,15 +399,16 @@ void instr_new_user_state_type (const char *father_type, const char *new_typenam recursiveNewUserStateType (father_type, new_typename, PJ_type_get_root()); } -static void recursiveNewValueForUserStateType(const char* type_name, const char* val, const char* color, type_t root) +static void recursiveNewValueForUserStateType(const char* type_name, const char* val, const char* color, + simgrid::instr::Type* root) { - if (not strcmp(root->name, type_name)) { - value PJ_value(val, color, root); + if (not strcmp(root->name_, type_name)) { + simgrid::instr::Value PJ_value(val, color, root); } xbt_dict_cursor_t cursor = nullptr; - type_t child_type; + simgrid::instr::Type* child_type; char *name; - xbt_dict_foreach(root->children, cursor, name, child_type) { + xbt_dict_foreach (root->children_, cursor, name, child_type) { recursiveNewValueForUserStateType(type_name, val, color, child_type); } } @@ -432,7 +432,7 @@ static void recursiveXBTGraphExtraction(xbt_graph_t graph, xbt_dict_t nodes, xbt //bottom-up recursion for (auto const& netzone_child : *netzone->getChildren()) { container_t child_container = - static_cast(xbt_dict_get(container->children, netzone_child->getCname())); + static_cast(xbt_dict_get(container->children_, netzone_child->getCname())); recursiveXBTGraphExtraction(graph, nodes, edges, netzone_child, child_container); } } diff --git a/src/surf/instr_surf.cpp b/src/surf/instr_surf.cpp index 4d45aa1169..d82ef1b992 100644 --- a/src/surf/instr_surf.cpp +++ b/src/surf/instr_surf.cpp @@ -13,8 +13,8 @@ void TRACE_surf_host_set_speed(double date, const char *resource, double speed) { if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) { container_t container = PJ_container_get(resource); - type_t type = PJ_type_get ("power", container->type); - new SetVariableEvent(date, container, type, speed); + simgrid::instr::Type* type = PJ_type_get("power", container->type_); + new simgrid::instr::SetVariableEvent(date, container, type, speed); } } @@ -22,8 +22,8 @@ void TRACE_surf_link_set_bandwidth(double date, const char *resource, double ban { if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) { container_t container = PJ_container_get(resource); - type_t type = PJ_type_get ("bandwidth", container->type); - new SetVariableEvent(date, container, type, bandwidth); + simgrid::instr::Type* type = PJ_type_get("bandwidth", container->type_); + new simgrid::instr::SetVariableEvent(date, container, type, bandwidth); } } diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 30e3b08d65..e0ae4e41af 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -165,7 +165,7 @@ NetworkCm02Model::NetworkCm02Model(void (*specificSolveFun)(lmm_system_t self)) maxminSystem_->solve_fun = specificSolveFun; } -LinkImpl* NetworkCm02Model::createLink(const char* name, double bandwidth, double latency, +LinkImpl* NetworkCm02Model::createLink(const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) { return new NetworkCm02Link(this, name, bandwidth, latency, policy, maxminSystem_); @@ -358,7 +358,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz /************ * Resource * ************/ -NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const char* name, double bandwidth, double latency, +NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy, lmm_system_t system) : LinkImpl(model, name, lmm_constraint_new(system, this, sg_bandwidth_factor * bandwidth)) { diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index 8ffa8ef3b0..7fd4187441 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -38,7 +38,7 @@ public: NetworkCm02Model(); explicit NetworkCm02Model(void (*solve_fun)(lmm_system_t self)); virtual ~NetworkCm02Model() = default; - LinkImpl* createLink(const char* name, double bandwidth, double latency, + LinkImpl* createLink(const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) override; void updateActionsStateLazy(double now, double delta) override; void updateActionsStateFull(double now, double delta) override; @@ -51,7 +51,7 @@ public: class NetworkCm02Link : public LinkImpl { public: - NetworkCm02Link(NetworkCm02Model* model, const char* name, double bandwidth, double latency, + NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy, lmm_system_t system); virtual ~NetworkCm02Link() = default; void apply_event(tmgr_trace_event_t event, double value) override; diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index 68a291a198..35a66b6bd0 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2013-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -20,12 +19,13 @@ void surf_network_model_init_Constant() namespace simgrid { namespace surf { -LinkImpl* NetworkConstantModel::createLink(const char* name, double bw, double lat, e_surf_link_sharing_policy_t policy) +LinkImpl* NetworkConstantModel::createLink(const std::string& name, double bw, double lat, + e_surf_link_sharing_policy_t policy) { xbt_die("Refusing to create the link %s: there is no link in the Constant network model. " "Please remove any link from your platform (and switch to routing='None')", - name); + name.c_str()); return nullptr; } diff --git a/src/surf/network_constant.hpp b/src/surf/network_constant.hpp index 61e36a52d0..108941ced3 100644 --- a/src/surf/network_constant.hpp +++ b/src/surf/network_constant.hpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2013-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -30,7 +29,8 @@ namespace simgrid { double nextOccuringEvent(double now) override; void updateActionsState(double now, double delta) override; - LinkImpl* createLink(const char* name, double bw, double lat, e_surf_link_sharing_policy_t policy) override; + LinkImpl* createLink(const std::string& name, double bw, double lat, + e_surf_link_sharing_policy_t policy) override; }; /********** diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index d6f78f78e5..6e2569a32d 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -98,19 +98,18 @@ namespace simgrid { * Resource * ************/ - LinkImpl::LinkImpl(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint) + LinkImpl::LinkImpl(simgrid::surf::NetworkModel* model, const std::string& name, lmm_constraint_t constraint) : Resource(model, name, constraint), piface_(this) { - if (strcmp(name,"__loopback__")) - xbt_assert(not LinkImpl::byName(name), "Link '%s' declared several times in the platform.", name); + if (name != "__loopback__") + xbt_assert(not LinkImpl::byName(name), "Link '%s' declared several times in the platform.", name.c_str()); latency_.scale = 1; bandwidth_.scale = 1; links->insert({name, this}); - XBT_DEBUG("Create link '%s'",name); - + XBT_DEBUG("Create link '%s'", name.c_str()); } /** @brief use destroy() instead of this destructor */ diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index be484919a7..d8a3b0d10a 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -43,7 +43,7 @@ public: * @param latency The initial latency of the Link in seconds * @param policy The sharing policy of the Link */ - virtual LinkImpl* createLink(const char* name, double bandwidth, double latency, + virtual LinkImpl* createLink(const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) = 0; /** @@ -114,7 +114,7 @@ public: */ class LinkImpl : public simgrid::surf::Resource, public simgrid::surf::PropertyHolder { protected: - LinkImpl(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint); + LinkImpl(simgrid::surf::NetworkModel* model, const std::string& name, lmm_constraint_t constraint); ~LinkImpl() override; public: diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 31f5fd9c86..fe0fdee60f 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -143,6 +143,7 @@ namespace surf { NetworkNS3Model::NetworkNS3Model() : NetworkModel() { NetPointNs3::EXTENSION_ID = simgrid::kernel::routing::NetPoint::extension_create(); + flowFromSock = xbt_dict_new_homogeneous([](void* p) { delete static_cast(p); }); ns3_initialize(ns3_tcp_model.get().c_str()); simgrid::kernel::routing::NetPoint::onCreation.connect([](simgrid::kernel::routing::NetPoint* pt) { @@ -165,7 +166,7 @@ NetworkNS3Model::~NetworkNS3Model() { xbt_dict_free(&flowFromSock); } -LinkImpl* NetworkNS3Model::createLink(const char* name, double bandwidth, double latency, +LinkImpl* NetworkNS3Model::createLink(const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) { return new LinkNS3(this, name, bandwidth, latency); @@ -245,7 +246,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta) xbt_dynar_pop(socket_to_destroy,&ns3Socket); if (XBT_LOG_ISENABLED(ns3, xbt_log_priority_debug)) { - SgFlow *flow = (SgFlow*)xbt_dict_get (flowFromSock, ns3Socket); + SgFlow* flow = static_cast(xbt_dict_get(flowFromSock, ns3Socket)); XBT_DEBUG ("Removing socket %p of action %p", ns3Socket, flow->action_); } xbt_dict_remove(flowFromSock, ns3Socket); @@ -256,7 +257,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta) * Resource * ************/ -LinkNS3::LinkNS3(NetworkNS3Model* model, const char* name, double bandwidth, double latency) +LinkNS3::LinkNS3(NetworkNS3Model* model, const std::string& name, double bandwidth, double latency) : LinkImpl(model, name, nullptr) { bandwidth_.peak = bandwidth; diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index 196d193d5e..b30a7eb830 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -18,7 +18,7 @@ class NetworkNS3Model : public NetworkModel { public: NetworkNS3Model(); ~NetworkNS3Model(); - LinkImpl* createLink(const char* name, double bandwidth, double latency, + LinkImpl* createLink(const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) override; Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; double nextOccuringEvent(double now) override; @@ -31,7 +31,7 @@ public: ************/ class LinkNS3 : public LinkImpl { public: - explicit LinkNS3(NetworkNS3Model* model, const char* name, double bandwidth, double latency); + explicit LinkNS3(NetworkNS3Model* model, const std::string& name, double bandwidth, double latency); ~LinkNS3(); void apply_event(tmgr_trace_event_t event, double value) override; diff --git a/src/surf/ns3/ns3_simulator.cc b/src/surf/ns3/ns3_simulator.cc index e675094a85..55df59e5b3 100644 --- a/src/surf/ns3/ns3_simulator.cc +++ b/src/surf/ns3/ns3_simulator.cc @@ -10,9 +10,7 @@ #include -xbt_dict_t flowFromSock = xbt_dict_new_homogeneous([](void *p) { - delete (SgFlow*)p; -}); // ns3::sock -> SgFlow +xbt_dict_t flowFromSock = nullptr; // ns3::sock -> SgFlow static void receive_callback(ns3::Ptr socket); static void datasent_callback(ns3::Ptr socket, uint32_t dataSent); diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 0ee2f30ddc..c1750d7333 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2010, 2013-2015. The SimGrid Team. +/* Copyright (c) 2007-2010, 2013-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -249,7 +249,7 @@ Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host, std::vector *spee return new CpuL07(this, host, speedPerPstate, core); } -LinkImpl* NetworkL07Model::createLink(const char* name, double bandwidth, double latency, +LinkImpl* NetworkL07Model::createLink(const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) { return new LinkL07(this, name, bandwidth, latency, policy); @@ -267,7 +267,7 @@ CpuL07::CpuL07(CpuL07Model* model, simgrid::s4u::Host* host, std::vector CpuL07::~CpuL07()=default; -LinkL07::LinkL07(NetworkL07Model* model, const char* name, double bandwidth, double latency, +LinkL07::LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) : LinkImpl(model, name, lmm_constraint_new(model->getMaxminSystem(), this, bandwidth)) { diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index 5d25d4e48e..3b944a36bd 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2015. The SimGrid Team. +/* Copyright (c) 2013-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -58,7 +58,7 @@ class NetworkL07Model : public NetworkModel { public: NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys); ~NetworkL07Model(); - LinkImpl* createLink(const char* name, double bandwidth, double latency, + LinkImpl* createLink(const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) override; Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; @@ -84,7 +84,7 @@ protected: class LinkL07 : public LinkImpl { public: - LinkL07(NetworkL07Model* model, const char* name, double bandwidth, double latency, + LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy); ~LinkL07() override; bool isUsed() override; diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 219c19331e..6966739b7b 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -131,12 +131,11 @@ void sg_platf_new_link(LinkCreationArgs* link) } for (auto const& link_name : names) { simgrid::surf::LinkImpl* l = - surf_network_model->createLink(link_name.c_str(), link->bandwidth, link->latency, link->policy); + surf_network_model->createLink(link_name, link->bandwidth, link->latency, link->policy); if (link->properties) { for (auto const& elm : *link->properties) l->setProperty(elm.first, elm.second); - delete link->properties; } if (link->latency_trace) @@ -146,6 +145,7 @@ void sg_platf_new_link(LinkCreationArgs* link) if (link->state_trace) l->setStateTrace(link->state_trace); } + delete link->properties; } void sg_platf_new_cluster(ClusterCreationArgs* cluster) @@ -274,7 +274,7 @@ void sg_platf_new_cluster(ClusterCreationArgs* cluster) XBT_DEBUG("", cluster->router_id.c_str()); if (cluster->router_id.empty()) { std::string newid = std::string(cluster->prefix) + cluster->id + "_router" + cluster->suffix; - current_as->router_ = sg_platf_new_router(newid.c_str(), NULL); + current_as->router_ = sg_platf_new_router(newid, NULL); } else { current_as->router_ = sg_platf_new_router(cluster->router_id, NULL); } diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 9275ffe215..a8a7239d2c 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -549,7 +549,7 @@ void Model::updateActionsStateFull(double /*now*/, double /*delta*/) namespace simgrid { namespace surf { -Resource::Resource(Model* model, const char* name, lmm_constraint_t constraint) +Resource::Resource(Model* model, const std::string& name, lmm_constraint_t constraint) : name_(name), model_(model), constraint_(constraint) {} diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index f465a21607..65eea27d30 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -363,7 +363,7 @@ public: * @param name The name of the Resource * @param constraint The lmm constraint associated to this Resource if it is part of a LMM component */ - Resource(Model *model, const char *name, lmm_constraint_t constraint); + Resource(Model * model, const std::string& name, lmm_constraint_t constraint); virtual ~Resource(); @@ -412,13 +412,9 @@ protected: } namespace std { - template <> - struct hash - { - std::size_t operator()(const simgrid::surf::Resource& r) const - { - return (std::size_t) xbt_str_hash(r.cname()); - } +template <> class hash { +public: + std::size_t operator()(const simgrid::surf::Resource& r) const { return (std::size_t)xbt_str_hash(r.cname()); } }; } diff --git a/src/xbt/cunit.cpp b/src/xbt/cunit.cpp index 1bf81768e8..9da7c7ea5f 100644 --- a/src/xbt/cunit.cpp +++ b/src/xbt/cunit.cpp @@ -16,6 +16,8 @@ #include "xbt/cunit.h" #include "xbt/dynar.h" +#define STRLEN 1024 + /* collection of all suites */ static xbt_dynar_t _xbt_test_suites = nullptr; /* global statistics */ @@ -454,15 +456,15 @@ static void apply_selection(char *selection) /* for the parsing */ char *sel = selection; int done = 0; - char dir[1024]; /* the directive */ + char dir[STRLEN]; /* the directive */ /* iterators */ unsigned int it_suite; xbt_test_suite_t suite; xbt_test_unit_t unit; unsigned int it_unit; - char suitename[512]; - char unitname[512]; + char suitename[STRLEN]; + char unitname[STRLEN]; if (not selection || selection[0] == '\0') return; @@ -475,11 +477,10 @@ static void apply_selection(char *selection) char *p = strchr(sel, ','); if (p) { - strncpy(dir, sel, p - sel); - dir[p - sel] = '\0'; + snprintf(dir, STRLEN, "%.*s", (int)(p - sel), sel); sel = p + 1; } else { - strncpy(dir, sel,1024); + snprintf(dir, STRLEN, "%s", sel); done = 1; } @@ -494,11 +495,10 @@ static void apply_selection(char *selection) p = strchr(dir, ':'); if (p) { - strncpy(unitname, p + 1,512); - strncpy(suitename, dir, p - dir); - suitename[p - dir] = '\0'; + snprintf(suitename, STRLEN, "%.*s", (int)(p - dir), dir); + snprintf(unitname, STRLEN, "%s", p + 1); } else { - strncpy(suitename, dir,512); + snprintf(suitename, STRLEN, "%s", dir); unitname[0] = '\0'; } diff --git a/src/xbt/dict.cpp b/src/xbt/dict.cpp index 6a94aae7e3..485641c1d9 100644 --- a/src/xbt/dict.cpp +++ b/src/xbt/dict.cpp @@ -638,7 +638,7 @@ static void traverse(xbt_dict_t head) } else { xbt_test_log("Seen #%d: %s", ++i, key); } - xbt_test_assert(not data || not strcmp(key, data), "Key(%s) != value(%s). Aborting", key, data); + xbt_test_assert(key && data && strcmp(key, data) == 0, "Key(%s) != value(%s). Aborting", key, data); } } @@ -750,8 +750,7 @@ XBT_TEST_UNIT("basic", test_dict_basic, "Basic usage: change, retrieve and trave /* RETRIEVE */ xbt_test_add("Search 123"); char* data = (char*)xbt_dict_get(head, "123"); - xbt_test_assert(data); - xbt_test_assert(not strcmp("123", data)); + xbt_test_assert(data && strcmp("123", data) == 0); search_not_found(head, "Can't be found"); search_not_found(head, "123 Can't be found"); @@ -864,7 +863,7 @@ XBT_TEST_UNIT("nulldata", test_dict_nulldata, "nullptr data management") xbt_test_log("Seen: %s", key); } - if (not strcmp(key, "null")) + if (key && strcmp(key, "null") == 0) found = 1; } xbt_test_assert(found, "the key 'null', associated to nullptr is not found"); diff --git a/src/xbt/ex.cpp b/src/xbt/ex.cpp index 50a97f1666..f609b1d7c0 100644 --- a/src/xbt/ex.cpp +++ b/src/xbt/ex.cpp @@ -59,6 +59,10 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_ex, xbt, "Exception mechanism"); +// Don't define ~xbt_ex() in ex.hpp. It is defined here to ensure that there is an unique definition of xt_ex in +// libsimgrid, but not in libsimgrid-java. Otherwise, sone tests are broken (seen with clang/libc++ on freebsd). +xbt_ex::~xbt_ex() = default; + void _xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, int line, const char* func) { xbt_ex e(simgrid::xbt::ThrowPoint(file, line, func), message); diff --git a/src/xbt/log.c b/src/xbt/log.c index 7d82b132c5..30d72a92e6 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -821,9 +821,10 @@ static void xbt_log_help(void) " -> warning: minor issue encountered\n" " -> error: issue encountered\n" " -> critical: major issue encountered\n" + " The default priority level is 'info'.\n" "\n" - " Format configuration: --log=CATEGORY_NAME.fmt:OPTIONS\n" - " OPTIONS may be:\n" + " Format configuration: --log=CATEGORY_NAME.fmt:FORMAT\n" + " FORMAT string may contain:\n" " -> %%%%: the %% char\n" " -> %%n: platform-dependent line separator (LOG4J compatible)\n" " -> %%e: plain old space (SimGrid extension)\n" diff --git a/src/xbt/mmalloc/mm_module.c b/src/xbt/mmalloc/mm_module.c index 6c04fdfa84..ec21f2d7df 100644 --- a/src/xbt/mmalloc/mm_module.c +++ b/src/xbt/mmalloc/mm_module.c @@ -381,32 +381,3 @@ ssize_t mmalloc_get_busy_size(xbt_mheap_t heap, void *ptr){ } } - -void mmcheck(xbt_mheap_t heap) {return; - if (!heap->heapinfo) - return; - malloc_info* heapinfo = NULL; - for (size_t i=1; i < heap->heaplimit; i += mmalloc_get_increment(heapinfo)) { - heapinfo = heap->heapinfo + i; - switch (heapinfo->type) { - case MMALLOC_TYPE_HEAPINFO: - case MMALLOC_TYPE_FREE: - if (heapinfo->free_block.size==0) { - xbt_die("Block size == 0"); - } - break; - case MMALLOC_TYPE_UNFRAGMENTED: - if (heapinfo->busy_block.size==0) { - xbt_die("Block size == 0"); - } - if (heapinfo->busy_block.busy_size==0 && heapinfo->busy_block.size!=0) { - xbt_die("Empty busy block"); - } - break; - default: - if (heapinfo->type<0) { - xbt_die("Unkown mmalloc block type."); - } - } - } -} diff --git a/src/xbt/mmalloc/mmprivate.h b/src/xbt/mmalloc/mmprivate.h index 93f925ab47..5e6609d9c1 100644 --- a/src/xbt/mmalloc/mmprivate.h +++ b/src/xbt/mmalloc/mmprivate.h @@ -310,8 +310,6 @@ static inline int mmalloc_get_increment(malloc_info* heapinfo) { } } -XBT_PRIVATE void mmcheck(xbt_mheap_t heap); - XBT_PRIVATE int malloc_use_mmalloc(void); XBT_PRIVATE int mmalloc_exec_using_mm(int argc, const char** argv); diff --git a/src/xbt/mmalloc/mrealloc.c b/src/xbt/mmalloc/mrealloc.c index dfd03b81b0..aabf868be6 100644 --- a/src/xbt/mmalloc/mrealloc.c +++ b/src/xbt/mmalloc/mrealloc.c @@ -36,9 +36,7 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size) if ((char *) ptr < (char *) mdp->heapbase || BLOCK(ptr) > mdp->heapsize) { printf("FIXME. Ouch, this pointer is not mine, refusing to proceed (another solution would be to malloc " "it instead of reallocing it, see source code)\n"); - result = mmalloc(mdp, size); abort(); - return result; } size_t requested_size = size; // The amount of memory requested by user, for real diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index 18c55ac2ce..7c41b5b706 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -153,7 +153,10 @@ static int xbt_log_layout_format_doit(xbt_log_layout_t l, xbt_log_event_t ev, co case 'm': { /* user-provided message; LOG4J compliant */ int sz; set_sz_from_precision(); - int len = vsnprintf(p, sz, msg_fmt, ev->ap); + va_list ap; + va_copy(ap, ev->ap); + int len = vsnprintf(p, sz, msg_fmt, ap); + va_end(ap); check_overflow(MIN(sz, len)); break; } diff --git a/src/xbt/xbt_main.cpp b/src/xbt/xbt_main.cpp index ffd97cd274..f1736ce64a 100644 --- a/src/xbt/xbt_main.cpp +++ b/src/xbt/xbt_main.cpp @@ -25,10 +25,10 @@ #include "src/internal_config.h" #include #ifdef _WIN32 -#include /* To silence MSVC on abort() */ +# include /* To silence MSVC on abort() */ #endif #if HAVE_UNISTD_H -# include +# include #endif XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module, xbt, "module handling"); @@ -85,7 +85,7 @@ static void xbt_preinit() #elif HAVE_SYSCONF xbt_pagesize = sysconf(_SC_PAGESIZE); #else - #error Cannot get page size. +# error Cannot get page size. #endif xbt_pagebits = log2(xbt_pagesize); diff --git a/teshsuite/smpi/coll-allgather/coll-allgather.tesh b/teshsuite/smpi/coll-allgather/coll-allgather.tesh index cda0bba97f..7f6d031a31 100644 --- a/teshsuite/smpi/coll-allgather/coll-allgather.tesh +++ b/teshsuite/smpi/coll-allgather/coll-allgather.tesh @@ -1,5 +1,4 @@ # Smpi Alltoall collectives tests -! setenv LD_LIBRARY_PATH=../../lib ! output sort p Test allgather diff --git a/teshsuite/smpi/coll-allgatherv/coll-allgatherv.c b/teshsuite/smpi/coll-allgatherv/coll-allgatherv.c index 1cbda3cc01..30734f17d5 100644 --- a/teshsuite/smpi/coll-allgatherv/coll-allgatherv.c +++ b/teshsuite/smpi/coll-allgatherv/coll-allgatherv.c @@ -39,16 +39,16 @@ int main(int argc, char *argv[]) int* sb = (int *) xbt_malloc(recv_counts[rank] * sizeof(int)); int* rb = (int *) xbt_malloc(recv_sb_size * sizeof(int)); - for (i = 0; i < recv_counts[rank]; ++i) - sb[i] = recv_disps[rank] + i; - for (i = 0; i < recv_sb_size; ++i) - rb[i] = -1; - printf("[%d] sndbuf=[", rank); - for (i = 0; i < recv_counts[rank]; i++) + for (i = 0; i < recv_counts[rank]; i++){ + sb[i] = recv_disps[rank] + i; printf("%d ", sb[i]); + } printf("]\n"); + for (i = 0; i < recv_sb_size; i++) + rb[i] = -1; + status = MPI_Allgatherv(sb, recv_counts[rank], MPI_INT, rb, recv_counts, recv_disps, MPI_INT, MPI_COMM_WORLD); printf("[%d] rcvbuf=[", rank); diff --git a/teshsuite/smpi/coll-allgatherv/coll-allgatherv.tesh b/teshsuite/smpi/coll-allgatherv/coll-allgatherv.tesh index b3a6e49531..835f62872d 100644 --- a/teshsuite/smpi/coll-allgatherv/coll-allgatherv.tesh +++ b/teshsuite/smpi/coll-allgatherv/coll-allgatherv.tesh @@ -1,5 +1,4 @@ # Smpi Allgatherv collectives tests -! setenv LD_LIBRARY_PATH=../../lib ! output sort p Test allgatherv diff --git a/teshsuite/smpi/coll-allreduce/coll-allreduce-automatic.tesh b/teshsuite/smpi/coll-allreduce/coll-allreduce-automatic.tesh index 57d1fa2bf5..b8b77622c1 100644 --- a/teshsuite/smpi/coll-allreduce/coll-allreduce-automatic.tesh +++ b/teshsuite/smpi/coll-allreduce/coll-allreduce-automatic.tesh @@ -1,5 +1,4 @@ # Smpi Allreduce collectives tests -! setenv LD_LIBRARY_PATH=../../lib p Test allreduce ! output sort diff --git a/teshsuite/smpi/coll-allreduce/coll-allreduce-large.tesh b/teshsuite/smpi/coll-allreduce/coll-allreduce-large.tesh index 841a8f4c00..1aa4a721a6 100644 --- a/teshsuite/smpi/coll-allreduce/coll-allreduce-large.tesh +++ b/teshsuite/smpi/coll-allreduce/coll-allreduce-large.tesh @@ -1,5 +1,4 @@ # Smpi Allreduce collectives tests -! setenv LD_LIBRARY_PATH=../../lib ! output sort ! timeout 20 diff --git a/teshsuite/smpi/coll-allreduce/coll-allreduce.c b/teshsuite/smpi/coll-allreduce/coll-allreduce.c index 45eeb9c8e5..509aec9883 100644 --- a/teshsuite/smpi/coll-allreduce/coll-allreduce.c +++ b/teshsuite/smpi/coll-allreduce/coll-allreduce.c @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); if (maxlen > 1) - mult = size; + mult = maxlen > size ? size : maxlen; int* sb = (int *) xbt_malloc(size *maxlen * sizeof(int)); int* rb = (int *) xbt_malloc(size *maxlen * sizeof(int)); diff --git a/teshsuite/smpi/coll-allreduce/coll-allreduce.tesh b/teshsuite/smpi/coll-allreduce/coll-allreduce.tesh index f3eefc0010..f1b9a3c67c 100644 --- a/teshsuite/smpi/coll-allreduce/coll-allreduce.tesh +++ b/teshsuite/smpi/coll-allreduce/coll-allreduce.tesh @@ -1,5 +1,4 @@ # Smpi Allreduce collectives tests -! setenv LD_LIBRARY_PATH=../../lib ! output sort p Test allreduce diff --git a/teshsuite/smpi/coll-alltoall/clusters.tesh b/teshsuite/smpi/coll-alltoall/clusters.tesh index 49527e232b..1367a2e437 100644 --- a/teshsuite/smpi/coll-alltoall/clusters.tesh +++ b/teshsuite/smpi/coll-alltoall/clusters.tesh @@ -1,5 +1,4 @@ # Smpi Alltoall on various cluster files, with several routings -! setenv LD_LIBRARY_PATH=../../lib ! output sort p Test classic - backbone diff --git a/teshsuite/smpi/coll-alltoall/coll-alltoall.tesh b/teshsuite/smpi/coll-alltoall/coll-alltoall.tesh index d9cf5d269c..1dda4e2314 100644 --- a/teshsuite/smpi/coll-alltoall/coll-alltoall.tesh +++ b/teshsuite/smpi/coll-alltoall/coll-alltoall.tesh @@ -1,5 +1,4 @@ # Smpi Alltoall collectives tests -! setenv LD_LIBRARY_PATH=../../lib ! output sort p Test all to all diff --git a/teshsuite/smpi/coll-alltoallv/coll-alltoallv.c b/teshsuite/smpi/coll-alltoallv/coll-alltoallv.c index fced26e395..107179fe01 100644 --- a/teshsuite/smpi/coll-alltoallv/coll-alltoallv.c +++ b/teshsuite/smpi/coll-alltoallv/coll-alltoallv.c @@ -68,6 +68,10 @@ int main(int argc, char **argv) /* Create the buffer */ MPI_Comm_size(comm, &size); + if(size<=0){ + printf("error : comm size <= 0, run with mpirun\n"); + return -1; + } MPI_Comm_rank(comm, &rank); int* sbuf = (int *) xbt_malloc(size * size * sizeof(int)); int* rbuf = (int *) xbt_malloc(size * size * sizeof(int)); diff --git a/teshsuite/smpi/coll-alltoallv/coll-alltoallv.tesh b/teshsuite/smpi/coll-alltoallv/coll-alltoallv.tesh index dfcf17e975..02acc662d7 100644 --- a/teshsuite/smpi/coll-alltoallv/coll-alltoallv.tesh +++ b/teshsuite/smpi/coll-alltoallv/coll-alltoallv.tesh @@ -1,5 +1,4 @@ # Smpi Alltoall collectives tests -! setenv LD_LIBRARY_PATH=../../lib ! output sort p Test all to all diff --git a/teshsuite/smpi/coll-barrier/coll-barrier.tesh b/teshsuite/smpi/coll-barrier/coll-barrier.tesh index 6dd68217aa..6f92664c2a 100644 --- a/teshsuite/smpi/coll-barrier/coll-barrier.tesh +++ b/teshsuite/smpi/coll-barrier/coll-barrier.tesh @@ -1,5 +1,4 @@ # Smpi scatter collectives tests -! setenv LD_LIBRARY_PATH=../../lib ! output sort p Test barrier diff --git a/teshsuite/smpi/coll-bcast/coll-bcast.tesh b/teshsuite/smpi/coll-bcast/coll-bcast.tesh index 000ddca254..32d741e360 100644 --- a/teshsuite/smpi/coll-bcast/coll-bcast.tesh +++ b/teshsuite/smpi/coll-bcast/coll-bcast.tesh @@ -1,5 +1,4 @@ p Test Broadcast with more processes than hosts -! setenv LD_LIBRARY_PATH=../../lib ! output sort $ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile_coll -platform ../../../examples/platforms/small_platform.xml -np 16 --log=xbt_cfg.thres:critical ${bindir:=.}/coll-bcast --log=smpi_kernel.thres:warning --log=smpi_coll.thres:error diff --git a/teshsuite/smpi/coll-gather/coll-gather.tesh b/teshsuite/smpi/coll-gather/coll-gather.tesh index 6ac136a319..99efd2b02a 100644 --- a/teshsuite/smpi/coll-gather/coll-gather.tesh +++ b/teshsuite/smpi/coll-gather/coll-gather.tesh @@ -1,5 +1,4 @@ # Smpi Alltoall collectives tests -! setenv LD_LIBRARY_PATH=../../lib ! output sort ! timeout 30 diff --git a/teshsuite/smpi/coll-reduce-scatter/coll-reduce-scatter.tesh b/teshsuite/smpi/coll-reduce-scatter/coll-reduce-scatter.tesh index 557b7c9d28..5c04f3e35d 100644 --- a/teshsuite/smpi/coll-reduce-scatter/coll-reduce-scatter.tesh +++ b/teshsuite/smpi/coll-reduce-scatter/coll-reduce-scatter.tesh @@ -1,5 +1,4 @@ # Smpi reduce scatter collectives tests -! setenv LD_LIBRARY_PATH=../../lib ! output sort p Test reduce_scatter diff --git a/teshsuite/smpi/coll-reduce/coll-reduce.tesh b/teshsuite/smpi/coll-reduce/coll-reduce.tesh index b33cfb305a..bbab866811 100644 --- a/teshsuite/smpi/coll-reduce/coll-reduce.tesh +++ b/teshsuite/smpi/coll-reduce/coll-reduce.tesh @@ -1,5 +1,4 @@ # Smpi Allreduce collectives tests -! setenv LD_LIBRARY_PATH=../../lib ! output sort p Test allreduce diff --git a/teshsuite/smpi/coll-scatter/coll-scatter.tesh b/teshsuite/smpi/coll-scatter/coll-scatter.tesh index f1ba5c6cf0..a7bd5a65f8 100644 --- a/teshsuite/smpi/coll-scatter/coll-scatter.tesh +++ b/teshsuite/smpi/coll-scatter/coll-scatter.tesh @@ -1,5 +1,4 @@ # Smpi scatter collectives tests -! setenv LD_LIBRARY_PATH=../../lib ! output sort p Test scatter diff --git a/teshsuite/smpi/macro-partial-shared-communication/macro-partial-shared-communication.tesh b/teshsuite/smpi/macro-partial-shared-communication/macro-partial-shared-communication.tesh index 7c17af24a3..839b94055f 100644 --- a/teshsuite/smpi/macro-partial-shared-communication/macro-partial-shared-communication.tesh +++ b/teshsuite/smpi/macro-partial-shared-communication/macro-partial-shared-communication.tesh @@ -1,5 +1,4 @@ p Test compute -! setenv LD_LIBRARY_PATH=../../lib ! output sort ! timeout 5 $ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-partial-shared-communication --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning diff --git a/teshsuite/smpi/macro-partial-shared/macro-partial-shared.tesh b/teshsuite/smpi/macro-partial-shared/macro-partial-shared.tesh index 9ae19143cc..985dbbef87 100644 --- a/teshsuite/smpi/macro-partial-shared/macro-partial-shared.tesh +++ b/teshsuite/smpi/macro-partial-shared/macro-partial-shared.tesh @@ -1,5 +1,4 @@ p Test compute -! setenv LD_LIBRARY_PATH=../../lib ! output sort ! timeout 5 $ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-partial-shared --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning diff --git a/teshsuite/smpi/macro-shared/macro-shared.tesh b/teshsuite/smpi/macro-shared/macro-shared.tesh index 2a79f0996c..af9fd486d7 100644 --- a/teshsuite/smpi/macro-shared/macro-shared.tesh +++ b/teshsuite/smpi/macro-shared/macro-shared.tesh @@ -1,5 +1,4 @@ p Test compute -! setenv LD_LIBRARY_PATH=../../lib ! output sort ! timeout 5 $ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-shared --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning diff --git a/teshsuite/smpi/privatization/privatization.tesh b/teshsuite/smpi/privatization/privatization.tesh index b04775fc75..c749a9e563 100644 --- a/teshsuite/smpi/privatization/privatization.tesh +++ b/teshsuite/smpi/privatization/privatization.tesh @@ -1,5 +1,4 @@ p Test privatization -! setenv LD_LIBRARY_PATH=../../lib ! timeout 5 $ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 32 ${bindir:=.}/privatization --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/privatization:1 --log=simix_context.thres:error --log=xbt_memory_map.thres:critical > You requested to use 32 ranks, but there is only 5 processes in your hostfile... diff --git a/teshsuite/smpi/privatization/privatization_dlopen.tesh b/teshsuite/smpi/privatization/privatization_dlopen.tesh index ced2221bae..6dea653099 100644 --- a/teshsuite/smpi/privatization/privatization_dlopen.tesh +++ b/teshsuite/smpi/privatization/privatization_dlopen.tesh @@ -1,5 +1,4 @@ p Test privatization with dlopen -! setenv LD_LIBRARY_PATH=../../lib ! timeout 5 $ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 32 ${bindir:=.}/privatization --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/privatization:dlopen --log=simix_context.thres:error > You requested to use 32 ranks, but there is only 5 processes in your hostfile... diff --git a/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh b/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh index 23f4e201ad..ea6e70929f 100644 --- a/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh +++ b/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh @@ -1,5 +1,4 @@ p Test dsend -! setenv LD_LIBRARY_PATH=../../lib ! output sort $ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning > [Jupiter:1:(2) 0.000000] [dsend/INFO] rank 1: data exchanged @@ -11,7 +10,6 @@ p Test dsend with timings injection p message size is 4 bytes p process 1 will finish at 0.5+2*4 (send) + 1+0.1*4 (isend) = 9.9s p process 2 will finish at 0.5+2*4 (time before first send) + 2*(1+0.5*4) (recv+irecv) + 0.005890 (network time, same as before) = 14.505890s -! setenv LD_LIBRARY_PATH=../../lib ! output sort $ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -q --log=smpi_kernel.thres:warning --cfg=smpi/or:0:1:0.5 --cfg=smpi/os:0:0.5:2 --cfg=smpi/ois:0:1:0.1 --log=xbt_cfg.thres:warning > [Jupiter:1:(2) 9.900000] [dsend/INFO] rank 1: data exchanged diff --git a/teshsuite/smpi/pt2pt-pingpong/TI_output.tesh b/teshsuite/smpi/pt2pt-pingpong/TI_output.tesh index 41b3d1315c..adacbe79ff 100644 --- a/teshsuite/smpi/pt2pt-pingpong/TI_output.tesh +++ b/teshsuite/smpi/pt2pt-pingpong/TI_output.tesh @@ -3,7 +3,6 @@ $ rm -rf ./out_in_ti.txt_files p Test output of time independent tracing p generate a trace with pingpong, and replay itself, then check that output trace of the second run is the same as in the first (once sorted) -! setenv LD_LIBRARY_PATH=../../lib ! output sort $ ${bindir:=.}/../../../smpi_script/bin/smpirun -trace-ti --cfg=tracing/filename:out_in_ti.txt --cfg=smpi/simulate-computation:no -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning > diff --git a/teshsuite/smpi/pt2pt-pingpong/broken_hostfiles.tesh b/teshsuite/smpi/pt2pt-pingpong/broken_hostfiles.tesh index fe266ef04b..3629028f3e 100644 --- a/teshsuite/smpi/pt2pt-pingpong/broken_hostfiles.tesh +++ b/teshsuite/smpi/pt2pt-pingpong/broken_hostfiles.tesh @@ -1,4 +1,3 @@ -! setenv LD_LIBRARY_PATH=../../lib ! expect return 1 $ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile_empty -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -q --log=smpi_kernel.thres:warning > [smpirun] ** error: the hostfile '../hostfile_empty' is empty. Aborting. diff --git a/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.tesh b/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.tesh index 9bcbfa9970..6120d55019 100644 --- a/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.tesh +++ b/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.tesh @@ -1,5 +1,4 @@ p Test pingpong -! setenv LD_LIBRARY_PATH=../../lib ! output sort $ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning > *** Ping-pong test (MPI_Send/MPI_Recv) *** diff --git a/teshsuite/smpi/timers/timers.tesh b/teshsuite/smpi/timers/timers.tesh index 9726e7b82c..92448d179b 100644 --- a/teshsuite/smpi/timers/timers.tesh +++ b/teshsuite/smpi/timers/timers.tesh @@ -1,5 +1,4 @@ p Test timers -! setenv LD_LIBRARY_PATH=../../lib $ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 1 ${bindir:=.}/timers -q --log=smpi_kernel.thres:warning --cfg=smpi/simulate-computation:no --cfg=smpi/host-speed:100000 --log=xbt_cfg.thres:warning > [rank 0] -> Tremblay diff --git a/teshsuite/smpi/type-hvector/type-hvector.tesh b/teshsuite/smpi/type-hvector/type-hvector.tesh index 91bbe67d68..839186d9c2 100644 --- a/teshsuite/smpi/type-hvector/type-hvector.tesh +++ b/teshsuite/smpi/type-hvector/type-hvector.tesh @@ -1,5 +1,4 @@ p Test hvector -! setenv LD_LIBRARY_PATH=../../lib ! output sort $ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 2 ${bindir:=.}/type-hvector -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning > [rank 0] -> Tremblay diff --git a/teshsuite/smpi/type-indexed/type-indexed.tesh b/teshsuite/smpi/type-indexed/type-indexed.tesh index 9bf1d2ff09..933004363e 100644 --- a/teshsuite/smpi/type-indexed/type-indexed.tesh +++ b/teshsuite/smpi/type-indexed/type-indexed.tesh @@ -1,5 +1,4 @@ p Test indexed -! setenv LD_LIBRARY_PATH=../../lib ! output sort $ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 2 ${bindir:=.}/type-indexed -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning > [rank 0] -> Tremblay diff --git a/teshsuite/smpi/type-struct/type-struct.tesh b/teshsuite/smpi/type-struct/type-struct.tesh index 6340f9223b..f564cbb3b7 100644 --- a/teshsuite/smpi/type-struct/type-struct.tesh +++ b/teshsuite/smpi/type-struct/type-struct.tesh @@ -1,5 +1,4 @@ p Test struct -! setenv LD_LIBRARY_PATH=../../lib ! output sort $ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 2 ${bindir:=.}/type-struct -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning > [rank 0] -> Tremblay diff --git a/teshsuite/smpi/type-vector/type-vector.tesh b/teshsuite/smpi/type-vector/type-vector.tesh index 5b23a477e5..d756d2abe9 100644 --- a/teshsuite/smpi/type-vector/type-vector.tesh +++ b/teshsuite/smpi/type-vector/type-vector.tesh @@ -1,5 +1,4 @@ p Test vector -! setenv LD_LIBRARY_PATH=../../lib ! output sort $ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ${srcdir:=.}/../../../examples/platforms/small_platform.xml -np 2 ${bindir:=.}/type-vector -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning > [rank 0] -> Tremblay diff --git a/teshsuite/xbt/parmap_bench/parmap_bench.cpp b/teshsuite/xbt/parmap_bench/parmap_bench.cpp index 9f74d1cc5f..ce1262055c 100644 --- a/teshsuite/xbt/parmap_bench/parmap_bench.cpp +++ b/teshsuite/xbt/parmap_bench/parmap_bench.cpp @@ -9,12 +9,12 @@ #include #include -#include -#include #include // std::iota #include #include +XBT_LOG_NEW_DEFAULT_CATEGORY(parmap_bench, "Bench for parmap"); + #define MODES_DEFAULT 0x7 #define TIMEOUT 10.0 #define ARRAY_SIZE 10007 @@ -45,16 +45,6 @@ static std::string parmap_mode_name(e_xbt_parmap_mode_t mode) return name; } -static bool parmap_skip_mode(e_xbt_parmap_mode_t mode) -{ - if (mode == XBT_PARMAP_FUTEX && not HAVE_FUTEX_H) { - std::cout << "not available\n"; - return true; - } else { - return false; - } -} - static unsigned fibonacci(unsigned n) { if (n < 2) @@ -73,68 +63,46 @@ static void fun_big_comp(unsigned* arg) *arg = fibonacci(*arg % FIBO_MAX); } -static void bench_parmap_full(int nthreads, e_xbt_parmap_mode_t mode) +static void bench_parmap(int nthreads, e_xbt_parmap_mode_t mode, bool full_bench) { - std::cout << "** mode = " << std::left << std::setw(15) << parmap_mode_name(mode) << " "; - std::cout.flush(); - - if (parmap_skip_mode(mode)) - return; + XBT_INFO("** mode = %s", parmap_mode_name(mode).c_str()); - std::vector a(ARRAY_SIZE); - std::vector data(ARRAY_SIZE); - std::iota(begin(a), end(a), 0); - std::iota(begin(data), end(data), &a[0]); - - int i = 0; - double start_time = xbt_os_time(); - double elapsed_time; - do { - { - simgrid::xbt::Parmap parmap(nthreads, mode); - parmap.apply(fun_to_apply, data); - } // enclosing block to ensure that the parmap is destroyed here. - elapsed_time = xbt_os_time() - start_time; - i++; - } while (elapsed_time < TIMEOUT); - - std::cout << "ran " << i << " times in " << elapsed_time << " seconds (" << (i / elapsed_time) << "/s)\n"; -} - -static void bench_parmap_apply(int nthreads, e_xbt_parmap_mode_t mode) -{ - std::cout << "** mode = " << std::left << std::setw(15) << parmap_mode_name(mode) << " "; - std::cout.flush(); - - if (parmap_skip_mode(mode)) + if (mode == XBT_PARMAP_FUTEX && not HAVE_FUTEX_H) { + XBT_INFO(" not available"); return; + } std::vector a(ARRAY_SIZE); std::vector data(ARRAY_SIZE); std::iota(begin(a), end(a), 0); std::iota(begin(data), end(data), &a[0]); - simgrid::xbt::Parmap parmap(nthreads, mode); + auto* parmap = new simgrid::xbt::Parmap(nthreads, mode); int i = 0; double start_time = xbt_os_time(); double elapsed_time; do { - parmap.apply(fun_to_apply, data); + if (full_bench) { + delete parmap; + parmap = new simgrid::xbt::Parmap(nthreads, mode); + } + parmap->apply(fun_to_apply, data); elapsed_time = xbt_os_time() - start_time; i++; } while (elapsed_time < TIMEOUT); + delete parmap; - std::cout << "ran " << i << " times in " << elapsed_time << " seconds (" << (i / elapsed_time) << "/s)\n"; + XBT_INFO(" ran %d times in %g seconds (%g/s)", i, elapsed_time, i / elapsed_time); } -static void bench_all_modes(void (*bench_fun)(int, e_xbt_parmap_mode_t), int nthreads, unsigned modes) +static void bench_all_modes(int nthreads, unsigned modes, bool full_bench) { std::vector all_modes = {XBT_PARMAP_POSIX, XBT_PARMAP_FUTEX, XBT_PARMAP_BUSY_WAIT, XBT_PARMAP_DEFAULT}; for (unsigned i = 0; i < all_modes.size(); i++) { if (1U << i & modes) - bench_fun(nthreads, all_modes[i]); + bench_parmap(nthreads, all_modes[i], full_bench); } } @@ -143,44 +111,45 @@ int main(int argc, char* argv[]) int nthreads; unsigned modes = MODES_DEFAULT; + xbt_log_control_set("parmap_bench.fmt:[%c/%p]%e%m%n"); MSG_init(&argc, argv); if (argc != 2 && argc != 3) { - std::cerr << "Usage: " << argv[0] << " nthreads [modes]\n" - << " nthreads - number of working threads\n" - << " modes - bitmask of modes to test\n"; + XBT_INFO("Usage: %s nthreads [modes]", argv[0]); + XBT_INFO(" nthreads - number of working threads"); + XBT_INFO(" modes - bitmask of modes to test"); return EXIT_FAILURE; } nthreads = atoi(argv[1]); if (nthreads < 1) { - std::cerr << "ERROR: invalid thread count: " << nthreads << "\n"; + XBT_ERROR("Invalid thread count: %d", nthreads); return EXIT_FAILURE; } if (argc == 3) modes = strtol(argv[2], NULL, 0); - std::cout << "Parmap benchmark with " << nthreads << " workers (modes = " << std::hex << modes << std::dec - << ")...\n\n"; + XBT_INFO("Parmap benchmark with %d workers (modes = %#x)...", nthreads, modes); + XBT_INFO("%s", ""); fun_to_apply = &fun_small_comp; - std::cout << "Benchmark for parmap create+apply+destroy (small comp):\n"; - bench_all_modes(bench_parmap_full, nthreads, modes); - std::cout << std::endl; + XBT_INFO("Benchmark for parmap create+apply+destroy (small comp):"); + bench_all_modes(nthreads, modes, true); + XBT_INFO("%s", ""); - std::cout << "Benchmark for parmap apply only (small comp):\n"; - bench_all_modes(bench_parmap_apply, nthreads, modes); - std::cout << std::endl; + XBT_INFO("Benchmark for parmap apply only (small comp):"); + bench_all_modes(nthreads, modes, false); + XBT_INFO("%s", ""); fun_to_apply = &fun_big_comp; - std::cout << "Benchmark for parmap create+apply+destroy (big comp):\n"; - bench_all_modes(bench_parmap_full, nthreads, modes); - std::cout << std::endl; + XBT_INFO("Benchmark for parmap create+apply+destroy (big comp):"); + bench_all_modes(nthreads, modes, true); + XBT_INFO("%s", ""); - std::cout << "Benchmark for parmap apply only (big comp):\n"; - bench_all_modes(bench_parmap_apply, nthreads, modes); - std::cout << std::endl; + XBT_INFO("Benchmark for parmap apply only (big comp):"); + bench_all_modes(nthreads, modes, false); + XBT_INFO("%s", ""); return EXIT_SUCCESS; } diff --git a/teshsuite/xbt/parmap_test/parmap_test.cpp b/teshsuite/xbt/parmap_test/parmap_test.cpp index cfb1684f1c..e6e209c58a 100644 --- a/teshsuite/xbt/parmap_test/parmap_test.cpp +++ b/teshsuite/xbt/parmap_test/parmap_test.cpp @@ -83,6 +83,7 @@ static int test_parmap_extended(e_xbt_parmap_mode_t mode) int main(int argc, char** argv) { int status = 0; + xbt_log_control_set("parmap_test.fmt:[%c/%p]%e%m%n"); MSG_init(&argc, argv); XBT_INFO("Basic testing posix"); diff --git a/teshsuite/xbt/parmap_test/parmap_test.tesh b/teshsuite/xbt/parmap_test/parmap_test.tesh index d389a737f1..393329725b 100644 --- a/teshsuite/xbt/parmap_test/parmap_test.tesh +++ b/teshsuite/xbt/parmap_test/parmap_test.tesh @@ -1,5 +1,5 @@ ! timeout 120 -$ ${bindir:=.}/parmap_test --log=root.fmt:%m%n +$ ${bindir:=.}/parmap_test --log=parmap_test.fmt:%m%n > Basic testing posix > Basic testing futex > Basic testing busy wait diff --git a/tools/jenkins/Coverage.sh b/tools/jenkins/Coverage.sh index a8503ca934..cfe1ed1a34 100755 --- a/tools/jenkins/Coverage.sh +++ b/tools/jenkins/Coverage.sh @@ -60,7 +60,7 @@ make -j$NUMPROC JACOCO_PATH="/usr/local/share/jacoco" export JAVA_TOOL_OPTIONS="-javaagent:${JACOCO_PATH}/lib/jacocoagent.jar" -ctest -D ExperimentalTest -j$NUMPROC || true +ctest --no-compress-output -D ExperimentalTest -j$NUMPROC || true ctest -D ExperimentalCoverage || true unset JAVA_TOOL_OPTIONS diff --git a/tools/jenkins/DynamicAnalysis.sh b/tools/jenkins/DynamicAnalysis.sh index 9faa38b67a..53cbde797d 100755 --- a/tools/jenkins/DynamicAnalysis.sh +++ b/tools/jenkins/DynamicAnalysis.sh @@ -57,7 +57,7 @@ cmake -Denable_documentation=OFF -Denable_lua=OFF \ make -j$NUMPROC -ctest -D ExperimentalTest -j$NUMPROC || true +ctest --no-compress-output -D ExperimentalTest -j$NUMPROC || true cd $WORKSPACE/build if [ -f Testing/TAG ] ; then diff --git a/tools/jenkins/Sanitizers.sh b/tools/jenkins/Sanitizers.sh index d375d564f5..9c66b0dc7e 100755 --- a/tools/jenkins/Sanitizers.sh +++ b/tools/jenkins/Sanitizers.sh @@ -81,7 +81,7 @@ cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=OFF \ -Denable_fortran=OFF ${SANITIZER_OPTIONS} $WORKSPACE make -j$NUMPROC -ctest -D ExperimentalTest || true +ctest --no-compress-output -D ExperimentalTest || true if [ -f Testing/TAG ] ; then xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/$(head -n 1 < Testing/TAG)/Test.xml > CTestResults_${SANITIZER}.xml diff --git a/tools/sg_unit_extractor.pl b/tools/sg_unit_extractor.pl index e626e3d096..8b2083fffc 100755 --- a/tools/sg_unit_extractor.pl +++ b/tools/sg_unit_extractor.pl @@ -1,6 +1,6 @@ #! /usr/bin/env perl -# Copyright (c) 2005-2012, 2014. The SimGrid Team. All rights reserved. +# Copyright (c) 2005-2012, 2014-2017. The SimGrid Team. All rights reserved. # This program is free software; you can redistribute it and/or modify it # under the terms of the license (GNU LGPL) which comes with this package. @@ -126,6 +126,7 @@ sub process_one($) { print OUT "#include \n\n"; print OUT "#include \"xbt.h\"\n\n"; print OUT "extern xbt_test_unit_t _xbt_current_unit;\n\n"; + print OUT "#define STRLEN 1024\n"; print OUT "/* SGU: BEGIN PROTOTYPES */\n"; print OUT "/* SGU: END PROTOTYPES */\n\n"; print OUT $GENERATED; @@ -133,7 +134,7 @@ sub process_one($) { print OUT <