Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / smpi / bindings / smpi_pmpi_request.cpp
index dc9f48e..1ff4577 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -138,7 +138,7 @@ int PMPI_Startall(int count, MPI_Request * requests)
       TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Startall"));
       if (not TRACE_smpi_view_internals())
         for (int i = 0; i < count; i++) {
-          MPI_Request req = requests[i];
+          const simgrid::smpi::Request* req = requests[i];
           if (req->flags() & MPI_REQ_SEND)
             TRACE_smpi_send(my_proc_id, my_proc_id, getPid(req->comm(), req->dst()), req->tag(), req->size());
         }
@@ -147,7 +147,7 @@ int PMPI_Startall(int count, MPI_Request * requests)
 
       if (not TRACE_smpi_view_internals())
         for (int i = 0; i < count; i++) {
-          MPI_Request req = requests[i];
+          const simgrid::smpi::Request* req = requests[i];
           if (req->flags() & MPI_REQ_RECV)
             TRACE_smpi_recv(getPid(req->comm(), req->src()), my_proc_id, req->tag());
         }
@@ -427,8 +427,8 @@ int PMPI_Sendrecv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, int
     int src_traced         = getPid(comm, src);
 
     // FIXME: Hack the way to trace this one
-    std::vector<int>* dst_hack = new std::vector<int>();
-    std::vector<int>* src_hack = new std::vector<int>();
+    auto* dst_hack = new std::vector<int>();
+    auto* src_hack = new std::vector<int>();
     dst_hack->push_back(dst_traced);
     src_hack->push_back(src_traced);
     TRACE_smpi_comm_in(my_proc_id, __func__,
@@ -461,12 +461,12 @@ int PMPI_Sendrecv_replace(void* buf, int count, MPI_Datatype datatype, int dst,
 
   int size = datatype->get_extent() * count;
   xbt_assert(size > 0);
-  void* recvbuf = xbt_new0(char, size);
-  retval = MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count, datatype, src, recvtag, comm, status);
+  std::vector<char> recvbuf(size);
+  retval =
+      MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf.data(), count, datatype, src, recvtag, comm, status);
   if(retval==MPI_SUCCESS){
-    simgrid::smpi::Datatype::copy(recvbuf, count, datatype, buf, count, datatype);
+    simgrid::smpi::Datatype::copy(recvbuf.data(), count, datatype, buf, count, datatype);
   }
-  xbt_free(recvbuf);
   return retval;
 }
 
@@ -588,10 +588,9 @@ int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* statu
 }
 
 // TODO: cheinrich: Move declaration to other file? Rename this function - it's used for PMPI_Wait*?
-static void trace_smpi_recv_helper(MPI_Request* request, MPI_Status* status);
 static void trace_smpi_recv_helper(MPI_Request* request, MPI_Status* status)
 {
-  MPI_Request req = *request;
+  const simgrid::smpi::Request* req = *request;
   if (req != MPI_REQUEST_NULL) { // Received requests become null
     int src_traced = req->src();
     // the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
@@ -620,7 +619,7 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status)
     MPI_Request savedreq = *request;
     if (savedreq != MPI_REQUEST_NULL && not(savedreq->flags() & MPI_REQ_FINISHED)
     && not(savedreq->flags() & MPI_REQ_GENERALIZED))
-      savedreq->ref();//don't erase te handle in Request::wait, we'll need it later
+      savedreq->ref();//don't erase the handle in Request::wait, we'll need it later
     else
       savedreq = MPI_REQUEST_NULL;
 
@@ -779,7 +778,7 @@ int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status)
     *flag=1;
     simgrid::smpi::Status::empty(status);
     return MPI_SUCCESS;
-  } else if (flag==NULL || status ==NULL){
+  } else if (flag == nullptr || status == nullptr) {
     return MPI_ERR_ARG;
   }
   return simgrid::smpi::Request::get_status(request,flag,status);
@@ -788,7 +787,7 @@ int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status)
 MPI_Request PMPI_Request_f2c(MPI_Fint request){
   if(request==-1)
     return MPI_REQUEST_NULL;
-  return static_cast<MPI_Request>(simgrid::smpi::Request::f2c(request));
+  return simgrid::smpi::Request::f2c(request);
 }
 
 MPI_Fint PMPI_Request_c2f(MPI_Request request) {