- int retval = 0;
- if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (sendbuf == nullptr || recvbuf == nullptr) {
- retval = MPI_ERR_BUFFER;
- } else if ((sendbuf != MPI_IN_PLACE && sendtype == MPI_DATATYPE_NULL) || recvtype == MPI_DATATYPE_NULL) {
- retval = MPI_ERR_TYPE;
- } else if ((sendbuf != MPI_IN_PLACE && (sendcounts == nullptr || senddisps == nullptr)) || recvcounts == nullptr ||
- recvdisps == nullptr) {
- retval = MPI_ERR_ARG;
- } else if (request == nullptr){
- retval = MPI_ERR_ARG;
- } else {
- int rank = simgrid::s4u::this_actor::get_pid();
- int size = comm->size();
- for (int i = 0; i < size; i++) {
- if (recvcounts[i] <0 || (sendbuf != MPI_IN_PLACE && sendcounts[i]<0))
- return MPI_ERR_COUNT;
- }
- smpi_bench_end();
- int send_size = 0;
- int recv_size = 0;
- std::vector<int>* trace_sendcounts = new std::vector<int>;
- std::vector<int>* trace_recvcounts = new std::vector<int>;
- int dt_size_recv = recvtype->size();
-
- void* sendtmpbuf = static_cast<char*>(sendbuf);
- int* sendtmpcounts = sendcounts;
- int* sendtmpdisps = senddisps;
- MPI_Datatype sendtmptype = sendtype;
- int maxsize = 0;
- for (int i = 0; i < size; i++) { // copy data to avoid bad free
- recv_size += recvcounts[i] * dt_size_recv;
- trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
- if (((recvdisps[i] + recvcounts[i]) * dt_size_recv) > maxsize)
- maxsize = (recvdisps[i] + recvcounts[i]) * dt_size_recv;
- }
-
- if (sendbuf == MPI_IN_PLACE) {
- sendtmpbuf = static_cast<void*>(xbt_malloc(maxsize));
- memcpy(sendtmpbuf, recvbuf, maxsize);
- sendtmpcounts = static_cast<int*>(xbt_malloc(size * sizeof(int)));
- memcpy(sendtmpcounts, recvcounts, size * sizeof(int));
- sendtmpdisps = static_cast<int*>(xbt_malloc(size * sizeof(int)));
- memcpy(sendtmpdisps, recvdisps, size * sizeof(int));
- sendtmptype = recvtype;
+ CHECK_COMM(9)
+ if(sendbuf != MPI_IN_PLACE){
+ CHECK_NULL(2, MPI_ERR_COUNT, sendcounts)
+ CHECK_NULL(3, MPI_ERR_ARG, senddispls)
+ CHECK_TYPE(4, sendtype)
+ }
+ CHECK_TYPE(8, recvtype)
+ CHECK_NULL(6, MPI_ERR_COUNT, recvcounts)
+ CHECK_NULL(7, MPI_ERR_ARG, recvdispls)
+ CHECK_REQUEST(10)
+
+ int rank = simgrid::s4u::this_actor::get_pid();
+ int size = comm->size();
+ for (int i = 0; i < size; i++) {
+ if(sendbuf != MPI_IN_PLACE){
+ CHECK_BUFFER(1, sendbuf, sendcounts[i])
+ CHECK_COUNT(2, sendcounts[i])