From: Martin Quinson Date: Thu, 1 Dec 2016 21:10:47 +0000 (+0100) Subject: Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid X-Git-Tag: v3_14~132 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ea5ba71aa6e9e92becf2763c71c92fed3228c794?hp=185e5aa83f3cc2e8e99acc3e040aac6750a7c2e9 Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid --- diff --git a/include/simgrid/s4u/engine.hpp b/include/simgrid/s4u/engine.hpp index dc982073d1..395ea59060 100644 --- a/include/simgrid/s4u/engine.hpp +++ b/include/simgrid/s4u/engine.hpp @@ -18,6 +18,9 @@ #include namespace simgrid { +namespace kernel { +class EngineImpl; +} namespace s4u { /** @brief Simulation engine * @@ -86,6 +89,8 @@ public: }); } + simgrid::kernel::EngineImpl* pimpl; + private: static s4u::Engine *instance_; }; diff --git a/include/surf/surf_routing.h b/include/surf/surf_routing.h index 011ee929cd..d8f2dbc4bf 100644 --- a/include/surf/surf_routing.h +++ b/include/surf/surf_routing.h @@ -11,6 +11,8 @@ SG_BEGIN_DECL() +// FIXME: this header file should die + XBT_PUBLIC_DATA(int) SIMIX_STORAGE_LEVEL; //Simix storage level XBT_PUBLIC_DATA(xbt_lib_t) as_router_lib; diff --git a/src/kernel/EngineImpl.cpp b/src/kernel/EngineImpl.cpp new file mode 100644 index 0000000000..552b4b0de6 --- /dev/null +++ b/src/kernel/EngineImpl.cpp @@ -0,0 +1,21 @@ +/* Copyright (c) 2016. The SimGrid Team. All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#include "src/kernel/EngineImpl.hpp" +#include "src/kernel/routing/AsImpl.hpp" +#include + +namespace simgrid { +namespace kernel { + +EngineImpl::EngineImpl() +{ +} +EngineImpl::~EngineImpl() +{ + delete rootAs_; +} +} +} diff --git a/src/kernel/EngineImpl.hpp b/src/kernel/EngineImpl.hpp new file mode 100644 index 0000000000..750cb62b99 --- /dev/null +++ b/src/kernel/EngineImpl.hpp @@ -0,0 +1,25 @@ +/* Copyright (c) 2016. The SimGrid Team. All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#include +#include + +namespace simgrid { +namespace kernel { +namespace routing { +class AsImpl; +} + +class EngineImpl { +public: + EngineImpl(); + virtual ~EngineImpl(); + kernel::routing::AsImpl* rootAs_ = nullptr; + +protected: + friend simgrid::s4u::Engine; +}; +} +} diff --git a/src/s4u/s4u_engine.cpp b/src/s4u/s4u_engine.cpp index 4f3b10602a..f28ecadc4d 100644 --- a/src/s4u/s4u_engine.cpp +++ b/src/s4u/s4u_engine.cpp @@ -12,6 +12,8 @@ #include "simgrid/s4u/engine.hpp" #include "simgrid/s4u/Mailbox.hpp" #include "simgrid/s4u/storage.hpp" +#include "simgrid/simix.h" +#include "src/kernel/EngineImpl.hpp" #include "surf/surf.h" // routing_platf. FIXME:KILLME. SOON #include "src/surf/surf_routing.hpp" // routing_platf. FIXME:KILLME. SOON @@ -27,6 +29,7 @@ Engine *Engine::instance_ = nullptr; /* That singleton is awful, but I don't see Engine::Engine(int *argc, char **argv) { xbt_assert(s4u::Engine::instance_ == nullptr, "It is currently forbidden to create more than one instance of s4u::Engine"); s4u::Engine::instance_ = this; + pimpl = new kernel::EngineImpl(); TRACE_global_init(argc, argv); SIMIX_global_init(argc, argv); @@ -78,6 +81,7 @@ void Engine::run() { s4u::As *Engine::rootAs() { return routing_platf->root_; // FIXME: get the root into the Engine directly (and kill the platf) + // return pimpl->rootAs_; } static s4u::As *asByNameRecursive(s4u::As *current, const char *name) diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 6d6ba0c771..e1aecbce80 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -767,19 +767,16 @@ simgrid::s4u::As * sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS) break; } - - if (current_routing == nullptr && routing_platf->root_ == nullptr) { /* it is the first one */ + if (current_routing == nullptr) { /* it is the first one */ + xbt_assert(routing_platf->root_ == nullptr, "All defined components must belong to a AS"); routing_platf->root_ = new_as; - } else if (current_routing != nullptr && routing_platf->root_ != nullptr) { + } else { /* set the father behavior */ if (current_routing->hierarchy_ == simgrid::kernel::routing::AsImpl::RoutingMode::unset) current_routing->hierarchy_ = simgrid::kernel::routing::AsImpl::RoutingMode::recursive; /* add to the sons dictionary */ xbt_dict_set(current_routing->children(), AS->id, (void *) new_as, nullptr); - - } else { - THROWF(arg_error, 0, "All defined components must belong to a AS"); } /* set the new current component of the tree */ diff --git a/src/xbt/lib.c b/src/xbt/lib.c index 6709ed4a90..068652e41a 100644 --- a/src/xbt/lib.c +++ b/src/xbt/lib.c @@ -45,7 +45,7 @@ void xbt_lib_free(xbt_lib_t *plib) int xbt_lib_add_level(xbt_lib_t lib, void_f_pvoid_t free_f) { XBT_DEBUG("xbt_lib_add_level"); - xbt_assert(xbt_dict_is_empty(lib->dict), "Lib is not empty, cannot add a level"); + xbt_assert(xbt_dict_is_empty(lib->dict), "Lib is not empty (size: %u), cannot add a level", xbt_dict_size(lib->dict)); lib->free_f = xbt_realloc(lib->free_f, sizeof(void_f_pvoid_t) * (lib->levels + 1)); lib->free_f[lib->levels] = free_f; return lib->levels++; diff --git a/teshsuite/simdag/flatifier/flatifier.cpp b/teshsuite/simdag/flatifier/flatifier.cpp index 6035034bfd..d88fef02d4 100644 --- a/teshsuite/simdag/flatifier/flatifier.cpp +++ b/teshsuite/simdag/flatifier/flatifier.cpp @@ -149,14 +149,14 @@ int main(int argc, char **argv) sg_host_t host1, host2; for (unsigned int it_src = 0; it_src < totalHosts; it_src++) { // Routes from host host1 = hosts[it_src]; - value1 = sg_host_by_name(host1->name().c_str())->pimpl_netcard; + value1 = host1->pimpl_netcard; for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host host2 = hosts[it_dst]; std::vector *route = new std::vector(); value2 = host2->pimpl_netcard; - routing_platf->getRouteAndLatency(value1, value2, route,nullptr); + simgrid::kernel::routing::AsImpl::getGlobalRoute(value1, value2, route, nullptr); if (! route->empty()){ - std::printf(" \n ", host1->name().c_str(), host2->name().c_str()); + std::printf(" \n ", host1->cname(), host2->cname()); for (auto link: *route) std::printf("",link->getName()); std::printf("\n \n"); @@ -166,9 +166,9 @@ int main(int argc, char **argv) xbt_lib_foreach(as_router_lib, cursor_dst, dst, value2){ //to router value2 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL); if(value2->isRouter()){ - std::printf(" \n ", host1->name().c_str(), dst); + std::printf(" \n ", host1->cname(), dst); std::vector *route = new std::vector(); - routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,route,nullptr); + simgrid::kernel::routing::AsImpl::getGlobalRoute(value1, value2, route, nullptr); for (auto link : *route) std::printf("",link->getName()); delete route; @@ -185,7 +185,7 @@ int main(int argc, char **argv) if(value2->isRouter()){ std::printf(" \n ", src, dst); std::vector *route = new std::vector(); - routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,route,nullptr); + simgrid::kernel::routing::AsImpl::getGlobalRoute(value1, value2, route, nullptr); for(auto link :*route) std::printf("",link->getName()); delete route; @@ -194,10 +194,10 @@ int main(int argc, char **argv) } for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host host2 = hosts[it_dst]; - std::printf(" \n ",src, host2->name().c_str()); + std::printf(" \n ", src, host2->cname()); std::vector *route = new std::vector(); value2 = host2->pimpl_netcard; - routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,route, nullptr); + simgrid::kernel::routing::AsImpl::getGlobalRoute(value1, value2, route, nullptr); for(auto link : *route) std::printf("",link->getName()); delete route; diff --git a/teshsuite/surf/surf_usage/surf_usage.cpp b/teshsuite/surf/surf_usage/surf_usage.cpp index da0716fa38..11f4c7ee54 100644 --- a/teshsuite/surf/surf_usage/surf_usage.cpp +++ b/teshsuite/surf/surf_usage/surf_usage.cpp @@ -19,18 +19,18 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example"); static const char *string_action(simgrid::surf::Action::State state) { switch (state) { - case (simgrid::surf::Action::State::ready): - return "SURF_ACTION_READY"; - case (simgrid::surf::Action::State::running): - return "SURF_ACTION_RUNNING"; - case (simgrid::surf::Action::State::failed): - return "SURF_ACTION_FAILED"; - case (simgrid::surf::Action::State::done): - return "SURF_ACTION_DONE"; - case (simgrid::surf::Action::State::not_in_the_system): - return "SURF_ACTION_NOT_IN_THE_SYSTEM"; - default: - return "INVALID STATE"; + case simgrid::surf::Action::State::ready: + return "SURF_ACTION_READY"; + case simgrid::surf::Action::State::running: + return "SURF_ACTION_RUNNING"; + case simgrid::surf::Action::State::failed: + return "SURF_ACTION_FAILED"; + case simgrid::surf::Action::State::done: + return "SURF_ACTION_DONE"; + case simgrid::surf::Action::State::not_in_the_system: + return "SURF_ACTION_NOT_IN_THE_SYSTEM"; + default: + return "INVALID STATE"; } } @@ -41,7 +41,7 @@ int main(int argc, char **argv) xbt_cfg_set_parse("cpu/model:Cas01"); xbt_cfg_set_parse("network/model:CM02"); - xbt_assert(argc >1, "Usage : %s platform.txt\n", argv[0]); + xbt_assert(argc > 1, "Usage: %s platform.xml\n", argv[0]); parse_platform_file(argv[1]); XBT_DEBUG("CPU model: %p", surf_cpu_model_pm); @@ -54,10 +54,9 @@ int main(int argc, char **argv) simgrid::surf::Action *actionB = hostB->pimpl_cpu->execution_start(1000.0); simgrid::surf::Action *actionC = surf_host_sleep(hostB, 7.32); - /* Use whatever calling style you want... */ - simgrid::surf::Action::State stateActionA = actionA->getState(); /* When you know actionA model type */ - simgrid::surf::Action::State stateActionB = actionB->getState(); /* If you're unsure about it's model type */ - simgrid::surf::Action::State stateActionC = actionC->getState(); /* When you know actionA model type */ + simgrid::surf::Action::State stateActionA = actionA->getState(); + simgrid::surf::Action::State stateActionB = actionB->getState(); + simgrid::surf::Action::State stateActionC = actionC->getState(); /* And just look at the state of these tasks */ XBT_INFO("actionA state: %s", string_action(stateActionA)); diff --git a/teshsuite/surf/surf_usage2/surf_usage2.cpp b/teshsuite/surf/surf_usage2/surf_usage2.cpp index 1f7e1574e4..1b9d258869 100644 --- a/teshsuite/surf/surf_usage2/surf_usage2.cpp +++ b/teshsuite/surf/surf_usage2/surf_usage2.cpp @@ -25,7 +25,7 @@ int main(int argc, char **argv) xbt_cfg_set_parse("network/model:CM02"); xbt_cfg_set_parse("cpu/model:Cas01"); - xbt_assert(argc >1, "Usage : %s platform.txt\n", argv[0]); + xbt_assert(argc > 1, "Usage: %s platform.xml\n", argv[0]); parse_platform_file(argv[1]); /*********************** HOST ***********************************/ @@ -48,25 +48,25 @@ int main(int argc, char **argv) XBT_INFO("Next Event : %g", now); for (auto model: *all_existing_models) { - if (surf_model_running_action_set_size((surf_model_t)model)) { + if (surf_model_running_action_set_size(model)) { XBT_DEBUG("\t Running that model"); running = 1; } - action = surf_model_extract_failed_action_set(static_cast(model)); + action = surf_model_extract_failed_action_set(model); while (action != nullptr) { XBT_INFO(" * Done Action"); XBT_DEBUG("\t * Failed Action: %p", action); action->unref(); - action = surf_model_extract_failed_action_set(static_cast(model)); + action = surf_model_extract_failed_action_set(model); } - action = surf_model_extract_done_action_set(static_cast(model)); + action = surf_model_extract_done_action_set(model); while (action != nullptr){ XBT_INFO(" * Done Action"); XBT_DEBUG("\t * Done Action: %p", action); action->unref(); - action = surf_model_extract_done_action_set(static_cast(model)); + action = surf_model_extract_done_action_set(model); } } } while (running && surf_solve(-1.0) >= 0.0); diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 6d4b7f27a2..14884e6202 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -73,7 +73,7 @@ set(EXTRA_DIST src/kernel/routing/AsFull.hpp src/kernel/routing/AsRoutedGraph.hpp src/kernel/routing/AsNone.hpp - src/kernel/routing/AsVivaldi.hpp + src/kernel/routing/AsVivaldi.hpp src/surf/storage_interface.hpp src/surf/storage_n11.hpp @@ -305,7 +305,10 @@ set(SURF_SRC src/kernel/routing/AsRoutedGraph.cpp src/kernel/routing/AsNone.cpp src/kernel/routing/AsVivaldi.cpp - + + src/kernel/EngineImpl.cpp + src/kernel/EngineImpl.hpp + src/surf/cpu_cas01.cpp src/surf/cpu_interface.cpp src/surf/cpu_ti.cpp