From: degomme Date: Fri, 15 Jan 2016 13:47:42 +0000 (+0100) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr/gitroot/simgrid/simgrid X-Git-Tag: v3_13~1237 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6c6e9129b8c8a2404310f460327314afa3fb9b8b?hp=d16a0247f545e3d8a50921ad98b40f2d112e9840 Merge branch 'master' of git+ssh://scm.gforge.inria.fr/gitroot/simgrid/simgrid --- diff --git a/examples/s4u/basic/s4u_basic.cpp b/examples/s4u/basic/s4u_basic.cpp index 6bbfdecbd6..c1e3ca5181 100644 --- a/examples/s4u/basic/s4u_basic.cpp +++ b/examples/s4u/basic/s4u_basic.cpp @@ -44,8 +44,8 @@ int main(int argc, char **argv) { simgrid::s4u::Engine *e = new simgrid::s4u::Engine(&argc,argv); e->loadPlatform("../../platforms/two_hosts_platform.xml"); - new Worker("worker", simgrid::s4u::Host::byName("host0"), 0, NULL); - new Master("master", simgrid::s4u::Host::byName("host1"), 0, NULL); + new Worker("worker", simgrid::s4u::Host::by_name("host0"), 0, NULL); + new Master("master", simgrid::s4u::Host::by_name("host1"), 0, NULL); e->run(); return 0; } diff --git a/examples/s4u/io/s4u_io_test.cpp b/examples/s4u/io/s4u_io_test.cpp index 846ac4c735..0283cc797a 100644 --- a/examples/s4u/io/s4u_io_test.cpp +++ b/examples/s4u/io/s4u_io_test.cpp @@ -16,13 +16,13 @@ public: myHost(const char*procname, simgrid::s4u::Host *host,int argc, char **argv) : simgrid::s4u::Actor(procname,host,argc,argv){} - void show_info(boost::unordered_map &mounts) { + void show_info(boost::unordered_map &mounts) { XBT_INFO("Storage info on %s:", simgrid::s4u::Host::current()->name().c_str()); for (const auto&kv : mounts) { const char* mountpoint = kv.first.c_str(); - simgrid::s4u::Storage &storage = kv.second; + simgrid::s4u::Storage &storage = *kv.second; // Retrieve disk's information sg_size_t free_size = storage.size_free(); @@ -35,7 +35,7 @@ public: } int main(int argc, char **argv) { - boost::unordered_map &mounts = + boost::unordered_map & mounts = simgrid::s4u::Host::current()->mountedStorages(); show_info(mounts); @@ -109,7 +109,7 @@ int main(int argc, char **argv) { simgrid::s4u::Engine *e = new simgrid::s4u::Engine(&argc,argv); e->loadPlatform("../../platforms/storage/storage.xml"); - new myHost("host", simgrid::s4u::Host::byName("denise"), 0, NULL); + new myHost("host", simgrid::s4u::Host::by_name("denise"), 0, NULL); e->run(); return 0; } diff --git a/include/simgrid/s4u/host.hpp b/include/simgrid/s4u/host.hpp index 0de509fe02..fa24695481 100644 --- a/include/simgrid/s4u/host.hpp +++ b/include/simgrid/s4u/host.hpp @@ -16,14 +16,11 @@ #include #include +#include namespace simgrid { namespace s4u { -class Actor; -class Storage; -class File; - /** @brief Simulated machine that can host some actors * * It represents some physical resource with computing and networking capabilities. @@ -45,13 +42,13 @@ private: public: // TODO, make me private ~Host(); public: - /** Retrieves an host from its name. */ - static s4u::Host *byName(std::string name); - /** Retrieves the host on which the current actor is running */ - static s4u::Host *current(); static Host* by_name_or_null(const char* name); static Host* by_name_or_create(const char* name); + /** Retrieves an host from its name. */ + static s4u::Host *by_name(std::string name); + /** Retrieves the host on which the current actor is running */ + static s4u::Host *current(); simgrid::xbt::string const& name() const { return name_; } @@ -81,25 +78,17 @@ public: xbt_dict_t getMountedStorageList(); xbt_dynar_t getAttachedStorageList(); - /** Allows to store user data on that host */ - // TODO, use the extension stuff instead - void set_userdata(void *data) {p_userdata = data;} - /** Retrieves the previously stored data */ - void* userdata() {return p_userdata;} - /** Get an associative list [mount point]->[Storage] off all local mount points. * * This is defined in the platform file, and cannot be modified programatically (yet). * * Do not change the returned value in any way. */ - // TODO, do not use Storage&, this looks dangerous! - boost::unordered_map &mountedStorages(); + boost::unordered_map &mountedStorages(); private: simgrid::xbt::string name_ = "noname"; - boost::unordered_map *mounts = NULL; // caching - void* p_userdata = NULL; + boost::unordered_map *mounts = NULL; // caching public: // FIXME: these should be protected, but it leads to many errors @@ -108,8 +97,6 @@ public: surf::NetCard *pimpl_netcard = nullptr; public: - static boost::unordered_map *hosts; - /*** Called on each newly created object */ static simgrid::xbt::signal onCreation; /*** Called just before destructing an object */ diff --git a/src/mc/mc_smx.cpp b/src/mc/mc_smx.cpp index 0343dae79b..3468c0fe1d 100644 --- a/src/mc/mc_smx.cpp +++ b/src/mc/mc_smx.cpp @@ -196,7 +196,7 @@ const char* MC_smx_process_get_host_name(smx_process_t p) ~fake_host() {} }; fake_host foo; - const size_t offset = (char*) &foo.host.getName() - (char*) &foo.host; + const size_t offset = (char*) &foo.host.name() - (char*) &foo.host; // Read the simgrid::xbt::string in the MCed process: mc_smx_process_info_t info = MC_smx_process_get_info(p); diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 1753479708..8264fe5eb8 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -62,7 +62,7 @@ void s4u::Actor::setAutoRestart(bool autorestart) { } s4u::Host *s4u::Actor::getHost() { - return s4u::Host::byName(sg_host_get_name(simcall_process_get_host(p_smx_process))); + return s4u::Host::by_name(sg_host_get_name(simcall_process_get_host(p_smx_process))); } const char* s4u::Actor::getName() { return simcall_process_get_name(p_smx_process); diff --git a/src/s4u/s4u_host.cpp b/src/s4u/s4u_host.cpp index 9bab734630..c327312306 100644 --- a/src/s4u/s4u_host.cpp +++ b/src/s4u/s4u_host.cpp @@ -31,9 +31,6 @@ int USER_HOST_LEVEL; namespace simgrid { namespace s4u { -boost::unordered_map *Host::hosts - = new boost::unordered_map(); - simgrid::xbt::signal Host::onCreation; simgrid::xbt::signal Host::onDestruction; simgrid::xbt::signal Host::onStateChange; @@ -48,7 +45,7 @@ Host::~Host() { delete mounts; } -Host *Host::byName(std::string name) { +Host *Host::by_name(std::string name) { Host* host = Host::by_name_or_null(name.c_str()); // TODO, raise an exception instead? if (host == nullptr) @@ -79,9 +76,9 @@ int Host::getNbPStates() const { return this->pimpl_cpu->getNbPStates(); } -boost::unordered_map &Host::mountedStorages() { +boost::unordered_map &Host::mountedStorages() { if (mounts == NULL) { - mounts = new boost::unordered_map (); + mounts = new boost::unordered_map (); xbt_dict_t dict = this->getMountedStorageList(); @@ -89,7 +86,7 @@ boost::unordered_map &Host::mountedStorages() { char *mountname; char *storagename; xbt_dict_foreach(dict, cursor, mountname, storagename) { - mounts->insert({mountname, Storage::byName(storagename)}); + mounts->insert({mountname, &Storage::byName(storagename)}); } xbt_dict_free(&dict); } diff --git a/teshsuite/simdag/incomplete/incomplete.c b/teshsuite/simdag/incomplete/incomplete.c index 1d65c087d8..4f25f389e5 100644 --- a/teshsuite/simdag/incomplete/incomplete.c +++ b/teshsuite/simdag/incomplete/incomplete.c @@ -26,7 +26,6 @@ int main(int argc, char **argv) SD_task_t taskInit; SD_task_t taskA, taskB, taskC, taskD; - xbt_dynar_t ret; const SD_workstation_t *workstation; @@ -64,8 +63,7 @@ int main(int argc, char **argv) &communication_amount1, -1.0); - ret = SD_simulate(-1.); - xbt_dynar_free(&ret); + SD_simulate(-1.); SD_task_destroy(taskA); SD_task_destroy(taskB); SD_task_destroy(taskC); diff --git a/teshsuite/simdag/network/mxn/test_intra_scatter.c b/teshsuite/simdag/network/mxn/test_intra_scatter.c index 318cea382e..5b28563e65 100644 --- a/teshsuite/simdag/network/mxn/test_intra_scatter.c +++ b/teshsuite/simdag/network/mxn/test_intra_scatter.c @@ -26,7 +26,6 @@ int main(int argc, char **argv) { double time; SD_task_t task; - xbt_dynar_t ret; double communication_amount[] = { 0.0, 1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 0.0, @@ -47,8 +46,7 @@ int main(int argc, char **argv) SD_task_schedule(task, 4, SD_workstation_get_list(), no_cost, communication_amount, -1.0); - ret = SD_simulate(-1.0); - xbt_dynar_free(&ret); + SD_simulate(-1.0); time = SD_get_clock(); diff --git a/teshsuite/simdag/network/test_reinit_costs.c b/teshsuite/simdag/network/test_reinit_costs.c index bc73a2a827..584bd62c73 100644 --- a/teshsuite/simdag/network/test_reinit_costs.c +++ b/teshsuite/simdag/network/test_reinit_costs.c @@ -38,25 +38,21 @@ static void zero_cost_test(int *argc, char *argv[]) { double time; SD_task_t task; - xbt_dynar_t ret; SD_init(argc, argv); SD_create_environment(argv[1]); task = create_empty_cost_root(); - ret = SD_simulate(-1.0); - xbt_dynar_free(&ret); + SD_simulate(-1.0); SD_task_destroy(task); SD_application_reinit(); task = create_empty_cost_root(); - ret = SD_simulate(-1.0); - xbt_dynar_free(&ret); + SD_simulate(-1.0); SD_task_destroy(task); - ret = SD_simulate(-1.0); - xbt_dynar_free(&ret); + SD_simulate(-1.0); time = SD_get_clock(); printf("%g\n", time); @@ -82,25 +78,21 @@ static void zero_cost_test2(int *argc, char *argv[]) { double time; SD_task_t task; - xbt_dynar_t ret; SD_init(argc, argv); SD_create_environment(argv[1]); task = create_root_with_costs(); - ret = SD_simulate(-1.0); - xbt_dynar_free(&ret); + SD_simulate(-1.0); SD_task_destroy(task); SD_application_reinit(); task = create_empty_cost_root(); - ret = SD_simulate(-1.0); - xbt_dynar_free(&ret); + SD_simulate(-1.0); SD_task_destroy(task); - ret = SD_simulate(-1.0); - xbt_dynar_free(&ret); + SD_simulate(-1.0); time = SD_get_clock(); printf("%g\n", time); diff --git a/teshsuite/simdag/partask/test_comp_only_par.c b/teshsuite/simdag/partask/test_comp_only_par.c index ddae4693ab..53b823ffb7 100644 --- a/teshsuite/simdag/partask/test_comp_only_par.c +++ b/teshsuite/simdag/partask/test_comp_only_par.c @@ -17,7 +17,6 @@ int main(int argc, char **argv) double comp_cost[] = { 1.0, 1.0 }; SD_task_t task; - xbt_dynar_t ret; SD_init(&argc, argv); SD_create_environment(argv[1]); @@ -26,8 +25,7 @@ int main(int argc, char **argv) SD_task_schedule(task, 2, SD_workstation_get_list(), comp_cost, comm_amount, -1.0); - ret = SD_simulate(-1.0); - xbt_dynar_free(&ret); + SD_simulate(-1.0); time = SD_get_clock(); diff --git a/teshsuite/simdag/partask/test_comp_only_seq.c b/teshsuite/simdag/partask/test_comp_only_seq.c index 3b22157e58..875db675cc 100644 --- a/teshsuite/simdag/partask/test_comp_only_seq.c +++ b/teshsuite/simdag/partask/test_comp_only_seq.c @@ -17,7 +17,6 @@ int main(int argc, char **argv) double comp_cost[] = { 1.0 }; SD_task_t task; - xbt_dynar_t ret; SD_init(&argc, argv); SD_create_environment(argv[1]); @@ -26,8 +25,7 @@ int main(int argc, char **argv) SD_task_schedule(task, 1, SD_workstation_get_list(), comp_cost, comm_amount, -1.0); - ret = SD_simulate(-1.0); - xbt_dynar_free(&ret); + SD_simulate(-1.0); time = SD_get_clock(); diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index bfcf1b08da..ecda4a58b9 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -703,6 +703,7 @@ set(headers_to_install include/xbt/cunit.h include/xbt/dict.h include/xbt/string.hpp + include/xbt/signal.hpp include/xbt/dynar.h include/xbt/ex.h include/xbt/fifo.h