@@ -23,9 +23,13 @@ std::pair<int, int> TorusMeshCommunicator::CalculateGridSize(int totalProcesses)
2323 while (rows > 1 && (totalProcesses % rows != 0 )) {
2424 --rows;
2525 }
26- if (rows <= 0 ) rows = 1 ;
26+ if (rows <= 0 ) {
27+ rows = 1 ;
28+ }
2729 int cols = totalProcesses / rows;
28- if (cols <= 0 ) cols = 1 ;
30+ if (cols <= 0 ) {
31+ cols = 1 ;
32+ }
2933 return {rows, cols};
3034}
3135
@@ -83,16 +87,17 @@ std::vector<int> TorusMeshCommunicator::BuildMessageRoute(int rows, int cols, in
8387bool TorusMeshCommunicator::ValidationImpl () {
8488 int initialized = 0 ;
8589 MPI_Initialized (&initialized);
86- if (initialized == 0 ) return false ;
90+ if (initialized == 0 ) {
91+ return false ;
92+ }
8793
8894 MPI_Comm_rank (MPI_COMM_WORLD, ¤t_rank_);
8995 MPI_Comm_size (MPI_COMM_WORLD, &total_ranks_);
9096
9197 int valid = 0 ;
9298 if (current_rank_ == 0 ) {
9399 const auto &req = GetInput ();
94- if (req.sender >= 0 && req.receiver >= 0 &&
95- req.sender < total_ranks_ && req.receiver < total_ranks_) {
100+ if (req.sender >= 0 && req.receiver >= 0 && req.sender < total_ranks_ && req.receiver < total_ranks_) {
96101 valid = 1 ;
97102 }
98103 }
@@ -156,8 +161,7 @@ std::vector<int> TorusMeshCommunicator::AssembleSendBuffer(int src, int len) con
156161}
157162
158163void TorusMeshCommunicator::RelayMessage (int src, int dst, const std::vector<int > &route,
159- const std::vector<int > &buffer,
160- std::vector<int > &output) const {
164+ const std::vector<int > &buffer, std::vector<int > &output) const {
161165 const int route_len = static_cast <int >(route.size ());
162166 auto it = std::find (route.begin (), route.end (), current_rank_);
163167 bool on_route = (it != route.end ());
@@ -196,8 +200,7 @@ void TorusMeshCommunicator::RelayMessage(int src, int dst, const std::vector<int
196200 }
197201}
198202
199- void TorusMeshCommunicator::SaveFinalResult (int dst, const std::vector<int > &output,
200- const std::vector<int > &route) {
203+ void TorusMeshCommunicator::SaveFinalResult (int dst, const std::vector<int > &output, const std::vector<int > &route) {
201204 if (current_rank_ == dst) {
202205 local_response_.received_data = output;
203206 local_response_.route = route;
@@ -211,4 +214,4 @@ bool TorusMeshCommunicator::PostProcessingImpl() {
211214 return true ;
212215}
213216
214- } // namespace klimov_m_torus
217+ } // namespace klimov_m_torus
0 commit comments