#define CHECK_ARGS(test, errcode, ...) \
if (test) { \
XBT_WARN(__VA_ARGS__); \
- return errcode; \
+ return (errcode); \
}
/* PMPI User level calls */
{
if (comm == MPI_COMM_NULL)
return MPI_ERR_COMM;
- if ((sendbuf == nullptr && sendcount > 0) || (recvbuf == nullptr))
+ if (sendbuf == nullptr && sendcount > 0)
return MPI_ERR_BUFFER;
if (((sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) || (recvtype == MPI_DATATYPE_NULL))
return MPI_ERR_TYPE;
if (request == nullptr)
return MPI_ERR_ARG;
- for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free
+ for (int i = 0; i < comm->size(); i++) {
if (recvcounts[i] < 0)
return MPI_ERR_COUNT;
+ else if (recvcounts[i] > 0 && recvbuf == nullptr)
+ return MPI_ERR_BUFFER;
}
smpi_bench_end();
std::unique_ptr<unsigned char[]> tmp_sendbuf;
if (sendbuf == MPI_IN_PLACE) {
tmp_sendbuf.reset(new unsigned char[recvcount * comm->size() * recvtype->size()]);
- // memcpy(??,nullptr,0) is actually undefined behavor, even if harmless.
+ // memcpy(??,nullptr,0) is actually undefined behavior, even if harmless.
if (recvbuf != nullptr)
memcpy(tmp_sendbuf.get(), recvbuf, recvcount * comm->size() * recvtype->size());
real_sendbuf = tmp_sendbuf.get();
smpi_bench_end();
int rank = simgrid::s4u::this_actor::get_pid();
int size = comm->size();
- for (int i = 0; i < size; i++) { // copy data to avoid bad free
+ for (int i = 0; i < size; i++) {
if (recvcounts[i] < 0 || (sendbuf != MPI_IN_PLACE && sendcounts[i] < 0))
return MPI_ERR_COUNT;
}