Skip to content

Commit d58f075

Browse files
committed
debug: some debug output for MPI communication
Signed-off-by: Torbjörn Klatt <[email protected]>
1 parent 6086c29 commit d58f075

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

src/pfasst/encap/vector_impl.hpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ namespace pfasst
3939
{
4040
#ifdef WITH_MPI
4141
if (this->send_request != MPI_REQUEST_NULL) {
42-
MPI_Status stat;
42+
MPI_Status stat = MPI_Status_factory();
43+
CLOG(DEBUG, "Encap") << "waiting for open send request";
4344
int err = MPI_Wait(&(this->send_request), &stat);
4445
check_mpi_error(err);
46+
CLOG(DEBUG, "Encap") << "waited for open send request";
4547
}
4648
assert(this->recv_request == MPI_REQUEST_NULL);
4749
assert(this->send_request == MPI_REQUEST_NULL);
@@ -191,9 +193,11 @@ namespace pfasst
191193
}
192194

193195
int src = (mpi.rank() - 1) % mpi.size();
196+
CLOG(DEBUG, "Encap") << "non-blocking recieving from rank " << src << " with tag=" << tag;
194197
int err = MPI_Irecv(this->data(), sizeof(scalar) * this->size(), MPI_CHAR,
195-
src, tag, mpi.comm, &this->recv_request);
198+
src, tag, mpi.comm, &this->recv_request);
196199
check_mpi_error(err);
200+
CLOG(DEBUG, "Encap") << "non-blocking recieved from rank " << src << " with tag=" << tag;
197201
}
198202

199203
template<typename scalar, typename time>
@@ -208,15 +212,17 @@ namespace pfasst
208212

209213
if (blocking) {
210214
int src = (mpi.rank() - 1) % mpi.size();
215+
CLOG(DEBUG, "Encap") << "blocking recieve from rank " << src << " with tag=" << tag;
211216
err = MPI_Recv(this->data(), sizeof(scalar) * this->size(), MPI_CHAR,
212217
src, tag, mpi.comm, &stat);
213218
check_mpi_error(err);
219+
CLOG(DEBUG, "Encap") << "recieved blocking from rank " << src << " with tag=" << tag << ": " << stat;
214220
} else {
215221
if (this->recv_request != MPI_REQUEST_NULL) {
216-
CLOG(DEBUG, "Encap") << "waiting on last recv request";
222+
CLOG(DEBUG, "Encap") << "waiting on last recieve request";
217223
err = MPI_Wait(&(this->recv_request), &stat);
218224
check_mpi_error(err);
219-
CLOG(DEBUG, "Encap") << "waiting done: " << stat;
225+
CLOG(DEBUG, "Encap") << "waited on last recieve request: " << stat;
220226
}
221227
}
222228
}
@@ -233,24 +239,33 @@ namespace pfasst
233239
int dest = (mpi.rank() + 1) % mpi.size();
234240

235241
if (blocking) {
242+
CLOG(DEBUG, "Encap") << "blocking send to rank " << dest << " with tag=" << tag;
236243
err = MPI_Send(this->data(), sizeof(scalar) * this->size(), MPI_CHAR, dest, tag, mpi.comm);
237244
check_mpi_error(err);
245+
CLOG(DEBUG, "Encap") << "sent blocking to rank " << dest << " with tag=" << tag;
238246
} else {
247+
// got never in here
248+
CLOG(DEBUG, "Encap") << "waiting on last send request to finish";
239249
err = MPI_Wait(&(this->send_request), &stat);
240250
check_mpi_error(err);
251+
CLOG(DEBUG, "Encap") << "waited on last send request: " << stat;
252+
CLOG(DEBUG, "Encap") << "non-blocking sending to rank " << dest << " with tag=" << tag;
241253
err = MPI_Isend(this->data(), sizeof(scalar) * this->size(), MPI_CHAR,
242254
dest, tag, mpi.comm, &(this->send_request));
243255
check_mpi_error(err);
256+
CLOG(DEBUG, "Encap") << "sent non-blocking to rank " << dest << " with tag=" << tag;
244257
}
245258
}
246259

247260
template<typename scalar, typename time>
248261
void VectorEncapsulation<scalar, time>::broadcast(ICommunicator* comm)
249262
{
250263
auto& mpi = as_mpi(comm);
264+
CLOG(DEBUG, "Encap") << "broadcasting";
251265
int err = MPI_Bcast(this->data(), sizeof(scalar) * this->size(), MPI_CHAR,
252266
comm->size()-1, mpi.comm);
253267
check_mpi_error(err);
268+
CLOG(DEBUG, "Encap") << "broadcasted";
254269
}
255270
#endif
256271

src/pfasst/mpi_communicator_impl.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ namespace pfasst
110110
int iconverged = converged.at(mpi->rank()) ? IStatus::CONVERGED : IStatus::NOT_CONVERGED;
111111
int dest_rank = (mpi->rank() + 1) % mpi->size();
112112

113+
CLOG(DEBUG, "Controller") << "sending converged status to rank " << dest_rank << " with tag '1': " << ((bool)iconverged == IStatus::CONVERGED);
113114
int err = MPI_Send(&iconverged, sizeof(int), MPI_INT, dest_rank, 1, mpi->comm);
114115
check_mpi_error(err);
116+
CLOG(DEBUG, "Controller") << "sent converged status";
115117
}
116118

117119
void MPIStatus::recv()
@@ -121,15 +123,17 @@ namespace pfasst
121123
if (mpi->rank() == 0) { return; }
122124

123125
if (get_converged(mpi->rank() - 1)) {
124-
CLOG(DEBUG, "Controller") << "skipping status recv as previous is stored as converged";
126+
CLOG(DEBUG, "Controller") << "skipping status recieve as previous is stored as converged";
125127
return;
126128
}
127129

128-
MPI_Status stat;
129-
int iconverged;
130+
MPI_Status stat = MPI_Status_factory();
131+
int iconverged = IStatus::NOT_CONVERGED;
130132
int src_rank = (mpi->rank() - 1) % mpi->size();
133+
CLOG(DEBUG, "Controller") << "recieving converged status from rank " << src_rank << " with tag '1'";
131134
int err = MPI_Recv(&iconverged, sizeof(iconverged), MPI_INT, src_rank, 1, mpi->comm, &stat);
132135
check_mpi_error(err);
136+
CLOG(DEBUG, "Controller") << "recieved converged status from rank " << src_rank << " with tag '1': " << ((bool)iconverged == IStatus::CONVERGED);
133137

134138
converged.at(mpi->rank() - 1) = (iconverged == IStatus::CONVERGED) ? true : false;
135139
}

0 commit comments

Comments
 (0)