{
if (comm == MPI_COMM_NULL) {
return MPI_ERR_COMM;
- } if ((sendbuf == nullptr && count > 0) || ((comm->rank() == root) && recvbuf == nullptr)) {
+ } else if ((sendbuf == nullptr && count > 0) || ((comm->rank() == root) && recvbuf == nullptr)) {
return MPI_ERR_BUFFER;
} else if (datatype == MPI_DATATYPE_NULL || not datatype->is_valid()){
return MPI_ERR_TYPE;
{
if (comm == MPI_COMM_NULL) {
return MPI_ERR_COMM;
- } if ((sendbuf == nullptr && count > 0) || (recvbuf == nullptr)) {
+ } else if ((sendbuf == nullptr && count > 0) || (recvbuf == nullptr)) {
return MPI_ERR_BUFFER;
} else if (datatype == MPI_DATATYPE_NULL || not datatype->is_valid()) {
return MPI_ERR_TYPE;
retval = MPI_ERR_ARG;
} else if (count < 0){
retval = MPI_ERR_COUNT;
+ } else if (sendbuf == nullptr || recvbuf == nullptr){
+ retval = MPI_ERR_BUFFER;
} else {
int rank = simgrid::s4u::this_actor::get_pid();
void* sendtmpbuf = sendbuf;
retval = MPI_ERR_ARG;
} else if (count < 0){
retval = MPI_ERR_COUNT;
+ } else if (sendbuf == nullptr || recvbuf == nullptr){
+ retval = MPI_ERR_BUFFER;
} else {
int rank = simgrid::s4u::this_actor::get_pid();
void* sendtmpbuf = sendbuf;
MPI_Datatype sendtmptype = sendtype;
if (sendbuf == MPI_IN_PLACE) {
sendtmpbuf = static_cast<void*>(xbt_malloc(recvcount * comm->size() * recvtype->size()));
- memcpy(sendtmpbuf, recvbuf, recvcount * comm->size() * recvtype->size());
+ //memcpy(??,nullptr,0) is actually undefined behavor, even if harmless.
+ if(recvbuf != nullptr)
+ memcpy(sendtmpbuf, recvbuf, recvcount * comm->size() * recvtype->size());
sendtmpcount = recvcount;
sendtmptype = recvtype;
}
smpi_trace_call_location_t trace_call_loc_;
s4u::ActorPtr actor_ = nullptr;
smpi_privatization_region_t privatized_region_ = nullptr;
- int optind = 1; /*for getopt replacement */
+#ifdef __linux__
+ int optind_ = 0; /*for getopt replacement */
+#else
+ int optind_ = 1; /*for getopt replacement */
+#endif
std::string tracing_category_ = "";
#if HAVE_PAPI
XBT_LOG_NEW_DEFAULT_CATEGORY(dsend,"the dsend test");
static void test_opts(int* argc, char **argv[]){
- int found = 0, ret;
+ int found = 0;
+ int ret;
int option_index = 0;
static struct option long_options[] = {
{"long", no_argument, 0, 0 },