Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill all trailling whitespaces
[simgrid.git] / src / smpi / smpi_win.cpp
index 3653491..5d83d8c 100644 (file)
@@ -1,11 +1,17 @@
-/* Copyright (c) 2007-2017. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2007-2017. 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. */
 
-#include "private.h"
-#include <vector>
+#include "src/smpi/private.h"
+#include "src/smpi/smpi_coll.hpp"
+#include "src/smpi/smpi_comm.hpp"
+#include "src/smpi/smpi_datatype.hpp"
+#include "src/smpi/smpi_info.hpp"
+#include "src/smpi/smpi_keyvals.hpp"
+#include "src/smpi/smpi_process.hpp"
+#include "src/smpi/smpi_request.hpp"
+#include "src/smpi/smpi_win.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_rma, smpi, "Logging specific to SMPI (RMA operations)");
 
@@ -78,7 +84,7 @@ Win::~Win(){
 }
 
 int Win::attach (void *base, MPI_Aint size){
-  if (!(base_ == MPI_BOTTOM || base_ == 0))
+  if (not(base_ == MPI_BOTTOM || base_ == 0))
     return MPI_ERR_ARG;
   base_=0;//actually the address will be given in the RMA calls, as being the disp.
   size_+=size;
@@ -270,7 +276,7 @@ int Win::get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype,
         comm_->group()->index(target_rank), smpi_process()->index(), SMPI_RMA_TAG+2, comm_,
         MPI_OP_NULL);
 
-    //start the send, with another process than us as sender. 
+    //start the send, with another process than us as sender.
     sreq->start();
     //push request to receiver's win
     xbt_mutex_acquire(send_win->mut_);
@@ -314,7 +320,7 @@ int Win::accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da
     if(locked != 1)
       return MPI_ERR_WIN;
   }
-  //FIXME: local version 
+  //FIXME: local version
 
   if(target_count*target_datatype->get_extent()>recv_win->size_)
     return MPI_ERR_ARG;
@@ -352,8 +358,8 @@ int Win::accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da
   return MPI_SUCCESS;
 }
 
-int Win::get_accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr, 
-              int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count, 
+int Win::get_accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
+              int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
               MPI_Datatype target_datatype, MPI_Op op, MPI_Request* request){
 
   //get sender pointer
@@ -413,7 +419,7 @@ int Win::compare_and_swap(void *origin_addr, void *compare_addr,
               target_disp, 1, datatype, &req);
   if (req != MPI_REQUEST_NULL)
     Request::wait(&req, MPI_STATUS_IGNORE);
-  if(! memcmp (result_addr, compare_addr, datatype->get_extent() )){
+  if (not memcmp(result_addr, compare_addr, datatype->get_extent())) {
     put(origin_addr, 1, datatype, target_rank,
               target_disp, 1, datatype);
   }
@@ -567,8 +573,8 @@ int Win::lock(int lock_type, int rank, int assert){
     if(lock_type == MPI_LOCK_SHARED){//the window used to be exclusive, it's now shared.
       xbt_mutex_release(target_win->lock_mut_);
    }
-  } else if(!(target_win->mode_==MPI_LOCK_SHARED && lock_type == MPI_LOCK_EXCLUSIVE))
-        target_win->mode_+= lock_type; // don't set to exclusive if it's already shared
+  } else if (not(target_win->mode_ == MPI_LOCK_SHARED && lock_type == MPI_LOCK_EXCLUSIVE))
+    target_win->mode_ += lock_type; // don't set to exclusive if it's already shared
 
   target_win->lockers_.push_back(comm_->rank());
 
@@ -676,22 +682,21 @@ int Win::finish_comms(int rank){
   int size = static_cast<int>(reqqs->size());
   if (size > 0) {
     size = 0;
-    std::vector<MPI_Request>* myreqqs = new std::vector<MPI_Request>();
+    std::vector<MPI_Request> myreqqs;
     std::vector<MPI_Request>::iterator iter = reqqs->begin();
     while (iter != reqqs->end()){
-      if(((*iter)->src() == rank) || ((*iter)->dst() == rank)){
-          myreqqs->push_back(*iter);
-          iter = reqqs->erase(iter);
-          size++;
+      if(((*iter)!=MPI_REQUEST_NULL) && (((*iter)->src() == rank) || ((*iter)->dst() == rank))){
+        myreqqs.push_back(*iter);
+        iter = reqqs->erase(iter);
+        size++;
       } else {
         ++iter;
       }
     }
     if(size >0){
-      MPI_Request* treqs = &(*myreqqs)[0];
+      MPI_Request* treqs = &myreqqs[0];
       Request::waitall(size, treqs, MPI_STATUSES_IGNORE);
-      myreqqs->clear();
-      delete myreqqs;
+      myreqqs.clear();
     }
   }
   xbt_mutex_release(mut_);