[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.1-293-g735e81b

Service Account noreply at mpich.org
Mon Jun 2 14:56:06 CDT 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".

The branch, master has been updated
       via  735e81b2d5ce04c81349f25af0eeaffe8aa8d431 (commit)
       via  5c0999c59df3ebc9d6fdd7f74c1e618c80733374 (commit)
       via  a7d8e188cbde58e9b67a0cd09491c7797fee61f2 (commit)
       via  e19e75f7d3baa10a76f1720575c5a558de4c9bf3 (commit)
       via  d2a87792e4a268c80b0be3462de2753771f52ada (commit)
      from  7e44a0f14764b56823811ff8235ce802f5bdfae6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/735e81b2d5ce04c81349f25af0eeaffe8aa8d431

commit 735e81b2d5ce04c81349f25af0eeaffe8aa8d431
Author: Su Huang <suhuang at us.ibm.com>
Date:   Mon Jun 2 14:10:43 2014 -0400

    pamid: fixed various RMA problems with shared window

diff --git a/src/mpid/pamid/src/onesided/mpid_win_get_accumulate.c b/src/mpid/pamid/src/onesided/mpid_win_get_accumulate.c
index fa0fada..52855bd 100644
--- a/src/mpid/pamid/src/onesided/mpid_win_get_accumulate.c
+++ b/src/mpid/pamid/src/onesided/mpid_win_get_accumulate.c
@@ -34,7 +34,7 @@ MPIDI_Fetch_data_op(const void   * origin_addr,
                     MPID_Win      *win)
 {
         static char FCNAME[] = "MPIDI_Fetch_data_op";
-        int shm_locked;
+        int shm_locked=0;
         MPI_User_function *uop;
         void *base, *dest_addr;
         int disp_unit;
@@ -46,14 +46,6 @@ MPIDI_Fetch_data_op(const void   * origin_addr,
            base = win->mpid.info[target_rank].base_addr;
            disp_unit = win->mpid.info[target_rank].disp_unit;
         }
-        else if (win->create_flavor == MPI_WIN_FLAVOR_DYNAMIC) {
-           base = NULL;
-           disp_unit = win->disp_unit;
-        }
-        else {
-           base = win->mpid.info[target_rank].base_addr;
-           disp_unit = win->mpid.info[target_rank].disp_unit;
-        }
         dest_addr = (char *) base + disp_unit * target_disp;
 
         MPID_Datatype_get_size_macro(origin_datatype, len);
@@ -525,7 +517,7 @@ MPID_Get_accumulate(const void   * origin_addr,
   MPIDI_Win_datatype_basic(result_count, result_datatype, &req->result.dt);
   MPIDI_Win_datatype_map(&req->result.dt);
   req->result_num_contig = req->result.dt.num_contig;
-  if (target_rank == win->comm_ptr->rank || win->create_flavor == MPI_WIN_FLAVOR_SHARED)
+  if (win->create_flavor == MPI_WIN_FLAVOR_SHARED)
    {
         win->mpid.sync.total++;
         MPIDI_Fetch_data_op(origin_addr, origin_count, origin_datatype,
@@ -541,11 +533,12 @@ MPID_Get_accumulate(const void   * origin_addr,
        MPIDI_Win_datatype_unmap(&req->target.dt);
        MPIDI_Win_datatype_unmap(&req->result.dt);
 
-       if(req->req_handle)
+       if(req->req_handle) {
           MPID_cc_set(req->req_handle->cc_ptr, 0);
-       else 
+       } else { 
            MPIU_Free(req);
-   } else {    /* non-shared or target_rank != origin_rank  */
+       }
+   } else {    /* non-shared  */
   //We wait for #messages depending on target and result_datatype
   win->mpid.sync.total += (1 + req->target.dt.num_contig);
   {
diff --git a/src/mpid/pamid/src/onesided/mpid_win_put.c b/src/mpid/pamid/src/onesided/mpid_win_put.c
index 535cbfd..d395792 100644
--- a/src/mpid/pamid/src/onesided/mpid_win_put.c
+++ b/src/mpid/pamid/src/onesided/mpid_win_put.c
@@ -264,33 +264,16 @@ MPID_Put(const void   *origin_addr,
     }
 
 
-  /* shared window  */
-  if ( (win->create_flavor == MPI_WIN_FLAVOR_SHARED))
-    {
-      ++win->mpid.sync.total;
-
-      MPIDI_SHM_MUTEX_LOCK(win);
-      shm_locked=1;
-
-      if (target_rank == win->comm_ptr->rank)
-          target_addr=win->base + req->offset;
-      else 
-          target_addr = win->mpid.info[target_rank].base_addr + req->offset;
-
-      /* The operation is not complete until the local copy is performed */
-      mpi_errno = MPIR_Localcopy(origin_addr,
-                                 origin_count,
-                                 origin_datatype,
-                                 target_addr,
-                                 target_count,
-                                 target_datatype);
-
-      if (shm_locked) {
-          MPIDI_SHM_MUTEX_UNLOCK(win);
-          shm_locked=0;
-      }
+  if (target_rank == win->comm_ptr->rank)
+     {
+       size_t offset = req->offset;
 
-       ++win->mpid.sync.complete;
+       mpi_errno = MPIR_Localcopy(origin_addr,
+                                  origin_count,
+                                  origin_datatype,
+                                  win->base + offset,
+                                  target_count,
+                                  target_datatype);
 
       /* The instant this completion counter is set to zero another thread
        * may notice the change and begin freeing request resources. The
@@ -300,12 +283,12 @@ MPID_Put(const void   *origin_addr,
        *
        * See MPID_Request_release_inline()
        */
-      if(req->req_handle)
-        MPID_cc_set(req->req_handle->cc_ptr, 0);
-      else
-        MPIU_Free(req);
-      return mpi_errno;
-    }
+       if(req->req_handle)
+         MPID_cc_set(req->req_handle->cc_ptr, 0);
+       else
+         MPIU_Free(req);
+       return mpi_errno;
+     }
   req->target.rank = target_rank;
 
 

http://git.mpich.org/mpich.git/commitdiff/5c0999c59df3ebc9d6fdd7f74c1e618c80733374

commit 5c0999c59df3ebc9d6fdd7f74c1e618c80733374
Author: Michael Blocksome <blocksom at us.ibm.com>
Date:   Mon Jun 2 11:45:13 2014 -0500

    pamid: shared window fixes for mpi_get_accumulate

diff --git a/src/mpid/pamid/src/onesided/mpid_win_get_accumulate.c b/src/mpid/pamid/src/onesided/mpid_win_get_accumulate.c
index 420c9e2..fa0fada 100644
--- a/src/mpid/pamid/src/onesided/mpid_win_get_accumulate.c
+++ b/src/mpid/pamid/src/onesided/mpid_win_get_accumulate.c
@@ -22,6 +22,57 @@
 #include "mpidi_onesided.h"
 
 static void 
+MPIDI_Fetch_data_op(const void   * origin_addr,
+                    int            origin_count,
+                    MPI_Datatype   origin_datatype,
+                    void         * result_addr,
+                    int            target_rank,
+                    MPI_Aint       target_disp,
+                    int            target_count,
+                    MPI_Datatype   target_datatype,
+                    MPI_Op         op,
+                    MPID_Win      *win)
+{
+        static char FCNAME[] = "MPIDI_Fetch_data_op";
+        int shm_locked;
+        MPI_User_function *uop;
+        void *base, *dest_addr;
+        int disp_unit;
+        int len, one;
+
+       if (win->create_flavor == MPI_WIN_FLAVOR_SHARED) {
+           MPIDI_SHM_MUTEX_LOCK(win);
+           shm_locked = 1;
+           base = win->mpid.info[target_rank].base_addr;
+           disp_unit = win->mpid.info[target_rank].disp_unit;
+        }
+        else if (win->create_flavor == MPI_WIN_FLAVOR_DYNAMIC) {
+           base = NULL;
+           disp_unit = win->disp_unit;
+        }
+        else {
+           base = win->mpid.info[target_rank].base_addr;
+           disp_unit = win->mpid.info[target_rank].disp_unit;
+        }
+        dest_addr = (char *) base + disp_unit * target_disp;
+
+        MPID_Datatype_get_size_macro(origin_datatype, len);
+        MPIU_Memcpy(result_addr, dest_addr, len);
+        if (op != MPI_NO_OP) {
+            uop = MPIR_OP_HDL_TO_FN(op);
+            one = 1;
+            (*uop)((void *) origin_addr, dest_addr, &one, &origin_datatype);
+        }
+
+        if (shm_locked) {
+            MPIDI_SHM_MUTEX_UNLOCK(win);
+            shm_locked = 0;
+        }
+   fn_fail: return;
+}
+
+
+static void 
 MPIDI_Win_GetAccSendAckDoneCB(pami_context_t   context,
 			     void           * _info,
 			     pami_result_t    result)
@@ -36,6 +87,7 @@ MPIDI_Win_GetAccumSendAck(pami_context_t   context,
 			  void           * _info,
 			  pami_result_t    result)
 {
+  static char FCNAME[] = "MPID_Win_GetAccumSendAck";
   MPIDI_Win_GetAccMsgInfo *msginfo = (MPIDI_Win_GetAccMsgInfo *) _info;  
   pami_result_t rc = PAMI_SUCCESS;
 
@@ -58,7 +110,6 @@ MPIDI_Win_GetAccumSendAck(pami_context_t   context,
                                  MPI_CHAR);
       MPID_assert(mpi_errno == MPI_SUCCESS);      
     }
-
   //Schedule sends to source to result buffer and trigger completion
   //callback there
   pami_send_t params = {
@@ -83,6 +134,7 @@ MPIDI_Win_GetAccumSendAck(pami_context_t   context,
   
   rc = PAMI_Send(context, &params);
   MPID_assert(rc == PAMI_SUCCESS);
+  fn_fail: return;
 }
 
 void
@@ -320,7 +372,14 @@ MPID_Get_accumulate(const void   * origin_addr,
   int mpi_errno = MPI_SUCCESS;
 
   if (op == MPI_NO_OP) {//we just need to fetch data    
-    mpi_errno = MPID_Get(result_addr,
+     if (win->create_flavor == MPI_WIN_FLAVOR_SHARED) {
+        win->mpid.sync.total++;
+        MPIDI_Fetch_data_op(origin_addr, origin_count, origin_datatype,
+                           result_addr, target_rank, target_disp,
+                           target_count, target_datatype, op, win);
+        ++win->mpid.sync.complete;
+     } else {
+        mpi_errno = MPID_Get(result_addr,
 			 result_count,
 			 result_datatype,
 			 target_rank,
@@ -328,6 +387,7 @@ MPID_Get_accumulate(const void   * origin_addr,
 			 target_count,
 			 target_datatype,
 			 win);  
+    }
     return mpi_errno;
   }
   
@@ -465,10 +525,29 @@ MPID_Get_accumulate(const void   * origin_addr,
   MPIDI_Win_datatype_basic(result_count, result_datatype, &req->result.dt);
   MPIDI_Win_datatype_map(&req->result.dt);
   req->result_num_contig = req->result.dt.num_contig;
-  
+  if (target_rank == win->comm_ptr->rank || win->create_flavor == MPI_WIN_FLAVOR_SHARED)
+   {
+        win->mpid.sync.total++;
+        MPIDI_Fetch_data_op(origin_addr, origin_count, origin_datatype,
+                           result_addr, target_rank, target_disp,
+                           target_count, target_datatype, op, win);
+        ++win->mpid.sync.complete;
+
+       if (req->buffer_free) {
+           MPIU_Free(req->buffer);
+           MPIU_Free(req->user_buffer);
+           req->buffer_free = 0;
+       }
+       MPIDI_Win_datatype_unmap(&req->target.dt);
+       MPIDI_Win_datatype_unmap(&req->result.dt);
+
+       if(req->req_handle)
+          MPID_cc_set(req->req_handle->cc_ptr, 0);
+       else 
+           MPIU_Free(req);
+   } else {    /* non-shared or target_rank != origin_rank  */
   //We wait for #messages depending on target and result_datatype
   win->mpid.sync.total += (1 + req->target.dt.num_contig);
-
   {
     MPI_Datatype basic_type = MPI_DATATYPE_NULL;
     MPID_Datatype_get_basic_type(origin_datatype, basic_type);
@@ -516,7 +595,7 @@ MPID_Get_accumulate(const void   * origin_addr,
    *        better latency for one-sided operations.
    */
   PAMI_Context_post(MPIDI_Context[0], &req->post_request, MPIDI_Get_accumulate, req);
-
+ }
 fn_fail:
   return mpi_errno;
 }

http://git.mpich.org/mpich.git/commitdiff/a7d8e188cbde58e9b67a0cd09491c7797fee61f2

commit a7d8e188cbde58e9b67a0cd09491c7797fee61f2
Author: Michael Blocksome <blocksom at us.ibm.com>
Date:   Mon Jun 2 11:43:35 2014 -0500

    pamid: shared window fixes for mpi_get

diff --git a/src/mpid/pamid/src/onesided/mpid_win_get.c b/src/mpid/pamid/src/onesided/mpid_win_get.c
index 019d513..7b83d4a 100644
--- a/src/mpid/pamid/src/onesided/mpid_win_get.c
+++ b/src/mpid/pamid/src/onesided/mpid_win_get.c
@@ -204,6 +204,8 @@ MPID_Get(void         *origin_addr,
          MPID_Win     *win)
 {
   int mpi_errno = MPI_SUCCESS;
+  int shm_locked=0;
+  void *target_addr;
   MPIDI_Win_request *req = MPIU_Calloc0(1, MPIDI_Win_request);
   req->win          = win;
   if(win->mpid.request_based != 1) 
@@ -257,16 +259,30 @@ MPID_Get(void         *origin_addr,
       return MPI_SUCCESS;
     }
 
-  /* If the get is a local operation, do it here */
-  if (target_rank == win->comm_ptr->rank)
+  /* If the get is a local operation,or shared window do it here */
+  if ((target_rank == win->comm_ptr->rank) || (win->create_flavor == MPI_WIN_FLAVOR_SHARED))
     {
+      if (target_rank == win->comm_ptr->rank)
+          target_addr = win->base + req->offset;
+      else
+          target_addr = win->mpid.info[target_rank].base_addr + req->offset;
+
+      if (win->create_flavor == MPI_WIN_FLAVOR_SHARED) {
+          MPIDI_SHM_MUTEX_LOCK(win);
+          shm_locked=1;
+      }
+
       /* The operation is not complete until the local copy is performed */
-      mpi_errno = MPIR_Localcopy(win->base + req->offset,
+      mpi_errno = MPIR_Localcopy(target_addr,
                                  target_count,
                                  target_datatype,
                                  origin_addr,
                                  origin_count,
                                  origin_datatype);
+      if (shm_locked) {
+          MPIDI_SHM_MUTEX_UNLOCK(win);
+          shm_locked=0;
+      }
 
       /* The instant this completion counter is set to zero another thread
        * may notice the change and begin freeing request resources. The

http://git.mpich.org/mpich.git/commitdiff/e19e75f7d3baa10a76f1720575c5a558de4c9bf3

commit e19e75f7d3baa10a76f1720575c5a558de4c9bf3
Author: Michael Blocksome <blocksom at us.ibm.com>
Date:   Mon Jun 2 11:36:56 2014 -0500

    pamid: calculate correct shared memory base address

diff --git a/src/mpid/pamid/src/onesided/mpid_win_accumulate.c b/src/mpid/pamid/src/onesided/mpid_win_accumulate.c
index 2ab1f14..47fe880 100644
--- a/src/mpid/pamid/src/onesided/mpid_win_accumulate.c
+++ b/src/mpid/pamid/src/onesided/mpid_win_accumulate.c
@@ -161,6 +161,7 @@ MPID_Accumulate(const void   *origin_addr,
                 MPID_Win     *win)
 {
   int mpi_errno = MPI_SUCCESS;
+  int shm_locked = 0;
   MPIDI_Win_request *req = MPIU_Calloc0(1, MPIDI_Win_request);
   req->win          = win;
   if(win->mpid.request_based != 1)
@@ -288,10 +289,39 @@ MPID_Accumulate(const void   *origin_addr,
 
 
   MPIDI_Win_datatype_map(&req->target.dt);
-  win->mpid.sync.total += req->target.dt.num_contig;
 
+  if (win->create_flavor == MPI_WIN_FLAVOR_SHARED)
+   {
+       MPI_User_function *uop;
+       void *base, *dest_addr;
+       int disp_unit;
+       int len, one;
 
+       ++win->mpid.sync.total;
+       MPIDI_SHM_MUTEX_LOCK(win);
+       shm_locked = 1;
+       base = win->mpid.info[target_rank].base_addr;
+       disp_unit = win->mpid.info[target_rank].disp_unit;
+       dest_addr = (char *) base + disp_unit * target_disp;
+
+       MPID_Datatype_get_size_macro(origin_datatype, len);
+
+       uop = MPIR_OP_HDL_TO_FN(op);
+       one = 1;
+
+       (*uop)((void *) origin_addr, dest_addr, &one, &origin_datatype);
+
+       if (shm_locked) {
+           MPIDI_SHM_MUTEX_UNLOCK(win);
+           shm_locked = 0;
+       }
+
+        MPIU_Free(req);
+        ++win->mpid.sync.complete;
+
+   } else { /* non-shared    */
   {
+    win->mpid.sync.total += req->target.dt.num_contig;
     MPI_Datatype basic_type = MPI_DATATYPE_NULL;
     MPID_Datatype_get_basic_type(origin_datatype, basic_type);
     /* MPID_Datatype_get_basic_type() doesn't handle the struct types */
@@ -334,6 +364,7 @@ MPID_Accumulate(const void   *origin_addr,
    */
   PAMI_Context_post(MPIDI_Context[0], &req->post_request, MPIDI_Accumulate, req);
 
+ }
 fn_fail:
   return mpi_errno;
 }
diff --git a/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c b/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c
index 78e27a0..0a63e9f 100644
--- a/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c
+++ b/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c
@@ -512,11 +512,15 @@ MPID_Win_allocate_shared(MPI_Aint     size,
       char *cur_base = (*win_ptr)->base;
       for (i = 0; i < comm_size; ++i) {
           if (win->mpid.info[i].base_size) {
+             if (i == 0) 
+                 win->mpid.info[i].base_addr = (void *) ((MPI_Aint) cur_base);
+             else {
               if (noncontig)  
                   /* Round up to next page size */
-                  win->mpid.info[i].base_addr =(void *) ((MPI_Aint) cur_base + (MPI_Aint) MPIDI_ROUND_UP_PAGESIZE(size,pageSize));
+                  win->mpid.info[i].base_addr =(void *) ((MPI_Aint) cur_base + (MPI_Aint) MPIDI_ROUND_UP_PAGESIZE((win->mpid.info[i-1].base_size),pageSize));
               else
-                  win->mpid.info[i].base_addr = (void *) ((MPI_Aint) cur_base + (MPI_Aint) size);
+                  win->mpid.info[i].base_addr = (void *) ((MPI_Aint) cur_base + (MPI_Aint) (win->mpid.info[i-1].base_size));
+              }
               cur_base = win->mpid.info[i].base_addr;
           } else {
               win->mpid.info[i].base_addr = NULL; 
diff --git a/src/mpid/pamid/src/onesided/mpid_win_compare_and_swap.c b/src/mpid/pamid/src/onesided/mpid_win_compare_and_swap.c
index ebbe56e..e75c921 100644
--- a/src/mpid/pamid/src/onesided/mpid_win_compare_and_swap.c
+++ b/src/mpid/pamid/src/onesided/mpid_win_compare_and_swap.c
@@ -116,6 +116,7 @@ int MPID_Compare_and_swap(const void *origin_addr, const void *compare_addr,
         int disp_unit;
         int len;
 
+        ++win->mpid.sync.total;
         if (win->create_flavor == MPI_WIN_FLAVOR_SHARED) {
             MPIDI_SHM_MUTEX_LOCK(win);
             shm_locked = 1;
@@ -128,7 +129,7 @@ int MPID_Compare_and_swap(const void *origin_addr, const void *compare_addr,
 	    disp_unit = win->disp_unit;
 	}
         else {
-            base = win->base;
+            base = win->mpid.info[target_rank].base_addr;
             disp_unit = win->disp_unit;
         }
 
@@ -145,6 +146,7 @@ int MPID_Compare_and_swap(const void *origin_addr, const void *compare_addr,
             shm_locked = 0;
         }
         MPIU_Free(req);
+       ++win->mpid.sync.complete;
     } 
   else {
     req->buffer           = (void *) ((uintptr_t) origin_addr + req->origin.dt.true_lb);
diff --git a/src/mpid/pamid/src/onesided/mpid_win_fetch_and_op.c b/src/mpid/pamid/src/onesided/mpid_win_fetch_and_op.c
index b1a415c..6343484 100644
--- a/src/mpid/pamid/src/onesided/mpid_win_fetch_and_op.c
+++ b/src/mpid/pamid/src/onesided/mpid_win_fetch_and_op.c
@@ -297,11 +297,12 @@ int MPID_Fetch_and_op(const void *origin_addr, void *result_addr,
         int disp_unit;
         int len, one;
 
+        ++win->mpid.sync.total;
         if (win->create_flavor == MPI_WIN_FLAVOR_SHARED) {
             MPIDI_SHM_MUTEX_LOCK(win);
             shm_locked = 1;
             base = win->mpid.info[target_rank].base_addr;
-            disp_unit = win->disp_unit;
+            disp_unit = win->mpid.info[target_rank].disp_unit;
 
         }
 	else if (win->create_flavor == MPI_WIN_FLAVOR_DYNAMIC) {
@@ -309,8 +310,8 @@ int MPID_Fetch_and_op(const void *origin_addr, void *result_addr,
 	    disp_unit = win->disp_unit;
 	}
         else {
-            base = win->base;
-            disp_unit = win->disp_unit;
+            base = win->mpid.info[target_rank].base_addr;
+            disp_unit = win->mpid.info[target_rank].disp_unit;
         }
 
         dest_addr = (char *) base + disp_unit * target_disp;
@@ -330,6 +331,7 @@ int MPID_Fetch_and_op(const void *origin_addr, void *result_addr,
 
         MPIU_Free(req);
 
+        ++win->mpid.sync.complete;
     }
   else {
     req->compare_buffer = NULL;
diff --git a/src/mpid/pamid/src/onesided/mpid_win_put.c b/src/mpid/pamid/src/onesided/mpid_win_put.c
index db5f20c..535cbfd 100644
--- a/src/mpid/pamid/src/onesided/mpid_win_put.c
+++ b/src/mpid/pamid/src/onesided/mpid_win_put.c
@@ -206,6 +206,8 @@ MPID_Put(const void   *origin_addr,
          MPID_Win     *win)
 {
   int mpi_errno = MPI_SUCCESS;
+  int shm_locked=0;
+  void * target_addr;
   MPIDI_Win_request *req = MPIU_Calloc0(1, MPIDI_Win_request);
   req->win          = win;
   if(win->mpid.request_based != 1) 
@@ -262,17 +264,34 @@ MPID_Put(const void   *origin_addr,
     }
 
 
-  /* If the get is a local operation, do it here */
-  if (target_rank == win->comm_ptr->rank)
+  /* shared window  */
+  if ( (win->create_flavor == MPI_WIN_FLAVOR_SHARED))
     {
+      ++win->mpid.sync.total;
+
+      MPIDI_SHM_MUTEX_LOCK(win);
+      shm_locked=1;
+
+      if (target_rank == win->comm_ptr->rank)
+          target_addr=win->base + req->offset;
+      else 
+          target_addr = win->mpid.info[target_rank].base_addr + req->offset;
+
       /* The operation is not complete until the local copy is performed */
       mpi_errno = MPIR_Localcopy(origin_addr,
                                  origin_count,
                                  origin_datatype,
-                                 win->base + req->offset,
+                                 target_addr,
                                  target_count,
                                  target_datatype);
 
+      if (shm_locked) {
+          MPIDI_SHM_MUTEX_UNLOCK(win);
+          shm_locked=0;
+      }
+
+       ++win->mpid.sync.complete;
+
       /* The instant this completion counter is set to zero another thread
        * may notice the change and begin freeing request resources. The
        * thread executing the code in this function must not touch any

http://git.mpich.org/mpich.git/commitdiff/d2a87792e4a268c80b0be3462de2753771f52ada

commit d2a87792e4a268c80b0be3462de2753771f52ada
Author: Michael Blocksome <blocksom at us.ibm.com>
Date:   Mon Jun 2 11:28:16 2014 -0500

    pamid: use MPIDI_Win_shm_ctrl_t structure consistently

diff --git a/src/mpid/pamid/include/mpidi_datatypes.h b/src/mpid/pamid/include/mpidi_datatypes.h
index de191b1..7c6e566 100644
--- a/src/mpid/pamid/include/mpidi_datatypes.h
+++ b/src/mpid/pamid/include/mpidi_datatypes.h
@@ -448,8 +448,10 @@ typedef pthread_mutex_t MPIDI_SHM_MUTEX;
 
 typedef struct MPIDI_Win_shm_ctrl_t
 {
-  MPIDI_SHM_MUTEX mutex_lock;
+  MPIDI_SHM_MUTEX  mutex_lock;    /* shared memory windows -- lock for    */
+                                     /*     accumulate/atomic operations     */
   OPA_int_t       active;
+  int        shm_count;
 } MPIDI_Win_shm_ctrl_t;
 
 typedef struct MPIDI_Win_shm_t
@@ -463,9 +465,7 @@ typedef struct MPIDI_Win_shm_t
       uint32_t shm_id;                /* shared memory id - sysv            */
       char     shm_key[64];         /* shared memory key - posix            */
     };
-    int       *shm_count;
-    MPIDI_SHM_MUTEX *mutex_lock;    /* shared memory windows -- lock for    */
-                                     /*     accumulate/atomic operations     */
+    MPIDI_Win_shm_ctrl_t  *ctrl;
 } MPIDI_Win_shm_t;
 
 /**
diff --git a/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c b/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c
index bdb241f..78e27a0 100644
--- a/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c
+++ b/src/mpid/pamid/src/onesided/mpid_win_allocate_shared.c
@@ -182,7 +182,7 @@ MPID_getSharedSegment_mmap(MPID_Win * win)
   close (fd); /* no longer needed */
 
   /* set mutex_lock address and initialize it   */
-  win->mpid.shm->mutex_lock = (MPIDI_SHM_MUTEX *) win->mpid.shm->base_addr;
+  win->mpid.shm->ctrl = (MPIDI_Win_shm_ctrl_t *) win->mpid.shm->base_addr;
   if (1 == first) {
     MPIDI_SHM_MUTEX_INIT(win);
   }
@@ -271,7 +271,7 @@ MPID_getSharedSegment_sysv(MPID_Win * win)
         MPIU_ERR_CHKANDJUMP((win->mpid.shm->base_addr == (void*) -1), mpi_errno,MPI_ERR_BUFFER, "**bufnull");
 
         /* set mutex_lock address and initialize it */
-        win->mpid.shm->mutex_lock = (MPIDI_SHM_MUTEX *) win->mpid.shm->base_addr;
+        win->mpid.shm->ctrl = (MPIDI_Win_shm_ctrl_t *) win->mpid.shm->base_addr;
         MPIDI_SHM_MUTEX_INIT(win);
 
         /* successfully created shm segment - shared the key with other tasks */
@@ -285,7 +285,7 @@ MPID_getSharedSegment_sysv(MPID_Win * win)
         if (win->mpid.shm->shm_id != -1) { /* shm segment is available */
             win->mpid.shm->base_addr = (void *) shmat(win->mpid.shm->shm_id,0,0);
         }
-        win->mpid.shm->mutex_lock = (MPIDI_SHM_MUTEX *) win->mpid.shm->base_addr;
+        win->mpid.shm->ctrl = (MPIDI_Win_shm_ctrl_t *) win->mpid.shm->base_addr;
     }
 
     win->mpid.shm->allocated = 1;
@@ -333,7 +333,7 @@ MPID_getSharedSegment(MPI_Aint     size,
         /* The beginning of the heap allocation contains a control block
          * before the data begins.
          */
-        new_size = MPIDI_ROUND_UP_PAGESIZE(sizeof(MPIDI_Win_shm_ctrl_t),pageSize);
+        new_size = MPIDI_ROUND_UP_PAGESIZE((sizeof(MPIDI_Win_shm_ctrl_t)+ ((comm_size+1) * sizeof(void *))),pageSize);
 
         if (size > 0) {
             if (*noncontig)
@@ -349,7 +349,7 @@ MPID_getSharedSegment(MPI_Aint     size,
         win->mpid.shm->segment_len = new_size;
         win->mpid.shm->base_addr = base_pp;
         if (size !=0) {
-            win->mpid.info[rank].base_addr = (void *)((MPI_Aint) base_pp + MPIDI_ROUND_UP_PAGESIZE(sizeof(MPIDI_Win_shm_ctrl_t),pageSize));
+            win->mpid.info[rank].base_addr = (void *)((MPI_Aint) base_pp + MPIDI_ROUND_UP_PAGESIZE((sizeof(MPIDI_Win_shm_ctrl_t) +  ((comm_size+1) * sizeof(void *))),pageSize));
         } else {
             win->mpid.info[rank].base_addr = NULL;
         }
@@ -357,10 +357,9 @@ MPID_getSharedSegment(MPI_Aint     size,
         win->mpid.info[rank].base_size = size;
 
         /* set mutex_lock address and initialize it   */
-        win->mpid.shm->mutex_lock = (pthread_mutex_t *) win->mpid.shm->base_addr;
-        win->mpid.shm->shm_count = (int *)((MPI_Aint) win->mpid.shm->mutex_lock + (MPI_Aint) sizeof(pthread_mutex_t));
+        win->mpid.shm->ctrl = (MPIDI_Win_shm_ctrl_t *) win->mpid.shm->base_addr;
         MPIDI_SHM_MUTEX_INIT(win);
-        OPA_fetch_and_add_int((OPA_int_t *) win->mpid.shm->shm_count,1);
+        OPA_fetch_and_add_int((OPA_int_t *) &win->mpid.shm->ctrl->shm_count,(int) 1);
 
     } else {
         /* allocate a temporary buffer to gather the 'size' of each buffer on
@@ -392,7 +391,7 @@ MPID_getSharedSegment(MPI_Aint     size,
         /* The beginning of the shared memory allocation contains a control
          * block before the data begins.
          */
-        win->mpid.shm->segment_len += MPIDI_ROUND_UP_PAGESIZE(sizeof(MPIDI_Win_shm_ctrl_t),pageSize);
+        win->mpid.shm->segment_len += MPIDI_ROUND_UP_PAGESIZE((sizeof(MPIDI_Win_shm_ctrl_t) + ((comm_size+1) * sizeof(void *))),pageSize);
 
         /* Get the shared segment which includes the control block header and
          * data buffer - possibly padded if non-contiguous.
@@ -407,14 +406,13 @@ MPID_getSharedSegment(MPI_Aint     size,
         if (mpi_errno) MPIU_ERR_POP(mpi_errno);
 
         /* increment the shared counter */
-        win->mpid.shm->shm_count=(int *)((MPI_Aint) win->mpid.shm->mutex_lock + (MPI_Aint) sizeof(MPIDI_SHM_MUTEX));
-        OPA_fetch_and_add_int((OPA_int_t *) win->mpid.shm->shm_count,1);
+        OPA_fetch_and_add_int((OPA_int_t *) &win->mpid.shm->ctrl->shm_count,(int) 1);
 
         /* wait for all ranks complete */
-        while(*win->mpid.shm->shm_count != comm_size) MPIDI_QUICKSLEEP;
+        while((int) win->mpid.shm->ctrl->shm_count != comm_size) MPIDI_QUICKSLEEP;
 
         /* compute the base addresses of each process within the shared memory segment */
-        win->base = (void *) ((long) win->mpid.shm->base_addr + (long ) MPIDI_ROUND_UP_PAGESIZE(sizeof(MPIDI_Win_shm_ctrl_t),pageSize));
+        win->base = (void *) ((long) win->mpid.shm->base_addr + (long ) MPIDI_ROUND_UP_PAGESIZE((sizeof(MPIDI_Win_shm_ctrl_t) + ((comm_size+1) * sizeof(void *))),pageSize));
     }
 
 fn_exit:
diff --git a/src/mpid/pamid/src/onesided/mpid_win_free.c b/src/mpid/pamid/src/onesided/mpid_win_free.c
index e926448..00da268 100644
--- a/src/mpid/pamid/src/onesided/mpid_win_free.c
+++ b/src/mpid/pamid/src/onesided/mpid_win_free.c
@@ -34,8 +34,8 @@ int MPIDI_SHM_Win_free(MPID_Win **win_ptr)
   /* Free shared memory region */
   /* free shm_base_addrs that's only used for shared memory windows */
   if ((*win_ptr)->mpid.shm->allocated) {
-    OPA_fetch_and_add_int((OPA_int_t *) (*win_ptr)->mpid.shm->shm_count,-1);
-    while(*(*win_ptr)->mpid.shm->shm_count) MPIDI_QUICKSLEEP;
+    OPA_fetch_and_add_int((OPA_int_t *) &((*win_ptr)->mpid.shm->ctrl->shm_count),-1);
+    while((*win_ptr)->mpid.shm->ctrl->shm_count !=0) MPIDI_QUICKSLEEP;
     if ((*win_ptr)->comm_ptr->rank == 0) {
       MPIDI_SHM_MUTEX_DESTROY(*win_ptr);
       }
diff --git a/src/mpid/pamid/src/onesided/mpidi_onesided.h b/src/mpid/pamid/src/onesided/mpidi_onesided.h
index 214926a..0a2e201 100644
--- a/src/mpid/pamid/src/onesided/mpidi_onesided.h
+++ b/src/mpid/pamid/src/onesided/mpidi_onesided.h
@@ -37,50 +37,69 @@ pami_rmw_t   zero_rmw_parms;
 #define MPIDI_QUICKSLEEP     usleep(1);
 #define MAX_NUM_CTRLSEND  1024          /* no more than 1024 outstanding control sends */
 
-#define MPIDI_SHM_MUTEX_LOCK(win)                                                       \
-    do {                                                                                \
-        pthread_mutex_t *shm_mutex = win->mpid.shm->mutex_lock;                         \
-        int rval = pthread_mutex_lock(shm_mutex);                                       \
-        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_lock",          \
-                             "**pthread_lock %s", strerror(rval));                      \
+#define MPIDI_SHM_MUTEX_LOCK(win)                                                          \
+    int mpi_errno=0;                                                                       \
+    do {                                                                                   \
+        pthread_mutex_t *shm_mutex = (pthread_mutex_t *) &win->mpid.shm->ctrl->mutex_lock; \
+        int rval = pthread_mutex_lock(shm_mutex);                                          \
+        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_lock",             \
+                             "**pthread_lock %s", strerror(rval));                         \
     } while (0);
 
-#define MPIDI_SHM_MUTEX_UNLOCK(win)                                                     \
-    do {                                                                                \
-        pthread_mutex_t *shm_mutex = win->mpid.shm->mutex_lock;                         \
-        int rval = pthread_mutex_unlock(shm_mutex);                                     \
-        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_unlock",        \
-                             "**pthread_unlock %s", strerror(rval));                    \
-    } while (0);
 
-#define MPIDI_SHM_MUTEX_INIT(win)                                                       \
-    do {                                                                                \
-        int rval=0;                                                                     \
-        pthread_mutexattr_t attr;                                                       \
-        pthread_mutex_t *shm_mutex = win->mpid.shm->mutex_lock;                         \
-                                                                                        \
-        rval = pthread_mutexattr_init(&attr);                                           \
-        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_mutex",         \
-                             "**pthread_mutex %s", strerror(rval));                     \
-        rval = pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);             \
-        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_mutex",         \
-                             "**pthread_mutex %s", strerror(rval));                     \
-        rval = pthread_mutex_init(shm_mutex, &attr);                                    \
-        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_mutex",         \
-                             "**pthread_mutex %s", strerror(rval));                     \
-        rval = pthread_mutexattr_destroy(&attr);                                        \
-        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_mutex",         \
-                             "**pthread_mutex %s", strerror(rval));                     \
+#define MPIDI_SHM_MUTEX_UNLOCK(win)                                                        \
+    int mpi_errno=0;                                                                       \
+    do {                                                                                   \
+        pthread_mutex_t *shm_mutex = (pthread_mutex_t *) &win->mpid.shm->ctrl->mutex_lock; \
+        int rval = pthread_mutex_unlock(shm_mutex);                                        \
+        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_unlock",           \
+                             "**pthread_unlock %s", strerror(rval));                       \
+    } while (0);    
+
+
+#define MPIDI_SHM_MUTEX_INIT(win)                                                          \
+    do {                                                                                   \
+        int rval=0;                                                                        \
+        int mpi_errno=0;                                                                   \
+        pthread_mutexattr_t attr;                                                          \
+        pthread_mutex_t *shm_mutex = (pthread_mutex_t *) &win->mpid.shm->ctrl->mutex_lock; \
+                                                                                           \
+        rval = pthread_mutexattr_init(&attr);                                              \
+        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_mutex",            \
+                             "**pthread_mutex %s", strerror(rval));                        \
+        rval = pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);                \
+        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_mutex",            \
+                             "**pthread_mutex %s", strerror(rval));                        \
+        rval = pthread_mutex_init(shm_mutex, &attr);                                       \
+        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_mutex",            \
+                             "**pthread_mutex %s", strerror(rval));                        \
+        rval = pthread_mutexattr_destroy(&attr);                                           \
+        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_mutex",            \
+                             "**pthread_mutex %s", strerror(rval));                        \
     } while (0);
 
-#define MPIDI_SHM_MUTEX_DESTROY(win)                                                    \
-    do {                                                                                \
-        pthread_mutex_t *shm_mutex = (win)->mpid.shm->mutex_lock;                       \
-        int rval = pthread_mutex_destroy(shm_mutex);                                    \
-        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_mutex",         \
-                             "**pthread_mutex %s", strerror(rval));                     \
+#define MPIDI_SHM_MUTEX_DESTROY(win)                                                        \
+    int mpi_errno=0;                                                                        \
+    do {                                                                                    \
+        pthread_mutex_t *shm_mutex = (pthread_mutex_t *) &(win)->mpid.shm->ctrl->mutex_lock;\
+        int rval = pthread_mutex_destroy(shm_mutex);                                        \
+        MPIU_ERR_CHKANDJUMP1(rval, mpi_errno, MPI_ERR_OTHER, "**pthread_mutex",             \
+                             "**pthread_mutex %s", strerror(rval));                         \
     } while (0);
 
+#define MPIDI_ACQUIRE_SHARED_LOCK(win) {                                                    \
+         MPIDI_SHM_MUTEX_LOCK(win);                                                         \
+         OPA_fetch_and_add_int((OPA_int_t *)&win->mpid.shm->ctrl->active,(int) 1);          \
+}
+
+#define MPIDI_RELEASE_SHARED_LOCK(win) {                                                    \
+         MPIDI_SHM_MUTEX_UNLOCK(win);                                                       \
+         OPA_fetch_and_add_int((OPA_int_t *)&(win->mpid.shm->ctrl->active),(int) -1);       \
+}
+
+
+
+
 /**
  * \brief One-sided Message Types
  */

-----------------------------------------------------------------------

Summary of changes:
 src/mpid/pamid/include/mpidi_datatypes.h           |    8 +-
 src/mpid/pamid/src/onesided/mpid_win_accumulate.c  |   33 +++++++-
 .../pamid/src/onesided/mpid_win_allocate_shared.c  |   32 ++++---
 .../pamid/src/onesided/mpid_win_compare_and_swap.c |    4 +-
 .../pamid/src/onesided/mpid_win_fetch_and_op.c     |    8 +-
 src/mpid/pamid/src/onesided/mpid_win_free.c        |    4 +-
 src/mpid/pamid/src/onesided/mpid_win_get.c         |   22 ++++-
 .../pamid/src/onesided/mpid_win_get_accumulate.c   |   82 ++++++++++++++++-
 src/mpid/pamid/src/onesided/mpid_win_put.c         |   32 ++++---
 src/mpid/pamid/src/onesided/mpidi_onesided.h       |   93 ++++++++++++--------
 10 files changed, 232 insertions(+), 86 deletions(-)


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list