123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- /**
- * @file tests/mpi/cluster/main.cpp
- * @author The PARADEVS Development Team
- * See the AUTHORS or Authors.txt file
- */
- /*
- * PARADEVS - the multimodeling and simulation environment
- * This file is a part of the PARADEVS environment
- *
- * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include <paradevs/common/RootCoordinator.hpp>
- #include <boost/mpi/environment.hpp>
- #include <boost/mpi/communicator.hpp>
- #include <paradevs/common/time/DoubleTime.hpp>
- #include <paradevs/kernel/pdevs/mpi/LogicalProcessor.hpp>
- #include <tests/mpi/cluster/graph_manager.hpp>
- #include <chrono>
- using namespace paradevs::tests::mpi::cluster;
- using namespace paradevs::common;
- using namespace boost::mpi;
- using namespace std::chrono;
- void example_simple(int argc, char *argv[])
- {
- environment env(argc, argv);
- communicator world;
- std::cout << "START " << world.rank() << std::endl;
-
- if (world.rank() == 0) {
- paradevs::tests::mpi::cluster::RootGraphManagerParameters parameters;
- parameters.ranks.push_back(1);
- parameters.ranks.push_back(2);
- parameters.ranks.push_back(3);
- parameters.ranks.push_back(4);
- parameters.ranks.push_back(5);
- parameters.ranks.push_back(6);
- parameters.ranks.push_back(7);
- parameters.ranks.push_back(8);
- paradevs::common::RootCoordinator <
- DoubleTime,
- paradevs::pdevs::Coordinator <
- DoubleTime,
- paradevs::tests::mpi::cluster::RootGraphManager,
- paradevs::common::NoParameters,
- paradevs::tests::mpi::cluster::RootGraphManagerParameters >
- > rc(0, 10, "root", paradevs::common::NoParameters(), parameters);
- steady_clock::time_point t1 = steady_clock::now();
- rc.run();
- steady_clock::time_point t2 = steady_clock::now();
- duration < double > time_span = duration_cast <
- duration < double > >(t2 - t1);
- std::cout << "time = " << time_span.count() << std::endl;
- } else {
- std::stringstream ss;
- ss << "S" << world.rank();
- paradevs::pdevs::mpi::Coordinator <
- DoubleTime,
- paradevs::tests::mpi::cluster::SubGraphManager >
- model(ss.str(), paradevs::common::NoParameters(),
- paradevs::common::NoParameters());
- paradevs::pdevs::mpi::LogicalProcessor <
- DoubleTime > LP(&model, world.rank(), 0);
-
- model.set_logical_processor(&LP);
- LP.loop();
- }
- }
- int main(int argc, char *argv[])
- {
- example_simple(argc, argv);
- return 0;
- }
|