Commit af23d9e5 authored by Thomas Steinreiter's avatar Thomas Steinreiter
Browse files

* fixed clang-tidy warnings

parent 1dc02038
#include "CollectiveCommunicator.hpp" #include "CollectiveCommunicator.hpp"
void CollectiveCommunicator::Communicate(State* model) { void CollectiveCommunicator::Communicate(State* model) {
if (commDistGraph_ == MPI_COMM_NULL) if (commDistGraph_ == MPI_COMM_NULL) { MpiReportErrorAbort("Communicator not initialized"); }
MpiReportErrorAbort("Communicator not initialized");
MPI_Neighbor_alltoallw(model, // sendbuf MPI_Neighbor_alltoallw(model, // sendbuf
sizes_.data(), // sendcounts sizes_.data(), // sendcounts
...@@ -17,8 +16,7 @@ void CollectiveCommunicator::Communicate(State* model) { ...@@ -17,8 +16,7 @@ void CollectiveCommunicator::Communicate(State* model) {
} }
MpiRequest CollectiveCommunicator::AsyncCommunicate(State* model) { MpiRequest CollectiveCommunicator::AsyncCommunicate(State* model) {
if (commDistGraph_ == MPI_COMM_NULL) if (commDistGraph_ == MPI_COMM_NULL) { MpiReportErrorAbort("Communicator not initialized"); }
MpiReportErrorAbort("Communicator not initialized");
MPI_Request req; MPI_Request req;
MPI_Ineighbor_alltoallw(model, // sendbuf MPI_Ineighbor_alltoallw(model, // sendbuf
......
...@@ -5,11 +5,9 @@ ...@@ -5,11 +5,9 @@
#include "Communicator.hpp" #include "Communicator.hpp"
// defines types and graph topology // defines types and graph topology
Communicator::Communicator(const MpiEnvironment& env, const Size& procsSize, Communicator::Communicator(const MpiEnvironment& env, const Size& gridSize, const Size& tileSize) {
const Size& tileSize) {
// Begin definition of basic types // Begin definition of basic types
MPI_Type_contiguous(static_cast<int>(tileSize.Cols), MPI_CHAR, MPI_Type_contiguous(static_cast<int>(tileSize.Cols), MPI_CHAR, &haloRowType_);
&haloRowType_);
MPI_Type_commit(&haloRowType_); MPI_Type_commit(&haloRowType_);
MPI_Type_vector(static_cast<int>(tileSize.Rows), 1, static_cast<int>(tileSize.Cols + 2), MPI_CHAR, MPI_Type_vector(static_cast<int>(tileSize.Rows), 1, static_cast<int>(tileSize.Cols + 2), MPI_CHAR,
...@@ -29,9 +27,7 @@ Communicator::Communicator(const MpiEnvironment& env, const Size& procsSize, ...@@ -29,9 +27,7 @@ Communicator::Communicator(const MpiEnvironment& env, const Size& procsSize,
const auto tRows = tileSize.Rows; const auto tRows = tileSize.Rows;
// character coordinates to displacement // character coordinates to displacement
const auto dp = [&](std::size_t x, std::size_t y) { const auto dp = [&](std::size_t x, std::size_t y) { return static_cast<MPI_Aint>(y * (tCols + 2) + x); };
return static_cast<MPI_Aint>(y * (tCols + 2) + x);
};
const std::array<MPI_Aint, NoNeighbors> generalSendDisplacements{{ const std::array<MPI_Aint, NoNeighbors> generalSendDisplacements{{
dp(1, 1), dp(1, 1), dp(tCols, 1), // dp(1, 1), dp(1, 1), dp(tCols, 1), //
...@@ -56,16 +52,14 @@ Communicator::Communicator(const MpiEnvironment& env, const Size& procsSize, ...@@ -56,16 +52,14 @@ Communicator::Communicator(const MpiEnvironment& env, const Size& procsSize,
// border cases) // border cases)
const auto rank2coord = [&](std::size_t rank) { const auto rank2coord = [&](std::size_t rank) {
return Coord{ return Coord{
rank % procsSize.Cols, // rank % gridSize.Cols, //
rank / procsSize.Cols // rank / gridSize.Cols //
}; };
}; };
const auto coord2rank = [&](Coord c) { return static_cast<int>(procsSize.Cols * c.Y + c.X); }; const auto coord2rank = [&](Coord c) { return static_cast<int>(gridSize.Cols * c.Y + c.X); };
const auto isInsideProcsGrid = [&](Coord c) { const auto isInsideProcsGrid = [&](Coord c) { return c.X < gridSize.Cols && c.Y < gridSize.Rows; };
return c.X < procsSize.Cols && c.Y < procsSize.Rows;
};
const auto myCoord = rank2coord(env.worldRank()); const auto myCoord = rank2coord(env.worldRank());
const std::array<Coord, NoNeighbors> generalNeighborCoords{{ const std::array<Coord, NoNeighbors> generalNeighborCoords{{
...@@ -90,18 +84,17 @@ Communicator::Communicator(const MpiEnvironment& env, const Size& procsSize, ...@@ -90,18 +84,17 @@ Communicator::Communicator(const MpiEnvironment& env, const Size& procsSize,
} }
} }
MPI_Dist_graph_create_adjacent( MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, // comm_old
MPI_COMM_WORLD, // comm_old static_cast<int>(neighbors_.size()), // indegree
static_cast<int>(neighbors_.size()), // indegree neighbors_.data(), // sources
neighbors_.data(), // sources static_cast<int*>(MPI_UNWEIGHTED), // sourceweights
reinterpret_cast<int*>(MPI_UNWEIGHTED), // sourceweights static_cast<int>(neighbors_.size()), // outdegree
static_cast<int>(neighbors_.size()), // outdegree neighbors_.data(), // destinations
neighbors_.data(), // destinations static_cast<int*>(MPI_UNWEIGHTED), // destweights
reinterpret_cast<int*>(MPI_UNWEIGHTED), // destweights MPI_INFO_NULL, // info
MPI_INFO_NULL, // info 0, // reorder
0, // reorder &commDistGraph_ // comm_dist_graph
&commDistGraph_ // comm_dist_graph );
);
// End definition of datastructures for this particular cell // End definition of datastructures for this particular cell
} }
...@@ -126,9 +119,7 @@ void Communicator::swap(Communicator& first, Communicator& second) { ...@@ -126,9 +119,7 @@ void Communicator::swap(Communicator& first, Communicator& second) {
swap(first.haloCornerType_, second.haloCornerType_); swap(first.haloCornerType_, second.haloCornerType_);
} }
Communicator::Communicator(Communicator&& other) noexcept { Communicator::Communicator(Communicator&& other) noexcept { swap(*this, other); }
swap(*this, other);
}
Communicator& Communicator::operator=(Communicator&& other) noexcept { Communicator& Communicator::operator=(Communicator&& other) noexcept {
swap(*this, other); swap(*this, other);
return *this; return *this;
......
...@@ -16,14 +16,14 @@ std::istream& operator>>(std::istream& in, CommunicationMode& comm) { ...@@ -16,14 +16,14 @@ std::istream& operator>>(std::istream& in, CommunicationMode& comm) {
in >> buf; in >> buf;
const auto& str2comm = StringToCommunicationMode(); const auto& str2comm = StringToCommunicationMode();
auto r = std::find_if(std::begin(str2comm), std::end(str2comm), [&](auto& t) { return t.first == buf; }); auto r = std::find_if(std::begin(str2comm), std::end(str2comm), [&](auto& t) { return t.first == buf; });
if (r == std::end(str2comm)) if (r == std::end(str2comm)) {
throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value); throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value);
}
comm = r->second; comm = r->second;
return in; return in;
} }
auto Configuration::parseArgs(int argc, char* argv[], const MpiEnvironment& env) auto Configuration::parseArgs(int argc, char* argv[], const MpiEnvironment& env) -> Configuration {
-> Configuration {
namespace po = boost::program_options; namespace po = boost::program_options;
Configuration cfg; Configuration cfg;
...@@ -52,16 +52,13 @@ auto Configuration::parseArgs(int argc, char* argv[], const MpiEnvironment& env) ...@@ -52,16 +52,13 @@ auto Configuration::parseArgs(int argc, char* argv[], const MpiEnvironment& env)
.run(), .run(),
vm); vm);
if (vm.count("help") > 0 && env.isMaster()) { if (vm.count("help") > 0 && env.isMaster()) { std::cout << desc << "\n"; }
std::cout << desc << "\n";
}
po::notify(vm); po::notify(vm);
} catch (const po::error& err) { MpiReportErrorAbort(err.what()); } } catch (const po::error& err) { MpiReportErrorAbort(err.what()); }
// if no dimensions given, use MPI_Dims_create // if no dimensions given, use MPI_Dims_create
if (cfg.Procs.Cols < 1 || cfg.Procs.Rows < 1) { if (cfg.Procs.Cols < 1 || cfg.Procs.Rows < 1) {
std::array<int, 2> dims{{static_cast<int>(cfg.Procs.Cols), std::array<int, 2> dims{{static_cast<int>(cfg.Procs.Cols), static_cast<int>(cfg.Procs.Rows)}};
static_cast<int>(cfg.Procs.Rows)}};
MPI_Dims_create(static_cast<int>(env.worldSize()), // nnodes MPI_Dims_create(static_cast<int>(env.worldSize()), // nnodes
2, // ndims 2, // ndims
dims.data()); // dims dims.data()); // dims
...@@ -74,10 +71,9 @@ auto Configuration::parseArgs(int argc, char* argv[], const MpiEnvironment& env) ...@@ -74,10 +71,9 @@ auto Configuration::parseArgs(int argc, char* argv[], const MpiEnvironment& env)
const auto& totalCellCount = cfg.Procs.Cols * cfg.Procs.Rows; const auto& totalCellCount = cfg.Procs.Cols * cfg.Procs.Rows;
const auto& worldSize = env.worldSize(); const auto& worldSize = env.worldSize();
if (totalCellCount != static_cast<std::size_t>(worldSize)) { if (totalCellCount != static_cast<std::size_t>(worldSize)) {
MpiReportErrorAbort(boost::str( MpiReportErrorAbort(boost::str(boost::format("Total number of cells (%d) does not match "
boost::format("Total number of cells (%d) does not match " "the MPI World size (%d)") %
"the MPI World size (%d)") % totalCellCount % worldSize));
totalCellCount % worldSize));
} }
return cfg; return cfg;
} }
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#include "MpiEnvironment.hpp" #include "MpiEnvironment.hpp"
#include "MpiWireworld.hpp" #include "MpiWireworld.hpp"
using namespace std::string_literals;
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
const auto& starttime = std::chrono::system_clock::now(); const auto& starttime = std::chrono::system_clock::now();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment