main.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /**
  2. * @file tests/mpi/cluster/main.cpp
  3. * @author The PARADEVS Development Team
  4. * See the AUTHORS or Authors.txt file
  5. */
  6. /*
  7. * PARADEVS - the multimodeling and simulation environment
  8. * This file is a part of the PARADEVS environment
  9. *
  10. * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. #include <paradevs/common/RootCoordinator.hpp>
  26. #include <boost/mpi/environment.hpp>
  27. #include <boost/mpi/communicator.hpp>
  28. #include <paradevs/common/time/DoubleTime.hpp>
  29. #include <paradevs/kernel/pdevs/mpi/LogicalProcessor.hpp>
  30. #include <tests/mpi/cluster/graph_manager.hpp>
  31. #include <chrono>
  32. using namespace paradevs::tests::mpi::cluster;
  33. using namespace paradevs::common;
  34. using namespace boost::mpi;
  35. using namespace std::chrono;
  36. void example_simple(int argc, char *argv[])
  37. {
  38. environment env(argc, argv);
  39. communicator world;
  40. std::cout << "START " << world.rank() << std::endl;
  41. if (world.rank() == 0) {
  42. paradevs::tests::mpi::cluster::RootGraphManagerParameters parameters;
  43. parameters.ranks.push_back(1);
  44. parameters.ranks.push_back(2);
  45. parameters.ranks.push_back(3);
  46. parameters.ranks.push_back(4);
  47. parameters.ranks.push_back(5);
  48. parameters.ranks.push_back(6);
  49. parameters.ranks.push_back(7);
  50. parameters.ranks.push_back(8);
  51. paradevs::common::RootCoordinator <
  52. DoubleTime,
  53. paradevs::pdevs::Coordinator <
  54. DoubleTime,
  55. paradevs::tests::mpi::cluster::RootGraphManager,
  56. paradevs::common::NoParameters,
  57. paradevs::tests::mpi::cluster::RootGraphManagerParameters >
  58. > rc(0, 10, "root", paradevs::common::NoParameters(), parameters);
  59. steady_clock::time_point t1 = steady_clock::now();
  60. rc.run();
  61. steady_clock::time_point t2 = steady_clock::now();
  62. duration < double > time_span = duration_cast <
  63. duration < double > >(t2 - t1);
  64. std::cout << "time = " << time_span.count() << std::endl;
  65. } else {
  66. std::stringstream ss;
  67. ss << "S" << world.rank();
  68. paradevs::pdevs::mpi::Coordinator <
  69. DoubleTime,
  70. paradevs::tests::mpi::cluster::SubGraphManager >
  71. model(ss.str(), paradevs::common::NoParameters(),
  72. paradevs::common::NoParameters());
  73. paradevs::pdevs::mpi::LogicalProcessor <
  74. DoubleTime > LP(&model, world.rank(), 0);
  75. model.set_logical_processor(&LP);
  76. LP.loop();
  77. }
  78. }
  79. int main(int argc, char *argv[])
  80. {
  81. example_simple(argc, argv);
  82. return 0;
  83. }