[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.2b4-54-g2672616

Service Account noreply at mpich.org
Mon Aug 3 00:37:45 CDT 2015


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  2672616c69f4e131c830744c3e53d07f1986cb92 (commit)
       via  184f24401be248761f2f84523eb9712025d8e762 (commit)
       via  720ab6bb4f0b7211ece7da875177690df2f6d3fd (commit)
       via  751723eafd383e06c8a5328775d4fae58537cdad (commit)
       via  7857e9aabdb291215edaf6fa6eb6940116a44e56 (commit)
       via  b3e784426aa2ee35bbf6a0946e412fc91a3c55df (commit)
       via  2c11094da38763c5eec5495b0cf70d3e15994dba (commit)
       via  0580240953d2b5a14abc438cba2165c48e544ef2 (commit)
       via  16e34b611e7a492dc04d0d180d5d69133fd94820 (commit)
       via  fb1f689a43a831290bbc449d3ee5d71f843da4d8 (commit)
       via  47e0c270d26ac06f4ab512f8a32678e0ec6543c4 (commit)
       via  bf5f0ec33784f6015b15b3419cff16a6dde5aa66 (commit)
       via  08f4cd38d95dde29bef38e15018e6e7f713547a0 (commit)
       via  912890e296b12cd8b7327b0b8e7575b9ff5cda02 (commit)
       via  92d67453362043bc5ea88042084d769a749d0f86 (commit)
      from  0e7a7ac8be48f3599fad1c1bc16174bf8817782f (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/2672616c69f4e131c830744c3e53d07f1986cb92

commit 2672616c69f4e131c830744c3e53d07f1986cb92
Author: Xin Zhao <xinzhao3 at illinois.edu>
Date:   Fri Jul 31 12:43:57 2015 -0500

    Register/de-register RMA progress when activate/de-activate window.
    
    Here, instead of registering/de-registering RMA progress on the
    first window and the last window, we do it on the first active
    window and the last active window, so that when only inactive
    windows exist, we do not need to register RMA progress at all.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/mpid/ch3/include/mpid_rma_oplist.h b/src/mpid/ch3/include/mpid_rma_oplist.h
index bfdee1b..62637af 100644
--- a/src/mpid/ch3/include/mpid_rma_oplist.h
+++ b/src/mpid/ch3/include/mpid_rma_oplist.h
@@ -158,6 +158,15 @@ static inline int MPIDI_CH3I_Win_set_active(MPID_Win * win_ptr)
 
     if (win_ptr->active == FALSE) {
         win_ptr->active = TRUE;
+
+        /* If this is the first active window, register RMA progress */
+        if (MPIDI_RMA_Win_active_list_head == NULL) {
+            mpi_errno = MPID_Progress_register_hook(MPIDI_CH3I_RMA_Make_progress_global);
+            if (mpi_errno) {
+                MPIU_ERR_POP(mpi_errno);
+            }
+        }
+
         MPL_DL_DELETE(MPIDI_RMA_Win_inactive_list_head, win_ptr);
         MPL_DL_APPEND(MPIDI_RMA_Win_active_list_head, win_ptr);
     }
@@ -181,6 +190,14 @@ static inline int MPIDI_CH3I_Win_set_inactive(MPID_Win * win_ptr)
         win_ptr->active = FALSE;
         MPL_DL_DELETE(MPIDI_RMA_Win_active_list_head, win_ptr);
         MPL_DL_APPEND(MPIDI_RMA_Win_inactive_list_head, win_ptr);
+
+        /* This is the last active window, de-register RMA progress */
+        if (MPIDI_RMA_Win_active_list_head == NULL) {
+            mpi_errno = MPID_Progress_deregister_hook(MPIDI_CH3I_RMA_Make_progress_global);
+            if (mpi_errno != MPI_SUCCESS) {
+                MPIU_ERR_POP(mpi_errno);
+            }
+        }
     }
 
   fn_exit:
diff --git a/src/mpid/ch3/src/mpid_rma.c b/src/mpid/ch3/src/mpid_rma.c
index 4bc238a..cba9e8e 100644
--- a/src/mpid/ch3/src/mpid_rma.c
+++ b/src/mpid/ch3/src/mpid_rma.c
@@ -353,11 +353,6 @@ static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
                       &((*win_ptr)->target_lock_entry_pool_start[i]));
     }
 
-    if (MPIDI_RMA_Win_inactive_list_head == NULL && MPIDI_RMA_Win_active_list_head == NULL) {
-        mpi_errno = MPID_Progress_register_hook(MPIDI_CH3I_RMA_Make_progress_global);
-        if (mpi_errno)
-            MPIU_ERR_POP(mpi_errno);
-    }
     MPL_DL_APPEND(MPIDI_RMA_Win_inactive_list_head, (*win_ptr));
 
     if (MPIDI_CH3U_Win_hooks.win_init != NULL) {
diff --git a/src/mpid/ch3/src/mpidi_rma.c b/src/mpid/ch3/src/mpidi_rma.c
index 1a24bb4..495d5b3 100644
--- a/src/mpid/ch3/src/mpidi_rma.c
+++ b/src/mpid/ch3/src/mpidi_rma.c
@@ -190,15 +190,8 @@ int MPID_Win_free(MPID_Win ** win_ptr)
     }
 
     /* dequeue window from the global list */
-    if ((*win_ptr)->active == TRUE) {
-        MPL_DL_DELETE(MPIDI_RMA_Win_active_list_head, (*win_ptr));
-    }
-    else {
-        MPL_DL_DELETE(MPIDI_RMA_Win_inactive_list_head, (*win_ptr));
-    }
-
-    if (MPIDI_RMA_Win_active_list_head == NULL && MPIDI_RMA_Win_inactive_list_head == NULL)
-        MPID_Progress_deregister_hook(MPIDI_CH3I_RMA_Make_progress_global);
+    MPIU_Assert((*win_ptr)->active == FALSE);
+    MPL_DL_DELETE(MPIDI_RMA_Win_inactive_list_head, (*win_ptr));
 
     comm_ptr = (*win_ptr)->comm_ptr;
     mpi_errno = MPIR_Comm_free_impl(comm_ptr);

http://git.mpich.org/mpich.git/commitdiff/184f24401be248761f2f84523eb9712025d8e762

commit 184f24401be248761f2f84523eb9712025d8e762
Author: Xin Zhao <xinzhao3 at illinois.edu>
Date:   Fri Jul 31 11:44:14 2015 -0500

    Delete MPIDI_CH3I_num_active_issued_win and MPIDI_CH3I_num_passive_win.
    
    After MPIDI_RMA_Win_active_list_head is introduced, those two
    variables are no longer needed. We can check if MPIDI_RMA_Win_active_list_head
    is empty to decide if running RMA progress or not.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h b/src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h
index 726a010..799d5ba 100644
--- a/src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h
+++ b/src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h
@@ -40,8 +40,7 @@ static inline void MPID_nem_mpich_send_seg (MPID_Segment *segment, MPIDI_msg_sz_
      !MPIDI_CH3I_shm_active_send &&             \
      !MPIDI_CH3I_Sendq_head(MPIDI_CH3I_shm_sendq) &&       \
      !MPIDU_Sched_are_pending() &&              \
-     !MPIDI_CH3I_num_active_issued_win &&       \
-     !MPIDI_CH3I_num_passive_win)
+     !MPIDI_RMA_Win_active_list_head)
 
 #undef FUNCNAME
 #define FUNCNAME MPID_nem_mpich_send_header
diff --git a/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_pre.h b/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_pre.h
index 4ca3ac8..1b909de 100644
--- a/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_pre.h
+++ b/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_pre.h
@@ -228,7 +228,6 @@ MPIDI_CH3I_Progress_state;
 #define MPIDI_CH3_PROGRESS_STATE_DECL MPIDI_CH3I_Progress_state ch;
 
 extern OPA_int_t MPIDI_CH3I_progress_completion_count;
-extern int MPIDI_CH3I_num_active_issued_win, MPIDI_CH3I_num_passive_win;
 
 #define MPIDI_CH3I_INCR_PROGRESS_COMPLETION_COUNT do {                                  \
         OPA_write_barrier();                                                            \
diff --git a/src/mpid/ch3/channels/nemesis/src/ch3_progress.c b/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
index 37184ea..1dfbcdc 100644
--- a/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
+++ b/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
@@ -46,7 +46,6 @@ extern MPID_Request ** const MPID_Recvq_unexpected_tail_ptr;
 #endif
 
 OPA_int_t MPIDI_CH3I_progress_completion_count = OPA_INT_T_INITIALIZER(0);
-int MPIDI_CH3I_num_active_issued_win = 0, MPIDI_CH3I_num_passive_win = 0;
 
 /* NEMESIS MULTITHREADING: Extra Data Structures Added */
 #ifdef MPICH_IS_THREADED
diff --git a/src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h b/src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h
index fc1115c..61908db 100644
--- a/src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h
+++ b/src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h
@@ -78,8 +78,6 @@ MPIDI_CH3I_Progress_state;
    and must be available to the routines in src/mpi */
 extern volatile unsigned int MPIDI_CH3I_progress_completion_count;
 
-extern int MPIDI_CH3I_num_active_issued_win, MPIDI_CH3I_num_passive_win;
-
 /* MPICH_IS_THREADED isn't defined yet (handled by mpiimplthread.h) */
 #if (MPICH_THREAD_LEVEL == MPI_THREAD_MULTIPLE)
 #define MPIDI_CH3I_PROGRESS_WAKEUP                                                                \
diff --git a/src/mpid/ch3/channels/sock/src/ch3_progress.c b/src/mpid/ch3/channels/sock/src/ch3_progress.c
index e6f81fb..ded4e10 100644
--- a/src/mpid/ch3/channels/sock/src/ch3_progress.c
+++ b/src/mpid/ch3/channels/sock/src/ch3_progress.c
@@ -23,7 +23,6 @@ static int MPIDI_CH3i_Progress_test(void);
 /* FIXME: Move thread stuff into some set of abstractions in order to remove
    ifdefs */
 volatile unsigned int MPIDI_CH3I_progress_completion_count = 0;
-int MPIDI_CH3I_num_active_issued_win = 0, MPIDI_CH3I_num_passive_win = 0;
 
 #ifdef MPICH_IS_THREADED
     volatile int MPIDI_CH3I_progress_blocked = FALSE;
diff --git a/src/mpid/ch3/include/mpid_rma_types.h b/src/mpid/ch3/include/mpid_rma_types.h
index cfcf80c..2763af5 100644
--- a/src/mpid/ch3/include/mpid_rma_types.h
+++ b/src/mpid/ch3/include/mpid_rma_types.h
@@ -105,8 +105,6 @@ typedef struct MPIDI_RMA_Slot {
     struct MPIDI_RMA_Target *target_list_head;
 } MPIDI_RMA_Slot_t;
 
-extern MPID_Win *MPIDI_RMA_Win_active_list_head, *MPIDI_RMA_Win_inactive_list_head;
-
 typedef struct MPIDI_RMA_Target_lock_entry {
     struct MPIDI_RMA_Target_lock_entry *next;
     struct MPIDI_RMA_Target_lock_entry *prev;
diff --git a/src/mpid/ch3/include/mpidpre.h b/src/mpid/ch3/include/mpidpre.h
index 52675cc..bc61055 100644
--- a/src/mpid/ch3/include/mpidpre.h
+++ b/src/mpid/ch3/include/mpidpre.h
@@ -351,6 +351,8 @@ typedef struct MPIDI_Win_basic_info {
     struct MPID_Win *prev;                                              \
     struct MPID_Win *next;                                              \
 
+extern struct MPID_Win *MPIDI_RMA_Win_active_list_head, *MPIDI_RMA_Win_inactive_list_head;
+
 #ifdef MPIDI_CH3_WIN_DECL
 #define MPID_DEV_WIN_DECL \
 MPIDI_DEV_WIN_DECL \
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index f6e2557..82d0df4 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -867,7 +867,7 @@ int MPIDI_CH3I_RMA_Make_progress_global(int *made_progress)
 
     (*made_progress) = 0;
 
-    if (MPIDI_CH3I_num_active_issued_win == 0 && MPIDI_CH3I_num_passive_win == 0)
+    if (MPIDI_RMA_Win_active_list_head == NULL)
         goto fn_exit;
 
     for (win_ptr = MPIDI_RMA_Win_active_list_head; win_ptr; win_ptr = win_ptr->next) {
diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index d71da97..9b2c726 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -544,7 +544,6 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
 
                 /* Set window access state properly. */
                 win_ptr->states.access_state = MPIDI_RMA_FENCE_ISSUED;
-                MPIDI_CH3I_num_active_issued_win++;
 
                 MPID_Request_get_ptr(fence_sync_req, req_ptr);
                 if (!MPID_Request_is_complete(req_ptr)) {
@@ -661,7 +660,6 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
             else {
                 MPID_Request *req_ptr;
 
-                MPIDI_CH3I_num_active_issued_win++;
                 win_ptr->states.access_state = MPIDI_RMA_FENCE_ISSUED;
 
                 MPID_Request_get_ptr(fence_sync_req, req_ptr);
@@ -939,7 +937,6 @@ int MPID_Win_start(MPID_Group * group_ptr, int assert, MPID_Win * win_ptr)
 
     /* Set window access state properly. */
     win_ptr->states.access_state = MPIDI_RMA_PSCW_ISSUED;
-    MPIDI_CH3I_num_active_issued_win++;
 
     if (win_ptr->sync_request_cnt == 0) {
         win_ptr->states.access_state = MPIDI_RMA_PSCW_GRANTED;
@@ -1176,7 +1173,6 @@ int MPID_Win_lock(int lock_type, int dest, int assert, MPID_Win * win_ptr)
     if (win_ptr->lock_epoch_count == 0) {
         /* Set window access state properly. */
         win_ptr->states.access_state = MPIDI_RMA_PER_TARGET;
-        MPIDI_CH3I_num_passive_win++;
     }
     win_ptr->lock_epoch_count++;
 
@@ -1322,8 +1318,6 @@ int MPID_Win_unlock(int dest, MPID_Win * win_ptr)
     if (win_ptr->lock_epoch_count == 0) {
         /* Set window access state properly. */
         win_ptr->states.access_state = MPIDI_RMA_NONE;
-        MPIDI_CH3I_num_passive_win--;
-        MPIU_Assert(MPIDI_CH3I_num_passive_win >= 0);
     }
 
     if (target != NULL) {
@@ -1555,7 +1549,6 @@ int MPID_Win_lock_all(int assert, MPID_Win * win_ptr)
         win_ptr->states.access_state = MPIDI_RMA_LOCK_ALL_GRANTED;
     else
         win_ptr->states.access_state = MPIDI_RMA_LOCK_ALL_CALLED;
-    MPIDI_CH3I_num_passive_win++;
 
     win_ptr->lock_all_assert = assert;
 
@@ -1728,8 +1721,6 @@ int MPID_Win_unlock_all(MPID_Win * win_ptr)
 
     /* Set window access state properly. */
     win_ptr->states.access_state = MPIDI_RMA_NONE;
-    MPIDI_CH3I_num_passive_win--;
-    MPIU_Assert(MPIDI_CH3I_num_passive_win >= 0);
 
     /* reset lock_all assert on window. */
     win_ptr->lock_all_assert = 0;

http://git.mpich.org/mpich.git/commitdiff/720ab6bb4f0b7211ece7da875177690df2f6d3fd

commit 720ab6bb4f0b7211ece7da875177690df2f6d3fd
Author: Xin Zhao <xinzhao3 at illinois.edu>
Date:   Wed Jul 29 16:23:06 2015 -0500

    Delete unused function argument.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index f2bfc96..f6e2557 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -47,8 +47,7 @@ cvars:
 
 static inline int check_and_switch_target_state(MPID_Win * win_ptr, MPIDI_RMA_Target_t * target,
                                                 int *is_able_to_issue, int *made_progress);
-static inline int check_and_switch_window_state(MPID_Win * win_ptr, int *is_able_to_issue,
-                                                int *made_progress);
+static inline int check_and_switch_window_state(MPID_Win * win_ptr, int *is_able_to_issue);
 static inline int issue_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * target,
                                    int *made_progress);
 static inline int issue_ops_win(MPID_Win * win_ptr, int *made_progress);
@@ -58,15 +57,13 @@ static inline int issue_ops_win(MPID_Win * win_ptr, int *made_progress);
 #define FUNCNAME check_and_switch_window_state
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)
-static inline int check_and_switch_window_state(MPID_Win * win_ptr, int *is_able_to_issue,
-                                                int *made_progress)
+static inline int check_and_switch_window_state(MPID_Win * win_ptr, int *is_able_to_issue)
 {
     int mpi_errno = MPI_SUCCESS;
     MPIDI_STATE_DECL(MPID_STATE_CHECK_AND_SWITCH_WINDOW_STATE);
 
     MPIDI_RMA_FUNC_ENTER(MPID_STATE_CHECK_AND_SWITCH_WINDOW_STATE);
 
-    (*made_progress) = 0;
     (*is_able_to_issue) = 0;
 
     switch (win_ptr->states.access_state) {
@@ -773,11 +770,9 @@ int MPIDI_CH3I_RMA_Make_progress_target(MPID_Win * win_ptr, int target_rank, int
      * to re-entrant RMA progress endlessly. */
 
     /* check window state */
-    mpi_errno = check_and_switch_window_state(win_ptr, &is_able_to_issue, &temp_progress);
+    mpi_errno = check_and_switch_window_state(win_ptr, &is_able_to_issue);
     if (mpi_errno != MPI_SUCCESS)
         MPIU_ERR_POP(mpi_errno);
-    if (temp_progress)
-        (*made_progress) = 1;
     if (!is_able_to_issue) {
         mpi_errno = poke_progress_engine();
         if (mpi_errno)
@@ -838,11 +833,9 @@ int MPIDI_CH3I_RMA_Make_progress_win(MPID_Win * win_ptr, int *made_progress)
      * to re-entrant RMA progress endlessly. */
 
     /* check and try to switch window state */
-    mpi_errno = check_and_switch_window_state(win_ptr, &is_able_to_issue, &temp_progress);
+    mpi_errno = check_and_switch_window_state(win_ptr, &is_able_to_issue);
     if (mpi_errno != MPI_SUCCESS)
         MPIU_ERR_POP(mpi_errno);
-    if (temp_progress)
-        (*made_progress) = 1;
     if (!is_able_to_issue) {
         mpi_errno = poke_progress_engine();
         if (mpi_errno != MPI_SUCCESS)
@@ -887,11 +880,9 @@ int MPIDI_CH3I_RMA_Make_progress_global(int *made_progress)
             continue;
 
         /* check and try to switch window state */
-        mpi_errno = check_and_switch_window_state(win_ptr, &is_able_to_issue, &temp_progress);
+        mpi_errno = check_and_switch_window_state(win_ptr, &is_able_to_issue);
         if (mpi_errno != MPI_SUCCESS)
             MPIU_ERR_POP(mpi_errno);
-        if (temp_progress)
-            (*made_progress) = 1;
         if (!is_able_to_issue) {
             continue;
         }

http://git.mpich.org/mpich.git/commitdiff/751723eafd383e06c8a5328775d4fae58537cdad

commit 751723eafd383e06c8a5328775d4fae58537cdad
Author: Xin Zhao <xinzhao3 at illinois.edu>
Date:   Wed Jul 29 15:40:28 2015 -0500

    Delete window state switch in RMA progress.
    
    All window states switch can be done in a event-trigger manner: for
    Fence and PSCW, state can be switched from ISSUED to GRANTED in
    the request complete cb function; for LOCK_ALL, state can be switched
    in the packet handler. Here we move the window state switch from RMA
    progress function to request cb functions and packet handler.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/mpid/ch3/include/mpidpre.h b/src/mpid/ch3/include/mpidpre.h
index ecc6a73..52675cc 100644
--- a/src/mpid/ch3/include/mpidpre.h
+++ b/src/mpid/ch3/include/mpidpre.h
@@ -334,8 +334,6 @@ typedef struct MPIDI_Win_basic_info {
     int active_req_cnt; /* keep track of number of active requests in    \
                            current epoch, i.e., number of issued but     \
                            incomplete RMA operations. */                 \
-    MPI_Request fence_sync_req;                                          \
-    MPI_Request *start_req;                                              \
     int *start_ranks_in_win_grp;                                         \
     int start_grp_size;                                                  \
     int lock_all_assert;                                                 \
diff --git a/src/mpid/ch3/include/mpidrma.h b/src/mpid/ch3/include/mpidrma.h
index 06538cd..c0f843a 100644
--- a/src/mpid/ch3/include/mpidrma.h
+++ b/src/mpid/ch3/include/mpidrma.h
@@ -590,6 +590,8 @@ static inline int handle_lock_ack(MPID_Win * win_ptr, int target_rank, MPIDI_CH3
             win_ptr->outstanding_locks--;
             MPIU_Assert(win_ptr->outstanding_locks >= 0);
             if (win_ptr->outstanding_locks == 0) {
+                win_ptr->states.access_state = MPIDI_RMA_LOCK_ALL_GRANTED;
+
                 if (win_ptr->num_targets_with_pending_ops) {
                     mpi_errno = MPIDI_CH3I_Win_set_active(win_ptr);
                     if (mpi_errno != MPI_SUCCESS) {
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index 9be5eae..f2bfc96 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -61,8 +61,7 @@ static inline int issue_ops_win(MPID_Win * win_ptr, int *made_progress);
 static inline int check_and_switch_window_state(MPID_Win * win_ptr, int *is_able_to_issue,
                                                 int *made_progress)
 {
-    MPID_Request *fence_req_ptr = NULL;
-    int i, mpi_errno = MPI_SUCCESS;
+    int mpi_errno = MPI_SUCCESS;
     MPIDI_STATE_DECL(MPID_STATE_CHECK_AND_SWITCH_WINDOW_STATE);
 
     MPIDI_RMA_FUNC_ENTER(MPID_STATE_CHECK_AND_SWITCH_WINDOW_STATE);
@@ -71,73 +70,6 @@ static inline int check_and_switch_window_state(MPID_Win * win_ptr, int *is_able
     (*is_able_to_issue) = 0;
 
     switch (win_ptr->states.access_state) {
-    case MPIDI_RMA_FENCE_ISSUED:
-        MPID_Request_get_ptr(win_ptr->fence_sync_req, fence_req_ptr);
-        if (MPID_Request_is_complete(fence_req_ptr)) {
-            win_ptr->states.access_state = MPIDI_RMA_FENCE_GRANTED;
-            (*is_able_to_issue) = 1;
-
-            MPID_Request_release(fence_req_ptr);
-            win_ptr->fence_sync_req = MPI_REQUEST_NULL;
-
-            MPIDI_CH3I_num_active_issued_win--;
-            MPIU_Assert(MPIDI_CH3I_num_active_issued_win >= 0);
-
-            (*made_progress) = 1;
-        }
-        break;
-
-    case MPIDI_RMA_PSCW_ISSUED:
-        if (win_ptr->start_req == NULL) {
-            /* for MPI_MODE_NOCHECK and all targets on SHM,
-             * we do not create PSCW requests on window. */
-            win_ptr->states.access_state = MPIDI_RMA_PSCW_GRANTED;
-            (*is_able_to_issue) = 1;
-
-            MPIDI_CH3I_num_active_issued_win--;
-            MPIU_Assert(MPIDI_CH3I_num_active_issued_win >= 0);
-
-            (*made_progress) = 1;
-        }
-        else {
-            for (i = 0; i < win_ptr->start_grp_size; i++) {
-                MPID_Request *start_req_ptr = NULL;
-                if (win_ptr->start_req[i] == MPI_REQUEST_NULL)
-                    continue;
-                MPID_Request_get_ptr(win_ptr->start_req[i], start_req_ptr);
-                if (MPID_Request_is_complete(start_req_ptr)) {
-                    MPID_Request_release(start_req_ptr);
-                    win_ptr->start_req[i] = MPI_REQUEST_NULL;
-                }
-                else {
-                    break;
-                }
-            }
-
-            if (i == win_ptr->start_grp_size) {
-                win_ptr->states.access_state = MPIDI_RMA_PSCW_GRANTED;
-                (*is_able_to_issue) = 1;
-
-                MPIDI_CH3I_num_active_issued_win--;
-                MPIU_Assert(MPIDI_CH3I_num_active_issued_win >= 0);
-
-                (*made_progress) = 1;
-
-                MPIU_Free(win_ptr->start_req);
-                win_ptr->start_req = NULL;
-            }
-        }
-        break;
-
-    case MPIDI_RMA_LOCK_ALL_ISSUED:
-        if (win_ptr->outstanding_locks == 0) {
-            win_ptr->states.access_state = MPIDI_RMA_LOCK_ALL_GRANTED;
-            (*is_able_to_issue) = 1;
-
-            (*made_progress) = 1;
-        }
-        break;
-
     case MPIDI_RMA_PER_TARGET:
     case MPIDI_RMA_LOCK_ALL_CALLED:
     case MPIDI_RMA_FENCE_GRANTED:
diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index a9c23fa..d71da97 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -520,18 +520,7 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
             goto finish_fence;
         }
         else {
-            /* It is possible that there is a IBARRIER in MPI_WIN_FENCE with
-             * MODE_NOPRECEDE not being completed, we let the progress engine
-             * to delete its request when it is completed. */
-            if (win_ptr->fence_sync_req != MPI_REQUEST_NULL) {
-                MPID_Request *req_ptr;
-                MPID_Request_get_ptr(win_ptr->fence_sync_req, req_ptr);
-                MPID_Request_release(req_ptr);
-                win_ptr->fence_sync_req = MPI_REQUEST_NULL;
-                win_ptr->states.access_state = MPIDI_RMA_NONE;
-                MPIDI_CH3I_num_active_issued_win--;
-                MPIU_Assert(MPIDI_CH3I_num_active_issued_win >= 0);
-            }
+            MPI_Request fence_sync_req;
 
             if (win_ptr->shm_allocated == TRUE) {
                 MPID_Comm *node_comm_ptr = win_ptr->comm_ptr->node_comm;
@@ -542,11 +531,11 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
                 MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
             }
 
-            mpi_errno = MPIR_Ibarrier_impl(win_ptr->comm_ptr, &(win_ptr->fence_sync_req));
+            mpi_errno = MPIR_Ibarrier_impl(win_ptr->comm_ptr, &fence_sync_req);
             if (mpi_errno != MPI_SUCCESS)
                 MPIU_ERR_POP(mpi_errno);
 
-            if (win_ptr->fence_sync_req == MPI_REQUEST_NULL) {
+            if (fence_sync_req == MPI_REQUEST_NULL) {
                 /* ibarrier completed immediately. */
                 win_ptr->states.access_state = MPIDI_RMA_FENCE_GRANTED;
             }
@@ -557,7 +546,7 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
                 win_ptr->states.access_state = MPIDI_RMA_FENCE_ISSUED;
                 MPIDI_CH3I_num_active_issued_win++;
 
-                MPID_Request_get_ptr(win_ptr->fence_sync_req, req_ptr);
+                MPID_Request_get_ptr(fence_sync_req, req_ptr);
                 if (!MPID_Request_is_complete(req_ptr)) {
                     req_ptr->dev.source_win_handle = win_ptr->handle;
                     req_ptr->request_completed_cb = fence_barrier_complete;
@@ -567,6 +556,8 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
                     /* ibarrier completed immediately. */
                     win_ptr->states.access_state = MPIDI_RMA_FENCE_GRANTED;
                 }
+
+                MPID_Request_release(req_ptr);
             }
 
             goto finish_fence;
@@ -575,18 +566,6 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
 
     /* Perform basic algorithm by calling reduce-scatter */
     if (!scalable_fence_enabled) {
-        /* If the IBARRIER is not completed, do not need to wait for
-         * it since we are going to call reduce-scatter */
-        if (win_ptr->fence_sync_req != MPI_REQUEST_NULL) {
-            MPID_Request *req_ptr;
-            MPID_Request_get_ptr(win_ptr->fence_sync_req, req_ptr);
-            MPID_Request_release(req_ptr);
-            win_ptr->fence_sync_req = MPI_REQUEST_NULL;
-            MPIDI_CH3I_num_active_issued_win--;
-            MPIU_Assert(MPIDI_CH3I_num_active_issued_win >= 0);
-
-            win_ptr->states.access_state = MPIDI_RMA_NONE;
-        }
         MPIU_CHKLMEM_MALLOC(rma_target_marks, int *, comm_size * sizeof(int),
                             mpi_errno, "rma_target_marks");
         for (i = 0; i < comm_size; i++)
@@ -668,12 +647,14 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
             win_ptr->states.access_state = MPIDI_RMA_NONE;
         }
         else {
+            MPI_Request fence_sync_req;
+
             /* Prepare for the next possible epoch */
-            mpi_errno = MPIR_Ibarrier_impl(win_ptr->comm_ptr, &(win_ptr->fence_sync_req));
+            mpi_errno = MPIR_Ibarrier_impl(win_ptr->comm_ptr, &fence_sync_req);
             if (mpi_errno != MPI_SUCCESS)
                 MPIU_ERR_POP(mpi_errno);
 
-            if (win_ptr->fence_sync_req == MPI_REQUEST_NULL) {
+            if (fence_sync_req == MPI_REQUEST_NULL) {
                 /* ibarrier completed immediately. */
                 win_ptr->states.access_state = MPIDI_RMA_FENCE_GRANTED;
             }
@@ -683,7 +664,7 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
                 MPIDI_CH3I_num_active_issued_win++;
                 win_ptr->states.access_state = MPIDI_RMA_FENCE_ISSUED;
 
-                MPID_Request_get_ptr(win_ptr->fence_sync_req, req_ptr);
+                MPID_Request_get_ptr(fence_sync_req, req_ptr);
                 if (!MPID_Request_is_complete(req_ptr)) {
                     req_ptr->dev.source_win_handle = win_ptr->handle;
                     req_ptr->request_completed_cb = fence_barrier_complete;
@@ -693,6 +674,8 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
                     /* ibarrier completed immediately. */
                     win_ptr->states.access_state = MPIDI_RMA_FENCE_GRANTED;
                 }
+
+                MPID_Request_release(req_ptr);
             }
 
             if (win_ptr->shm_allocated == TRUE) {
@@ -862,7 +845,7 @@ int MPID_Win_start(MPID_Group * group_ptr, int assert, MPID_Win * win_ptr)
 {
     int mpi_errno = MPI_SUCCESS;
     MPIU_CHKLMEM_DECL(2);
-    MPIU_CHKPMEM_DECL(2);
+    MPIU_CHKPMEM_DECL(1);
     MPIDI_STATE_DECL(MPID_STATE_MPID_WIN_START);
 
     MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPID_WIN_START);
@@ -897,10 +880,6 @@ int MPID_Win_start(MPID_Group * group_ptr, int assert, MPID_Win * win_ptr)
         /* wait for messages from local processes */
 
         /* post IRECVs */
-        MPIU_CHKPMEM_MALLOC(win_ptr->start_req, MPI_Request *,
-                            win_ptr->start_grp_size * sizeof(MPI_Request),
-                            mpi_errno, "win_ptr->start_req");
-
         if (win_ptr->shm_allocated == TRUE) {
             int node_comm_size = comm_ptr->node_comm->local_size;
             MPIU_CHKLMEM_MALLOC(intra_start_req, MPI_Request *,
@@ -927,23 +906,17 @@ int MPID_Win_start(MPID_Group * group_ptr, int assert, MPID_Win * win_ptr)
 
                 if (win_ptr->shm_allocated == TRUE && orig_vc->node_id == target_vc->node_id) {
                     intra_start_req[intra_cnt++] = req_ptr->handle;
-                    win_ptr->start_req[i] = MPI_REQUEST_NULL;
                 }
                 else {
-                    if (MPID_Request_is_complete(req_ptr)) {
-                        win_ptr->start_req[i] = MPI_REQUEST_NULL;
-                    }
-                    else {
-                        win_ptr->start_req[i] = req_ptr->handle;
+                    if (!MPID_Request_is_complete(req_ptr)) {
                         req_ptr->dev.source_win_handle = win_ptr->handle;
                         req_ptr->request_completed_cb = start_req_complete;
                         win_ptr->sync_request_cnt++;
                     }
+
+                    MPID_Request_release(req_ptr);
                 }
             }
-            else {
-                win_ptr->start_req[i] = MPI_REQUEST_NULL;
-            }
         }
 
         /* for targets on SHM, waiting until their IRECVs to be finished */
@@ -1059,7 +1032,6 @@ int MPID_Win_complete(MPID_Win * win_ptr)
     /* free start group stored in window */
     MPIU_Free(win_ptr->start_ranks_in_win_grp);
     win_ptr->start_ranks_in_win_grp = NULL;
-    MPIU_Assert(win_ptr->start_req == NULL);
 
     MPIU_Assert(win_ptr->active_req_cnt == 0);
 
diff --git a/src/mpid/ch3/src/mpid_rma.c b/src/mpid/ch3/src/mpid_rma.c
index 7685e5f..4bc238a 100644
--- a/src/mpid/ch3/src/mpid_rma.c
+++ b/src/mpid/ch3/src/mpid_rma.c
@@ -290,8 +290,6 @@ static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
     (*win_ptr)->states.exposure_state = MPIDI_RMA_NONE;
     (*win_ptr)->num_targets_with_pending_ops = 0;
     (*win_ptr)->active_req_cnt = 0;
-    (*win_ptr)->fence_sync_req = MPI_REQUEST_NULL;
-    (*win_ptr)->start_req = NULL;
     (*win_ptr)->start_ranks_in_win_grp = NULL;
     (*win_ptr)->start_grp_size = 0;
     (*win_ptr)->lock_all_assert = 0;
diff --git a/src/mpid/ch3/src/mpidi_rma.c b/src/mpid/ch3/src/mpidi_rma.c
index 26b5741..1a24bb4 100644
--- a/src/mpid/ch3/src/mpidi_rma.c
+++ b/src/mpid/ch3/src/mpidi_rma.c
@@ -159,14 +159,6 @@ int MPID_Win_free(MPID_Win ** win_ptr)
                         ((*win_ptr)->states.exposure_state != MPIDI_RMA_NONE),
                         mpi_errno, MPI_ERR_RMA_SYNC, "**rmasync");
 
-    if ((*win_ptr)->fence_sync_req != MPI_REQUEST_NULL) {
-        /* If the ibarrier for previous FENCE is not completed,
-         * set the window state to FENCE_ISSUED here, so that
-         * wait_progress_engine() will enter RMA progress and
-         * try to swtich the window state when ibarrier is completed. */
-        (*win_ptr)->states.access_state = MPIDI_RMA_FENCE_ISSUED;
-    }
-
     /* 1. Here we must wait until all passive locks are released on this target,
      * because for some UNLOCK messages, we do not send ACK back to origin,
      * we must wait until lock is released so that we can free window.
@@ -180,8 +172,7 @@ int MPID_Win_free(MPID_Win ** win_ptr)
     while ((*win_ptr)->current_lock_type != MPID_LOCK_NONE ||
            (*win_ptr)->at_completion_counter != 0 ||
            (*win_ptr)->target_lock_queue_head != NULL ||
-           (*win_ptr)->current_target_lock_data_bytes != 0 ||
-           (*win_ptr)->fence_sync_req != MPI_REQUEST_NULL || (*win_ptr)->sync_request_cnt != 0) {
+           (*win_ptr)->current_target_lock_data_bytes != 0 || (*win_ptr)->sync_request_cnt != 0) {
         mpi_errno = wait_progress_engine();
         if (mpi_errno != MPI_SUCCESS)
             MPIU_ERR_POP(mpi_errno);

http://git.mpich.org/mpich.git/commitdiff/7857e9aabdb291215edaf6fa6eb6940116a44e56

commit 7857e9aabdb291215edaf6fa6eb6940116a44e56
Author: Pavan Balaji <balaji at anl.gov>
Date:   Tue Jul 28 23:38:54 2015 -0500

    Set window to active when receiving Lock ACK.
    
    Here we activate th window when lock is granted and
    there are pending operations.
    
    We also delete the activation/de-activation code in the opening
    and the ending synchronization calls for Passive Target which were
    originally added for debugging.
    
    When a new op is enqueued / all operations are issued out, we
    activate the window / de-activate the window under Passive
    Target states.
    
    Signed-off-by: Xin Zhao <xinzhao3 at illinois.edu>

diff --git a/src/mpid/ch3/include/mpid_rma_oplist.h b/src/mpid/ch3/include/mpid_rma_oplist.h
index 76a8e48..bfdee1b 100644
--- a/src/mpid/ch3/include/mpid_rma_oplist.h
+++ b/src/mpid/ch3/include/mpid_rma_oplist.h
@@ -443,7 +443,9 @@ static inline int MPIDI_CH3I_Win_enqueue_op(MPID_Win * win_ptr, MPIDI_RMA_Op_t *
         target->next_op_to_issue = op;
 
     if (win_ptr->states.access_state == MPIDI_RMA_FENCE_GRANTED ||
-        win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED)
+        win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED ||
+        win_ptr->states.access_state == MPIDI_RMA_LOCK_ALL_GRANTED ||
+        target->access_state == MPIDI_RMA_LOCK_GRANTED)
         MPIDI_CH3I_Win_set_active(win_ptr);
 
   fn_exit:
diff --git a/src/mpid/ch3/include/mpidrma.h b/src/mpid/ch3/include/mpidrma.h
index 9f397b5..06538cd 100644
--- a/src/mpid/ch3/include/mpidrma.h
+++ b/src/mpid/ch3/include/mpidrma.h
@@ -589,6 +589,14 @@ static inline int handle_lock_ack(MPID_Win * win_ptr, int target_rank, MPIDI_CH3
         if (flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED) {
             win_ptr->outstanding_locks--;
             MPIU_Assert(win_ptr->outstanding_locks >= 0);
+            if (win_ptr->outstanding_locks == 0) {
+                if (win_ptr->num_targets_with_pending_ops) {
+                    mpi_errno = MPIDI_CH3I_Win_set_active(win_ptr);
+                    if (mpi_errno != MPI_SUCCESS) {
+                        MPIU_ERR_POP(mpi_errno);
+                    }
+                }
+            }
         }
         else if (flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_DISCARDED) {
             /* re-send lock request message. */
@@ -604,8 +612,11 @@ static inline int handle_lock_ack(MPID_Win * win_ptr, int target_rank, MPIDI_CH3
         MPIU_ERR_POP(mpi_errno);
     MPIU_Assert(t != NULL);
 
-    if (flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED)
+    if (flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED) {
         t->access_state = MPIDI_RMA_LOCK_GRANTED;
+        if (t->pending_op_list_head)
+            MPIDI_CH3I_Win_set_active(win_ptr);
+    }
 
     if (win_ptr->states.access_state == MPIDI_RMA_LOCK_ALL_GRANTED ||
         t->access_state == MPIDI_RMA_LOCK_GRANTED) {
@@ -697,11 +708,8 @@ static inline int handle_lock_ack_with_op(MPID_Win * win_ptr,
         if (target->pending_op_list_head == NULL) {
             win_ptr->num_targets_with_pending_ops--;
             MPIU_Assert(win_ptr->num_targets_with_pending_ops >= 0);
-            if (win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED ||
-                win_ptr->states.access_state == MPIDI_RMA_FENCE_GRANTED) {
-                if (win_ptr->num_targets_with_pending_ops == 0) {
-                    MPIDI_CH3I_Win_set_inactive(win_ptr);
-                }
+            if (win_ptr->num_targets_with_pending_ops == 0) {
+                MPIDI_CH3I_Win_set_inactive(win_ptr);
             }
         }
     }
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index 5173b76..9be5eae 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -381,11 +381,8 @@ static inline int check_and_set_req_completion(MPID_Win * win_ptr, MPIDI_RMA_Tar
     if (target->pending_op_list_head == NULL) {
         win_ptr->num_targets_with_pending_ops--;
         MPIU_Assert(win_ptr->num_targets_with_pending_ops >= 0);
-        if (win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED ||
-            win_ptr->states.access_state == MPIDI_RMA_FENCE_GRANTED) {
-            if (win_ptr->num_targets_with_pending_ops == 0) {
-                MPIDI_CH3I_Win_set_inactive(win_ptr);
-            }
+        if (win_ptr->num_targets_with_pending_ops == 0) {
+            MPIDI_CH3I_Win_set_inactive(win_ptr);
         }
     }
 
diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index e1885a5..a9c23fa 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -1205,12 +1205,6 @@ int MPID_Win_lock(int lock_type, int dest, int assert, MPID_Win * win_ptr)
         /* Set window access state properly. */
         win_ptr->states.access_state = MPIDI_RMA_PER_TARGET;
         MPIDI_CH3I_num_passive_win++;
-
-        /* mark the window as active */
-        mpi_errno = MPIDI_CH3I_Win_set_active(win_ptr);
-        if (mpi_errno) {
-            MPIU_ERR_POP(mpi_errno);
-        }
     }
     win_ptr->lock_epoch_count++;
 
@@ -1358,12 +1352,6 @@ int MPID_Win_unlock(int dest, MPID_Win * win_ptr)
         win_ptr->states.access_state = MPIDI_RMA_NONE;
         MPIDI_CH3I_num_passive_win--;
         MPIU_Assert(MPIDI_CH3I_num_passive_win >= 0);
-
-        /* mark the window as inactive */
-        mpi_errno = MPIDI_CH3I_Win_set_inactive(win_ptr);
-        if (mpi_errno) {
-            MPIU_ERR_POP(mpi_errno);
-        }
     }
 
     if (target != NULL) {
@@ -1590,12 +1578,6 @@ int MPID_Win_lock_all(int assert, MPID_Win * win_ptr)
                         win_ptr->states.access_state != MPIDI_RMA_FENCE_GRANTED,
                         mpi_errno, MPI_ERR_RMA_SYNC, "**rmasync");
 
-    /* mark the window as active */
-    mpi_errno = MPIDI_CH3I_Win_set_active(win_ptr);
-    if (mpi_errno) {
-        MPIU_ERR_POP(mpi_errno);
-    }
-
     /* Set window access state properly. */
     if (assert & MPI_MODE_NOCHECK)
         win_ptr->states.access_state = MPIDI_RMA_LOCK_ALL_GRANTED;
@@ -1782,12 +1764,6 @@ int MPID_Win_unlock_all(MPID_Win * win_ptr)
 
     MPIU_Assert(win_ptr->active_req_cnt == 0);
 
-    /* mark the window as inactive */
-    mpi_errno = MPIDI_CH3I_Win_set_inactive(win_ptr);
-    if (mpi_errno) {
-        MPIU_ERR_POP(mpi_errno);
-    }
-
   fn_exit:
     MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPID_WIN_UNLOCK_ALL);
     return mpi_errno;

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

commit b3e784426aa2ee35bbf6a0946e412fc91a3c55df
Author: Xin Zhao <xinzhao3 at illinois.edu>
Date:   Wed Jul 29 13:27:15 2015 -0500

    Modify Fence cb function to activate/de-activate window.
    
    Same with PSCW, after all previous ibarrier requests are
    completed, the cb function will activate/de-activate the
    current window, depending on if there are pending operations.
    
    We also delete the activation/de-activation code in the opening
    and the ending synchronization calls for FENCE which were
    originally added for debugging.
    
    When a new op is enqueued / all operations are issued out, we
    activate the window / de-activate the window under FENCE state.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/mpid/ch3/include/mpid_rma_oplist.h b/src/mpid/ch3/include/mpid_rma_oplist.h
index 0693d34..76a8e48 100644
--- a/src/mpid/ch3/include/mpid_rma_oplist.h
+++ b/src/mpid/ch3/include/mpid_rma_oplist.h
@@ -442,7 +442,8 @@ static inline int MPIDI_CH3I_Win_enqueue_op(MPID_Win * win_ptr, MPIDI_RMA_Op_t *
     if (target->next_op_to_issue == NULL)
         target->next_op_to_issue = op;
 
-    if (win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED)
+    if (win_ptr->states.access_state == MPIDI_RMA_FENCE_GRANTED ||
+        win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED)
         MPIDI_CH3I_Win_set_active(win_ptr);
 
   fn_exit:
diff --git a/src/mpid/ch3/include/mpidrma.h b/src/mpid/ch3/include/mpidrma.h
index f18d783..9f397b5 100644
--- a/src/mpid/ch3/include/mpidrma.h
+++ b/src/mpid/ch3/include/mpidrma.h
@@ -697,7 +697,8 @@ static inline int handle_lock_ack_with_op(MPID_Win * win_ptr,
         if (target->pending_op_list_head == NULL) {
             win_ptr->num_targets_with_pending_ops--;
             MPIU_Assert(win_ptr->num_targets_with_pending_ops >= 0);
-            if (win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED) {
+            if (win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED ||
+                win_ptr->states.access_state == MPIDI_RMA_FENCE_GRANTED) {
                 if (win_ptr->num_targets_with_pending_ops == 0) {
                     MPIDI_CH3I_Win_set_inactive(win_ptr);
                 }
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index 2c952b9..5173b76 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -381,7 +381,8 @@ static inline int check_and_set_req_completion(MPID_Win * win_ptr, MPIDI_RMA_Tar
     if (target->pending_op_list_head == NULL) {
         win_ptr->num_targets_with_pending_ops--;
         MPIU_Assert(win_ptr->num_targets_with_pending_ops >= 0);
-        if (win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED) {
+        if (win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED ||
+            win_ptr->states.access_state == MPIDI_RMA_FENCE_GRANTED) {
             if (win_ptr->num_targets_with_pending_ops == 0) {
                 MPIDI_CH3I_Win_set_inactive(win_ptr);
             }
diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index 87a6fda..e1885a5 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -454,6 +454,19 @@ static int fence_barrier_complete(MPID_Request * sreq)
     win_ptr->sync_request_cnt--;
     MPIU_Assert(win_ptr->sync_request_cnt >= 0);
 
+    if (win_ptr->sync_request_cnt == 0) {
+        if (win_ptr->states.access_state == MPIDI_RMA_FENCE_ISSUED) {
+            win_ptr->states.access_state = MPIDI_RMA_FENCE_GRANTED;
+
+            if (win_ptr->num_targets_with_pending_ops) {
+                mpi_errno = MPIDI_CH3I_Win_set_active(win_ptr);
+                if (mpi_errno != MPI_SUCCESS) {
+                    MPIU_ERR_POP(mpi_errno);
+                }
+            }
+        }
+    }
+
   fn_exit:
     MPIDI_FUNC_EXIT(MPID_STATE_FENCE_BARRIER_COMPLETE);
     return mpi_errno;
@@ -492,14 +505,6 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
                         win_ptr->states.exposure_state != MPIDI_RMA_NONE,
                         mpi_errno, MPI_ERR_RMA_SYNC, "**rmasync");
 
-    if (!(assert & MPI_MODE_NOSUCCEED)) {
-        /* mark the window as active */
-        mpi_errno = MPIDI_CH3I_Win_set_active(win_ptr);
-        if (mpi_errno) {
-            MPIU_ERR_POP(mpi_errno);
-        }
-    }
-
     /* Judge if we should switch to scalable FENCE algorithm */
     if (comm_size >= MPIR_CVAR_CH3_RMA_SCALABLE_FENCE_PROCESS_NUM) {
         scalable_fence_enabled = 1;
@@ -558,6 +563,10 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
                     req_ptr->request_completed_cb = fence_barrier_complete;
                     win_ptr->sync_request_cnt++;
                 }
+                else {
+                    /* ibarrier completed immediately. */
+                    win_ptr->states.access_state = MPIDI_RMA_FENCE_GRANTED;
+                }
             }
 
             goto finish_fence;
@@ -657,12 +666,6 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
 
         if (assert & MPI_MODE_NOSUCCEED) {
             win_ptr->states.access_state = MPIDI_RMA_NONE;
-
-            /* mark the window as inactive */
-            mpi_errno = MPIDI_CH3I_Win_set_inactive(win_ptr);
-            if (mpi_errno) {
-                MPIU_ERR_POP(mpi_errno);
-            }
         }
         else {
             /* Prepare for the next possible epoch */
@@ -686,6 +689,10 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
                     req_ptr->request_completed_cb = fence_barrier_complete;
                     win_ptr->sync_request_cnt++;
                 }
+                else {
+                    /* ibarrier completed immediately. */
+                    win_ptr->states.access_state = MPIDI_RMA_FENCE_GRANTED;
+                }
             }
 
             if (win_ptr->shm_allocated == TRUE) {

http://git.mpich.org/mpich.git/commitdiff/2c11094da38763c5eec5495b0cf70d3e15994dba

commit 2c11094da38763c5eec5495b0cf70d3e15994dba
Author: Pavan Balaji <balaji at anl.gov>
Date:   Tue Jul 28 23:12:27 2015 -0500

    Add a callback for PSCW request completions.
    
    Here the callback function will activate/de-activate the
    window after all requests for PSCW are completed.
    
    We also delete the activation/de-activation code in the opening
    and the ending synchronization calls for PSCW which were
    originally added for debugging.
    
    When a new op is enqueued / all operations are issued out, we
    activate the window / de-activate the window under PSCW state.
    
    Signed-off-by: Xin Zhao <xinzhao3 at illinois.edu>

diff --git a/src/mpid/ch3/include/mpid_rma_oplist.h b/src/mpid/ch3/include/mpid_rma_oplist.h
index 21df432..0693d34 100644
--- a/src/mpid/ch3/include/mpid_rma_oplist.h
+++ b/src/mpid/ch3/include/mpid_rma_oplist.h
@@ -442,6 +442,9 @@ static inline int MPIDI_CH3I_Win_enqueue_op(MPID_Win * win_ptr, MPIDI_RMA_Op_t *
     if (target->next_op_to_issue == NULL)
         target->next_op_to_issue = op;
 
+    if (win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED)
+        MPIDI_CH3I_Win_set_active(win_ptr);
+
   fn_exit:
     return mpi_errno;
   fn_fail:
diff --git a/src/mpid/ch3/include/mpidrma.h b/src/mpid/ch3/include/mpidrma.h
index 967857e..f18d783 100644
--- a/src/mpid/ch3/include/mpidrma.h
+++ b/src/mpid/ch3/include/mpidrma.h
@@ -697,6 +697,11 @@ static inline int handle_lock_ack_with_op(MPID_Win * win_ptr,
         if (target->pending_op_list_head == NULL) {
             win_ptr->num_targets_with_pending_ops--;
             MPIU_Assert(win_ptr->num_targets_with_pending_ops >= 0);
+            if (win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED) {
+                if (win_ptr->num_targets_with_pending_ops == 0) {
+                    MPIDI_CH3I_Win_set_inactive(win_ptr);
+                }
+            }
         }
     }
     else if (flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_QUEUED_DATA_DISCARDED ||
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index 6d883cd..2c952b9 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -381,6 +381,11 @@ static inline int check_and_set_req_completion(MPID_Win * win_ptr, MPIDI_RMA_Tar
     if (target->pending_op_list_head == NULL) {
         win_ptr->num_targets_with_pending_ops--;
         MPIU_Assert(win_ptr->num_targets_with_pending_ops >= 0);
+        if (win_ptr->states.access_state == MPIDI_RMA_PSCW_GRANTED) {
+            if (win_ptr->num_targets_with_pending_ops == 0) {
+                MPIDI_CH3I_Win_set_inactive(win_ptr);
+            }
+        }
     }
 
   fn_exit:
diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index 3a2afdc..87a6fda 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -815,6 +815,39 @@ int MPID_Win_post(MPID_Group * post_grp_ptr, int assert, MPID_Win * win_ptr)
 }
 
 #undef FUNCNAME
+#define FUNCNAME start_req_complete
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+static int start_req_complete(MPID_Request * req)
+{
+    int mpi_errno = MPI_SUCCESS;
+    MPID_Win *win_ptr = NULL;
+
+    MPIDI_STATE_DECL(MPID_STATE_START_REQ_COMPLETE);
+    MPIDI_FUNC_ENTER(MPID_STATE_START_REQ_COMPLETE);
+
+    MPID_Win_get_ptr(req->dev.source_win_handle, win_ptr);
+    MPIU_Assert(win_ptr != NULL);
+
+    win_ptr->sync_request_cnt--;
+    MPIU_Assert(win_ptr->sync_request_cnt >= 0);
+
+    if (win_ptr->sync_request_cnt == 0) {
+        win_ptr->states.access_state = MPIDI_RMA_PSCW_GRANTED;
+
+        if (win_ptr->num_targets_with_pending_ops)
+            MPIDI_CH3I_Win_set_active(win_ptr);
+    }
+
+  fn_exit:
+    MPIDI_FUNC_EXIT(MPID_STATE_START_REQ_COMPLETE);
+    return mpi_errno;
+
+  fn_fail:
+    goto fn_exit;
+}
+
+#undef FUNCNAME
 #define FUNCNAME MPID_Win_start
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)
@@ -837,12 +870,6 @@ int MPID_Win_start(MPID_Group * group_ptr, int assert, MPID_Win * win_ptr)
                         win_ptr->states.access_state != MPIDI_RMA_FENCE_GRANTED,
                         mpi_errno, MPI_ERR_RMA_SYNC, "**rmasync");
 
-    /* mark the window as active */
-    mpi_errno = MPIDI_CH3I_Win_set_active(win_ptr);
-    if (mpi_errno) {
-        MPIU_ERR_POP(mpi_errno);
-    }
-
     win_ptr->start_grp_size = group_ptr->size;
 
     MPIU_CHKPMEM_MALLOC(win_ptr->start_ranks_in_win_grp, int *,
@@ -896,7 +923,15 @@ int MPID_Win_start(MPID_Group * group_ptr, int assert, MPID_Win * win_ptr)
                     win_ptr->start_req[i] = MPI_REQUEST_NULL;
                 }
                 else {
-                    win_ptr->start_req[i] = req_ptr->handle;
+                    if (MPID_Request_is_complete(req_ptr)) {
+                        win_ptr->start_req[i] = MPI_REQUEST_NULL;
+                    }
+                    else {
+                        win_ptr->start_req[i] = req_ptr->handle;
+                        req_ptr->dev.source_win_handle = win_ptr->handle;
+                        req_ptr->request_completed_cb = start_req_complete;
+                        win_ptr->sync_request_cnt++;
+                    }
                 }
             }
             else {
@@ -926,6 +961,10 @@ int MPID_Win_start(MPID_Group * group_ptr, int assert, MPID_Win * win_ptr)
     win_ptr->states.access_state = MPIDI_RMA_PSCW_ISSUED;
     MPIDI_CH3I_num_active_issued_win++;
 
+    if (win_ptr->sync_request_cnt == 0) {
+        win_ptr->states.access_state = MPIDI_RMA_PSCW_GRANTED;
+    }
+
     MPIU_Assert(win_ptr->active_req_cnt == 0);
 
     /* Ensure ordering of load/store operations. */
@@ -1017,12 +1056,6 @@ int MPID_Win_complete(MPID_Win * win_ptr)
 
     MPIU_Assert(win_ptr->active_req_cnt == 0);
 
-    /* mark the window as inactive */
-    mpi_errno = MPIDI_CH3I_Win_set_inactive(win_ptr);
-    if (mpi_errno != MPI_SUCCESS) {
-        MPIU_ERR_POP(mpi_errno);
-    }
-
   fn_exit:
     MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPID_WIN_COMPLETE);
     return mpi_errno;

http://git.mpich.org/mpich.git/commitdiff/0580240953d2b5a14abc438cba2165c48e544ef2

commit 0580240953d2b5a14abc438cba2165c48e544ef2
Author: Xin Zhao <xinzhao3 at illinois.edu>
Date:   Wed Jul 29 15:13:37 2015 -0500

    Add active/inactive window lists.
    
    Here we introduce active window list and inactive window list:
    
    (1) Active window means that CH3 has work to do on such window
    even though there is no user event (e.g. MPI calls is posted)
    and network event (e.g. sending/receiving request is completed,
    a packet is received) happening.
    
    (2) Inactive window means that CH3 does not have work to do
    on such window unless there are user events or network events
    happening.
    
    In this patch we use a simple approach where we activate each window
    when opening an access epoch and deactivate it when closing an epoch.
    A more sophisticated approach would be to activate the window based on
    what operations are queued up.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/mpid/ch3/include/mpid_rma_oplist.h b/src/mpid/ch3/include/mpid_rma_oplist.h
index f3e5a1c..21df432 100644
--- a/src/mpid/ch3/include/mpid_rma_oplist.h
+++ b/src/mpid/ch3/include/mpid_rma_oplist.h
@@ -148,6 +148,48 @@ MPIR_T_PVAR_DOUBLE_TIMER_DECL_EXTERN(RMA, rma_rmaqueue_alloc);
      &(win_ptr_)->slots[(rank_)])
 
 
+#undef FUNCNAME
+#define FUNCNAME MPIDI_CH3I_Win_set_active
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+static inline int MPIDI_CH3I_Win_set_active(MPID_Win * win_ptr)
+{
+    int mpi_errno = MPI_SUCCESS;
+
+    if (win_ptr->active == FALSE) {
+        win_ptr->active = TRUE;
+        MPL_DL_DELETE(MPIDI_RMA_Win_inactive_list_head, win_ptr);
+        MPL_DL_APPEND(MPIDI_RMA_Win_active_list_head, win_ptr);
+    }
+
+  fn_exit:
+    return mpi_errno;
+  fn_fail:
+    goto fn_exit;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDI_CH3I_Win_set_inactive
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+static inline int MPIDI_CH3I_Win_set_inactive(MPID_Win * win_ptr)
+{
+    int mpi_errno = MPI_SUCCESS;
+
+    if (win_ptr->active == TRUE) {
+        win_ptr->active = FALSE;
+        MPL_DL_DELETE(MPIDI_RMA_Win_active_list_head, win_ptr);
+        MPL_DL_APPEND(MPIDI_RMA_Win_inactive_list_head, win_ptr);
+    }
+
+  fn_exit:
+    return mpi_errno;
+  fn_fail:
+    goto fn_exit;
+}
+
+
 /* MPIDI_CH3I_Win_op_alloc(): get a new op element from op pool and
  * initialize it. If we cannot get one, return NULL. */
 #undef FUNCNAME
diff --git a/src/mpid/ch3/include/mpid_rma_types.h b/src/mpid/ch3/include/mpid_rma_types.h
index 820b5f8..cfcf80c 100644
--- a/src/mpid/ch3/include/mpid_rma_types.h
+++ b/src/mpid/ch3/include/mpid_rma_types.h
@@ -105,7 +105,7 @@ typedef struct MPIDI_RMA_Slot {
     struct MPIDI_RMA_Target *target_list_head;
 } MPIDI_RMA_Slot_t;
 
-extern MPID_Win *MPIDI_RMA_Win_list_head;
+extern MPID_Win *MPIDI_RMA_Win_active_list_head, *MPIDI_RMA_Win_inactive_list_head;
 
 typedef struct MPIDI_RMA_Target_lock_entry {
     struct MPIDI_RMA_Target_lock_entry *next;
diff --git a/src/mpid/ch3/include/mpidpre.h b/src/mpid/ch3/include/mpidpre.h
index 973d981..ecc6a73 100644
--- a/src/mpid/ch3/include/mpidpre.h
+++ b/src/mpid/ch3/include/mpidpre.h
@@ -349,6 +349,7 @@ typedef struct MPIDI_Win_basic_info {
     int sync_request_cnt; /* This counter tracks number of              \
                              incomplete sync requests (used in          \
                              Win_fence and PSCW). */                    \
+    int active; /* specify if this window is active or not */           \
     struct MPID_Win *prev;                                              \
     struct MPID_Win *next;                                              \
 
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index 855be8a..6d883cd 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -942,7 +942,7 @@ int MPIDI_CH3I_RMA_Make_progress_global(int *made_progress)
     if (MPIDI_CH3I_num_active_issued_win == 0 && MPIDI_CH3I_num_passive_win == 0)
         goto fn_exit;
 
-    for (win_ptr = MPIDI_RMA_Win_list_head; win_ptr; win_ptr = win_ptr->next) {
+    for (win_ptr = MPIDI_RMA_Win_active_list_head; win_ptr; win_ptr = win_ptr->next) {
         int temp_progress = 0;
         int is_able_to_issue = 0;
 
diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index acfc7c5..3a2afdc 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -492,6 +492,14 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
                         win_ptr->states.exposure_state != MPIDI_RMA_NONE,
                         mpi_errno, MPI_ERR_RMA_SYNC, "**rmasync");
 
+    if (!(assert & MPI_MODE_NOSUCCEED)) {
+        /* mark the window as active */
+        mpi_errno = MPIDI_CH3I_Win_set_active(win_ptr);
+        if (mpi_errno) {
+            MPIU_ERR_POP(mpi_errno);
+        }
+    }
+
     /* Judge if we should switch to scalable FENCE algorithm */
     if (comm_size >= MPIR_CVAR_CH3_RMA_SCALABLE_FENCE_PROCESS_NUM) {
         scalable_fence_enabled = 1;
@@ -649,6 +657,12 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
 
         if (assert & MPI_MODE_NOSUCCEED) {
             win_ptr->states.access_state = MPIDI_RMA_NONE;
+
+            /* mark the window as inactive */
+            mpi_errno = MPIDI_CH3I_Win_set_inactive(win_ptr);
+            if (mpi_errno) {
+                MPIU_ERR_POP(mpi_errno);
+            }
         }
         else {
             /* Prepare for the next possible epoch */
@@ -823,6 +837,12 @@ int MPID_Win_start(MPID_Group * group_ptr, int assert, MPID_Win * win_ptr)
                         win_ptr->states.access_state != MPIDI_RMA_FENCE_GRANTED,
                         mpi_errno, MPI_ERR_RMA_SYNC, "**rmasync");
 
+    /* mark the window as active */
+    mpi_errno = MPIDI_CH3I_Win_set_active(win_ptr);
+    if (mpi_errno) {
+        MPIU_ERR_POP(mpi_errno);
+    }
+
     win_ptr->start_grp_size = group_ptr->size;
 
     MPIU_CHKPMEM_MALLOC(win_ptr->start_ranks_in_win_grp, int *,
@@ -997,6 +1017,12 @@ int MPID_Win_complete(MPID_Win * win_ptr)
 
     MPIU_Assert(win_ptr->active_req_cnt == 0);
 
+    /* mark the window as inactive */
+    mpi_errno = MPIDI_CH3I_Win_set_inactive(win_ptr);
+    if (mpi_errno != MPI_SUCCESS) {
+        MPIU_ERR_POP(mpi_errno);
+    }
+
   fn_exit:
     MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPID_WIN_COMPLETE);
     return mpi_errno;
@@ -1139,6 +1165,12 @@ int MPID_Win_lock(int lock_type, int dest, int assert, MPID_Win * win_ptr)
         /* Set window access state properly. */
         win_ptr->states.access_state = MPIDI_RMA_PER_TARGET;
         MPIDI_CH3I_num_passive_win++;
+
+        /* mark the window as active */
+        mpi_errno = MPIDI_CH3I_Win_set_active(win_ptr);
+        if (mpi_errno) {
+            MPIU_ERR_POP(mpi_errno);
+        }
     }
     win_ptr->lock_epoch_count++;
 
@@ -1286,6 +1318,12 @@ int MPID_Win_unlock(int dest, MPID_Win * win_ptr)
         win_ptr->states.access_state = MPIDI_RMA_NONE;
         MPIDI_CH3I_num_passive_win--;
         MPIU_Assert(MPIDI_CH3I_num_passive_win >= 0);
+
+        /* mark the window as inactive */
+        mpi_errno = MPIDI_CH3I_Win_set_inactive(win_ptr);
+        if (mpi_errno) {
+            MPIU_ERR_POP(mpi_errno);
+        }
     }
 
     if (target != NULL) {
@@ -1512,6 +1550,12 @@ int MPID_Win_lock_all(int assert, MPID_Win * win_ptr)
                         win_ptr->states.access_state != MPIDI_RMA_FENCE_GRANTED,
                         mpi_errno, MPI_ERR_RMA_SYNC, "**rmasync");
 
+    /* mark the window as active */
+    mpi_errno = MPIDI_CH3I_Win_set_active(win_ptr);
+    if (mpi_errno) {
+        MPIU_ERR_POP(mpi_errno);
+    }
+
     /* Set window access state properly. */
     if (assert & MPI_MODE_NOCHECK)
         win_ptr->states.access_state = MPIDI_RMA_LOCK_ALL_GRANTED;
@@ -1698,6 +1742,12 @@ int MPID_Win_unlock_all(MPID_Win * win_ptr)
 
     MPIU_Assert(win_ptr->active_req_cnt == 0);
 
+    /* mark the window as inactive */
+    mpi_errno = MPIDI_CH3I_Win_set_inactive(win_ptr);
+    if (mpi_errno) {
+        MPIU_ERR_POP(mpi_errno);
+    }
+
   fn_exit:
     MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPID_WIN_UNLOCK_ALL);
     return mpi_errno;
diff --git a/src/mpid/ch3/src/mpid_rma.c b/src/mpid/ch3/src/mpid_rma.c
index 4cc527b..7685e5f 100644
--- a/src/mpid/ch3/src/mpid_rma.c
+++ b/src/mpid/ch3/src/mpid_rma.c
@@ -41,7 +41,7 @@ cvars:
 
 MPIU_THREADSAFE_INIT_DECL(initRMAoptions);
 
-MPID_Win *MPIDI_RMA_Win_list_head = NULL;
+MPID_Win *MPIDI_RMA_Win_active_list_head = NULL, *MPIDI_RMA_Win_inactive_list_head = NULL;
 
 static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model, MPID_Info * info,
                     MPID_Comm * comm_ptr, MPID_Win ** win_ptr);
@@ -299,6 +299,7 @@ static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
     (*win_ptr)->outstanding_locks = 0;
     (*win_ptr)->current_target_lock_data_bytes = 0;
     (*win_ptr)->sync_request_cnt = 0;
+    (*win_ptr)->active = FALSE;
     (*win_ptr)->next = NULL;
     (*win_ptr)->prev = NULL;
 
@@ -354,12 +355,12 @@ static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
                       &((*win_ptr)->target_lock_entry_pool_start[i]));
     }
 
-    if (MPIDI_RMA_Win_list_head == NULL) {
+    if (MPIDI_RMA_Win_inactive_list_head == NULL && MPIDI_RMA_Win_active_list_head == NULL) {
         mpi_errno = MPID_Progress_register_hook(MPIDI_CH3I_RMA_Make_progress_global);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
     }
-    MPL_DL_APPEND(MPIDI_RMA_Win_list_head, (*win_ptr));
+    MPL_DL_APPEND(MPIDI_RMA_Win_inactive_list_head, (*win_ptr));
 
     if (MPIDI_CH3U_Win_hooks.win_init != NULL) {
         mpi_errno =
diff --git a/src/mpid/ch3/src/mpidi_rma.c b/src/mpid/ch3/src/mpidi_rma.c
index d015d1e..26b5741 100644
--- a/src/mpid/ch3/src/mpidi_rma.c
+++ b/src/mpid/ch3/src/mpidi_rma.c
@@ -199,9 +199,14 @@ int MPID_Win_free(MPID_Win ** win_ptr)
     }
 
     /* dequeue window from the global list */
-    MPL_DL_DELETE(MPIDI_RMA_Win_list_head, (*win_ptr));
+    if ((*win_ptr)->active == TRUE) {
+        MPL_DL_DELETE(MPIDI_RMA_Win_active_list_head, (*win_ptr));
+    }
+    else {
+        MPL_DL_DELETE(MPIDI_RMA_Win_inactive_list_head, (*win_ptr));
+    }
 
-    if (MPIDI_RMA_Win_list_head == NULL)
+    if (MPIDI_RMA_Win_active_list_head == NULL && MPIDI_RMA_Win_inactive_list_head == NULL)
         MPID_Progress_deregister_hook(MPIDI_CH3I_RMA_Make_progress_global);
 
     comm_ptr = (*win_ptr)->comm_ptr;

http://git.mpich.org/mpich.git/commitdiff/16e34b611e7a492dc04d0d180d5d69133fd94820

commit 16e34b611e7a492dc04d0d180d5d69133fd94820
Author: Xin Zhao <xinzhao3 at illinois.edu>
Date:   Wed Jul 29 16:01:02 2015 -0500

    Use num_targets_with_pending_ops instead of num_active_slots.
    
    Here we use num_targets_with_pending_ops to keep track of
    total number of targets that has pending operations.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/mpid/ch3/include/mpid_rma_oplist.h b/src/mpid/ch3/include/mpid_rma_oplist.h
index f53469c..f3e5a1c 100644
--- a/src/mpid/ch3/include/mpid_rma_oplist.h
+++ b/src/mpid/ch3/include/mpid_rma_oplist.h
@@ -309,9 +309,6 @@ static inline int MPIDI_CH3I_Win_create_target(MPID_Win * win_ptr, int target_ra
 
     t->target_rank = target_rank;
 
-    if (slot->target_list_head == NULL)
-        win_ptr->num_active_slots++;
-
     /* Enqueue target into target list. */
     MPL_DL_APPEND(slot->target_list_head, t);
 
@@ -395,6 +392,9 @@ static inline int MPIDI_CH3I_Win_enqueue_op(MPID_Win * win_ptr, MPIDI_RMA_Op_t *
         }
     }
 
+    if (target->pending_op_list_head == NULL)
+        win_ptr->num_targets_with_pending_ops++;
+
     /* Enqueue operation into pending list. */
     MPL_DL_APPEND(target->pending_op_list_head, op);
     if (target->next_op_to_issue == NULL)
@@ -427,9 +427,6 @@ static inline int MPIDI_CH3I_Win_target_dequeue_and_free(MPID_Win * win_ptr, MPI
     if (mpi_errno != MPI_SUCCESS)
         MPIU_ERR_POP(mpi_errno);
 
-    if (slot->target_list_head == NULL)
-        win_ptr->num_active_slots--;
-
   fn_exit:
     return mpi_errno;
   fn_fail:
@@ -455,8 +452,6 @@ static inline int MPIDI_CH3I_RMA_Cleanup_targets_win(MPID_Win * win_ptr)
         }
     }
 
-    MPIU_Assert(win_ptr->num_active_slots == 0);
-
   fn_exit:
     return mpi_errno;
   fn_fail:
diff --git a/src/mpid/ch3/include/mpidpre.h b/src/mpid/ch3/include/mpidpre.h
index 88f5a6c..973d981 100644
--- a/src/mpid/ch3/include/mpidpre.h
+++ b/src/mpid/ch3/include/mpidpre.h
@@ -329,8 +329,8 @@ typedef struct MPIDI_Win_basic_info {
         enum MPIDI_RMA_states access_state;                              \
         enum MPIDI_RMA_states exposure_state;                            \
     } states;                                                            \
-    int num_active_slots; /* specify number of slots that have           \
-                             active targets */                           \
+    int num_targets_with_pending_ops; /* keep track of number of targets \
+                                         tht has pending operations. */  \
     int active_req_cnt; /* keep track of number of active requests in    \
                            current epoch, i.e., number of issued but     \
                            incomplete RMA operations. */                 \
diff --git a/src/mpid/ch3/include/mpidrma.h b/src/mpid/ch3/include/mpidrma.h
index 6cc12bc..967857e 100644
--- a/src/mpid/ch3/include/mpidrma.h
+++ b/src/mpid/ch3/include/mpidrma.h
@@ -693,6 +693,11 @@ static inline int handle_lock_ack_with_op(MPID_Win * win_ptr,
         }
 
         MPIDI_CH3I_RMA_Ops_free_elem(win_ptr, &(target->pending_op_list_head), op);
+
+        if (target->pending_op_list_head == NULL) {
+            win_ptr->num_targets_with_pending_ops--;
+            MPIU_Assert(win_ptr->num_targets_with_pending_ops >= 0);
+        }
     }
     else if (flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_QUEUED_DATA_DISCARDED ||
              flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_DISCARDED) {
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index 820241e..855be8a 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -378,6 +378,11 @@ static inline int check_and_set_req_completion(MPID_Win * win_ptr, MPIDI_RMA_Tar
         win_ptr->active_req_cnt += rma_op->ref_cnt;
     }
 
+    if (target->pending_op_list_head == NULL) {
+        win_ptr->num_targets_with_pending_ops--;
+        MPIU_Assert(win_ptr->num_targets_with_pending_ops >= 0);
+    }
+
   fn_exit:
     MPIDI_RMA_FUNC_EXIT(MPID_STATE_CHECK_AND_SET_REQ_COMPLETION);
     return mpi_errno;
@@ -399,7 +404,8 @@ static inline int issue_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * targ
 
     (*made_progress) = 0;
 
-    if (win_ptr->num_active_slots == 0 || target == NULL || target->pending_op_list_head == NULL)
+    if (win_ptr->num_targets_with_pending_ops == 0 || target == NULL ||
+        target->pending_op_list_head == NULL)
         goto fn_exit;
 
     /* Issue out operations in the list. */
@@ -540,9 +546,6 @@ static inline int issue_ops_win(MPID_Win * win_ptr, int *made_progress)
 
     (*made_progress) = 0;
 
-    if (win_ptr->num_active_slots == 0)
-        goto fn_exit;
-
     /* FIXME: we should optimize the issuing pattern here. */
 
     start_slot = win_ptr->comm_ptr->rank % win_ptr->num_slots;
@@ -594,11 +597,6 @@ int MPIDI_CH3I_RMA_Free_ops_before_completion(MPID_Win * win_ptr)
     int i, made_progress = 0;
     int mpi_errno = MPI_SUCCESS;
 
-    /* If we are in an free_ops_before_completion, the window must be holding
-     * up resources.  If it isn't, we are in the wrong window and
-     * incorrectly entered this function. */
-    MPIU_ERR_CHKANDJUMP(win_ptr->num_active_slots == 0, mpi_errno, MPI_ERR_OTHER, "**rmanoop");
-
     /* make nonblocking progress once */
     mpi_errno = MPIDI_CH3I_RMA_Make_progress_win(win_ptr, &made_progress);
     if (mpi_errno != MPI_SUCCESS)
@@ -696,11 +694,6 @@ int MPIDI_CH3I_RMA_Cleanup_ops_aggressive(MPID_Win * win_ptr)
     MPIDI_RMA_Target_t *curr_target = NULL;
     int made_progress = 0;
 
-    /* If we are in an aggressive cleanup, the window must be holding
-     * up resources.  If it isn't, we are in the wrong window and
-     * incorrectly entered this function. */
-    MPIU_ERR_CHKANDJUMP(win_ptr->num_active_slots == 0, mpi_errno, MPI_ERR_OTHER, "**rmanoop");
-
     /* find the first target that has something to issue */
     for (i = 0; i < win_ptr->num_slots; i++) {
         if (win_ptr->slots[i].target_list_head != NULL) {
@@ -755,11 +748,6 @@ int MPIDI_CH3I_RMA_Cleanup_target_aggressive(MPID_Win * win_ptr, MPIDI_RMA_Targe
 
     (*target) = NULL;
 
-    /* If we are in an aggressive cleanup, the window must be holding
-     * up resources.  If it isn't, we are in the wrong window and
-     * incorrectly entered this function. */
-    MPIU_ERR_CHKANDJUMP(win_ptr->num_active_slots == 0, mpi_errno, MPI_ERR_OTHER, "**rmanotarget");
-
     if (win_ptr->states.access_state == MPIDI_RMA_LOCK_ALL_CALLED) {
         /* switch to window-wide protocol */
         MPIDI_VC_t *orig_vc = NULL, *target_vc = NULL;
@@ -927,9 +915,6 @@ int MPIDI_CH3I_RMA_Make_progress_win(MPID_Win * win_ptr, int *made_progress)
         goto fn_exit;
     }
 
-    if (win_ptr->num_active_slots == 0)
-        goto fn_exit;
-
     mpi_errno = issue_ops_win(win_ptr, &temp_progress);
     if (mpi_errno != MPI_SUCCESS)
         MPIU_ERR_POP(mpi_errno);
@@ -976,9 +961,6 @@ int MPIDI_CH3I_RMA_Make_progress_global(int *made_progress)
             continue;
         }
 
-        if (win_ptr->num_active_slots == 0)
-            continue;
-
         mpi_errno = issue_ops_win(win_ptr, &temp_progress);
         if (mpi_errno != MPI_SUCCESS)
             MPIU_ERR_POP(mpi_errno);
diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index 9ef93c1..acfc7c5 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -685,9 +685,6 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
     }
 
   finish_fence:
-    /* Make sure that all targets are freed. */
-    MPIU_Assert(win_ptr->num_active_slots == 0);
-
     MPIU_Assert(win_ptr->active_req_cnt == 0);
 
     /* Ensure ordering of load/store operations. */
@@ -803,7 +800,6 @@ int MPID_Win_post(MPID_Group * post_grp_ptr, int assert, MPID_Win * win_ptr)
     /* --END ERROR HANDLING-- */
 }
 
-
 #undef FUNCNAME
 #define FUNCNAME MPID_Win_start
 #undef FCNAME
@@ -999,9 +995,6 @@ int MPID_Win_complete(MPID_Win * win_ptr)
     win_ptr->start_ranks_in_win_grp = NULL;
     MPIU_Assert(win_ptr->start_req == NULL);
 
-    /* Make sure that all targets are freed. */
-    MPIU_Assert(win_ptr->num_active_slots == 0);
-
     MPIU_Assert(win_ptr->active_req_cnt == 0);
 
   fn_exit:
@@ -1703,9 +1696,6 @@ int MPID_Win_unlock_all(MPID_Win * win_ptr)
     /* reset lock_all assert on window. */
     win_ptr->lock_all_assert = 0;
 
-    /* Make sure that all targets are freed. */
-    MPIU_Assert(win_ptr->num_active_slots == 0);
-
     MPIU_Assert(win_ptr->active_req_cnt == 0);
 
   fn_exit:
diff --git a/src/mpid/ch3/src/mpid_rma.c b/src/mpid/ch3/src/mpid_rma.c
index cfbdec4..4cc527b 100644
--- a/src/mpid/ch3/src/mpid_rma.c
+++ b/src/mpid/ch3/src/mpid_rma.c
@@ -288,7 +288,7 @@ static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
     (*win_ptr)->shm_allocated = FALSE;
     (*win_ptr)->states.access_state = MPIDI_RMA_NONE;
     (*win_ptr)->states.exposure_state = MPIDI_RMA_NONE;
-    (*win_ptr)->num_active_slots = 0;
+    (*win_ptr)->num_targets_with_pending_ops = 0;
     (*win_ptr)->active_req_cnt = 0;
     (*win_ptr)->fence_sync_req = MPI_REQUEST_NULL;
     (*win_ptr)->start_req = NULL;

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

commit fb1f689a43a831290bbc449d3ee5d71f843da4d8
Author: Xin Zhao <xinzhao3 at illinois.edu>
Date:   Tue Jul 28 23:08:24 2015 -0500

    Use sync_request_cnt to count total number of ibarrier requests.
    
    Originally we use this counter to track number of dangling requests in
    Fence.  Here we modify it to track total number of Fence requests,
    which is a cleaner design.  This has the disadvantage that we now wait
    for all previously pending ibarrier requests to complete before
    issuing the pending operations, but that's not a common use case and
    this patch is simpler and easier to maintain.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index f6a6731..9ef93c1 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -450,7 +450,7 @@ static int fence_barrier_complete(MPID_Request * sreq)
     MPID_Win_get_ptr(sreq->dev.source_win_handle, win_ptr);
     MPIU_Assert(win_ptr != NULL);
 
-    /* decrement pending incomplete ibarrier request counter */
+    /* decrement incomplete ibarrier request counter */
     win_ptr->sync_request_cnt--;
     MPIU_Assert(win_ptr->sync_request_cnt >= 0);
 
@@ -513,13 +513,6 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
             if (win_ptr->fence_sync_req != MPI_REQUEST_NULL) {
                 MPID_Request *req_ptr;
                 MPID_Request_get_ptr(win_ptr->fence_sync_req, req_ptr);
-
-                if (!MPID_Request_is_complete(req_ptr)) {
-                    req_ptr->dev.source_win_handle = win_ptr->handle;
-                    req_ptr->request_completed_cb = fence_barrier_complete;
-                    win_ptr->sync_request_cnt++;
-                }
-
                 MPID_Request_release(req_ptr);
                 win_ptr->fence_sync_req = MPI_REQUEST_NULL;
                 win_ptr->states.access_state = MPIDI_RMA_NONE;
@@ -545,9 +538,18 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
                 win_ptr->states.access_state = MPIDI_RMA_FENCE_GRANTED;
             }
             else {
+                MPID_Request *req_ptr;
+
                 /* Set window access state properly. */
                 win_ptr->states.access_state = MPIDI_RMA_FENCE_ISSUED;
                 MPIDI_CH3I_num_active_issued_win++;
+
+                MPID_Request_get_ptr(win_ptr->fence_sync_req, req_ptr);
+                if (!MPID_Request_is_complete(req_ptr)) {
+                    req_ptr->dev.source_win_handle = win_ptr->handle;
+                    req_ptr->request_completed_cb = fence_barrier_complete;
+                    win_ptr->sync_request_cnt++;
+                }
             }
 
             goto finish_fence;
@@ -561,13 +563,6 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
         if (win_ptr->fence_sync_req != MPI_REQUEST_NULL) {
             MPID_Request *req_ptr;
             MPID_Request_get_ptr(win_ptr->fence_sync_req, req_ptr);
-
-            if (!MPID_Request_is_complete(req_ptr)) {
-                req_ptr->dev.source_win_handle = win_ptr->handle;
-                req_ptr->request_completed_cb = fence_barrier_complete;
-                win_ptr->sync_request_cnt++;
-            }
-
             MPID_Request_release(req_ptr);
             win_ptr->fence_sync_req = MPI_REQUEST_NULL;
             MPIDI_CH3I_num_active_issued_win--;
@@ -666,8 +661,17 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
                 win_ptr->states.access_state = MPIDI_RMA_FENCE_GRANTED;
             }
             else {
+                MPID_Request *req_ptr;
+
                 MPIDI_CH3I_num_active_issued_win++;
                 win_ptr->states.access_state = MPIDI_RMA_FENCE_ISSUED;
+
+                MPID_Request_get_ptr(win_ptr->fence_sync_req, req_ptr);
+                if (!MPID_Request_is_complete(req_ptr)) {
+                    req_ptr->dev.source_win_handle = win_ptr->handle;
+                    req_ptr->request_completed_cb = fence_barrier_complete;
+                    win_ptr->sync_request_cnt++;
+                }
             }
 
             if (win_ptr->shm_allocated == TRUE) {

http://git.mpich.org/mpich.git/commitdiff/47e0c270d26ac06f4ab512f8a32678e0ec6543c4

commit 47e0c270d26ac06f4ab512f8a32678e0ec6543c4
Author: Xin Zhao <xinzhao3 at illinois.edu>
Date:   Fri Jul 31 15:09:00 2015 -0500

    Issue UNLOCK/FLUSH message right after lock is granted.
    
    After lock is granted, we directly issue the UNLOCK/FLUSH message
    instead of going through the RMA issuing progress again, because
    window can be inactive at this point.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/mpid/ch3/include/mpidrma.h b/src/mpid/ch3/include/mpidrma.h
index f35ebbd..6cc12bc 100644
--- a/src/mpid/ch3/include/mpidrma.h
+++ b/src/mpid/ch3/include/mpidrma.h
@@ -607,6 +607,18 @@ static inline int handle_lock_ack(MPID_Win * win_ptr, int target_rank, MPIDI_CH3
     if (flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED)
         t->access_state = MPIDI_RMA_LOCK_GRANTED;
 
+    if (win_ptr->states.access_state == MPIDI_RMA_LOCK_ALL_GRANTED ||
+        t->access_state == MPIDI_RMA_LOCK_GRANTED) {
+        if (t->pending_op_list_head == NULL) {
+            int made_progress ATTRIBUTE((unused)) = 0;
+            mpi_errno =
+                MPIDI_CH3I_RMA_Make_progress_target(win_ptr, t->target_rank, &made_progress);
+            if (mpi_errno != MPI_SUCCESS) {
+                MPIU_ERR_POP(mpi_errno);
+            }
+        }
+    }
+
     if (flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_DISCARDED)
         t->access_state = MPIDI_RMA_LOCK_CALLED;
 
diff --git a/src/mpid/ch3/src/ch3u_rma_pkthandler.c b/src/mpid/ch3/src/ch3u_rma_pkthandler.c
index 6b1ea43..c4f631e 100644
--- a/src/mpid/ch3/src/ch3u_rma_pkthandler.c
+++ b/src/mpid/ch3/src/ch3u_rma_pkthandler.c
@@ -1279,11 +1279,11 @@ int MPIDI_CH3_PktHandler_CASResp(MPIDI_VC_t * vc ATTRIBUTE((unused)),
 
     /* decrement ack_counter on this target */
     if (cas_resp_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED) {
-        mpi_errno = handle_lock_ack(win_ptr, target_rank, cas_resp_pkt->flags);
+        mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, cas_resp_pkt->flags);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
 
-        mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, cas_resp_pkt->flags);
+        mpi_errno = handle_lock_ack(win_ptr, target_rank, cas_resp_pkt->flags);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
     }
@@ -1532,11 +1532,11 @@ int MPIDI_CH3_PktHandler_FOPResp(MPIDI_VC_t * vc ATTRIBUTE((unused)),
 
     /* decrement ack_counter */
     if (fop_resp_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED) {
-        mpi_errno = handle_lock_ack(win_ptr, target_rank, fop_resp_pkt->flags);
+        mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, fop_resp_pkt->flags);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
 
-        mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, fop_resp_pkt->flags);
+        mpi_errno = handle_lock_ack(win_ptr, target_rank, fop_resp_pkt->flags);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
     }
@@ -1621,11 +1621,10 @@ int MPIDI_CH3_PktHandler_Get_AccumResp(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
 
     /* decrement ack_counter on target */
     if (get_accum_resp_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED) {
-        mpi_errno = handle_lock_ack(win_ptr, target_rank, get_accum_resp_pkt->flags);
+        mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, get_accum_resp_pkt->flags);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
-
-        mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, get_accum_resp_pkt->flags);
+        mpi_errno = handle_lock_ack(win_ptr, target_rank, get_accum_resp_pkt->flags);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
     }
@@ -1816,11 +1815,11 @@ int MPIDI_CH3_PktHandler_GetResp(MPIDI_VC_t * vc ATTRIBUTE((unused)),
 
     /* decrement ack_counter on target */
     if (get_resp_pkt->flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED) {
-        mpi_errno = handle_lock_ack(win_ptr, target_rank, get_resp_pkt->flags);
+        mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, get_resp_pkt->flags);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
 
-        mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, get_resp_pkt->flags);
+        mpi_errno = handle_lock_ack(win_ptr, target_rank, get_resp_pkt->flags);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
     }
@@ -1951,14 +1950,14 @@ int MPIDI_CH3_PktHandler_LockOpAck(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
         MPID_Win_get_ptr(req_ptr->dev.source_win_handle, win_ptr);
     }
 
-    mpi_errno = handle_lock_ack(win_ptr, target_rank, lock_op_ack_pkt->flags);
-    if (mpi_errno)
-        MPIU_ERR_POP(mpi_errno);
-
     mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, lock_op_ack_pkt->flags);
     if (mpi_errno != MPI_SUCCESS)
         MPIU_ERR_POP(mpi_errno);
 
+    mpi_errno = handle_lock_ack(win_ptr, target_rank, lock_op_ack_pkt->flags);
+    if (mpi_errno)
+        MPIU_ERR_POP(mpi_errno);
+
     if (flags & MPIDI_CH3_PKT_FLAG_RMA_ACK) {
         MPIU_Assert(flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED);
         mpi_errno = MPIDI_CH3I_RMA_Handle_ack(win_ptr, target_rank);

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

commit bf5f0ec33784f6015b15b3419cff16a6dde5aa66
Author: Xin Zhao <xinzhao3 at illinois.edu>
Date:   Sun Aug 2 14:13:02 2015 -0500

    Rename function adjust_op_piggybacked_with_lock to handle_lock_ack_with_op
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/mpid/ch3/include/mpidrma.h b/src/mpid/ch3/include/mpidrma.h
index 88a1eed..f35ebbd 100644
--- a/src/mpid/ch3/include/mpidrma.h
+++ b/src/mpid/ch3/include/mpidrma.h
@@ -616,8 +616,8 @@ static inline int handle_lock_ack(MPID_Win * win_ptr, int target_rank, MPIDI_CH3
     goto fn_exit;
 }
 
-static inline int adjust_op_piggybacked_with_lock(MPID_Win * win_ptr,
-                                                  int target_rank, MPIDI_CH3_Pkt_flags_t flags)
+static inline int handle_lock_ack_with_op(MPID_Win * win_ptr,
+                                          int target_rank, MPIDI_CH3_Pkt_flags_t flags)
 {
     MPIDI_RMA_Target_t *target = NULL;
     MPIDI_RMA_Op_t *op = NULL;
diff --git a/src/mpid/ch3/src/ch3u_rma_pkthandler.c b/src/mpid/ch3/src/ch3u_rma_pkthandler.c
index 91b8eec..6b1ea43 100644
--- a/src/mpid/ch3/src/ch3u_rma_pkthandler.c
+++ b/src/mpid/ch3/src/ch3u_rma_pkthandler.c
@@ -1283,7 +1283,7 @@ int MPIDI_CH3_PktHandler_CASResp(MPIDI_VC_t * vc ATTRIBUTE((unused)),
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
 
-        mpi_errno = adjust_op_piggybacked_with_lock(win_ptr, target_rank, cas_resp_pkt->flags);
+        mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, cas_resp_pkt->flags);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
     }
@@ -1536,7 +1536,7 @@ int MPIDI_CH3_PktHandler_FOPResp(MPIDI_VC_t * vc ATTRIBUTE((unused)),
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
 
-        mpi_errno = adjust_op_piggybacked_with_lock(win_ptr, target_rank, fop_resp_pkt->flags);
+        mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, fop_resp_pkt->flags);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
     }
@@ -1625,8 +1625,7 @@ int MPIDI_CH3_PktHandler_Get_AccumResp(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
 
-        mpi_errno = adjust_op_piggybacked_with_lock(win_ptr, target_rank,
-                                                    get_accum_resp_pkt->flags);
+        mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, get_accum_resp_pkt->flags);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
     }
@@ -1821,7 +1820,7 @@ int MPIDI_CH3_PktHandler_GetResp(MPIDI_VC_t * vc ATTRIBUTE((unused)),
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
 
-        mpi_errno = adjust_op_piggybacked_with_lock(win_ptr, target_rank, get_resp_pkt->flags);
+        mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, get_resp_pkt->flags);
         if (mpi_errno)
             MPIU_ERR_POP(mpi_errno);
     }
@@ -1956,7 +1955,7 @@ int MPIDI_CH3_PktHandler_LockOpAck(MPIDI_VC_t * vc, MPIDI_CH3_Pkt_t * pkt,
     if (mpi_errno)
         MPIU_ERR_POP(mpi_errno);
 
-    mpi_errno = adjust_op_piggybacked_with_lock(win_ptr, target_rank, lock_op_ack_pkt->flags);
+    mpi_errno = handle_lock_ack_with_op(win_ptr, target_rank, lock_op_ack_pkt->flags);
     if (mpi_errno != MPI_SUCCESS)
         MPIU_ERR_POP(mpi_errno);
 

http://git.mpich.org/mpich.git/commitdiff/08f4cd38d95dde29bef38e15018e6e7f713547a0

commit 08f4cd38d95dde29bef38e15018e6e7f713547a0
Author: Pavan Balaji <balaji at anl.gov>
Date:   Wed Jul 29 14:56:31 2015 -0500

    Rename dangling_request_cnt to sync_request_cnt.
    
    We want to use this counter to keep track of total number
    of synchronization requests in Fence and PSCW, not just
    number of dangling requests in Fence, therefore we rename
    the variable here.
    
    Signed-off-by: Xin Zhao <xinzhao3 at illinois.edu>

diff --git a/src/mpid/ch3/include/mpidpre.h b/src/mpid/ch3/include/mpidpre.h
index 11cb6d3..88f5a6c 100644
--- a/src/mpid/ch3/include/mpidpre.h
+++ b/src/mpid/ch3/include/mpidpre.h
@@ -346,15 +346,9 @@ typedef struct MPIDI_Win_basic_info {
     struct MPIDI_RMA_Target_lock_entry *target_lock_entry_pool_start;   \
     struct MPIDI_RMA_Target_lock_entry *target_lock_entry_pool_head;    \
     int current_target_lock_data_bytes;                                 \
-    int dangling_request_cnt; /* This counter tracks number of          \
-                                 ibarrier requests (used in             \
-                                 Win_fence) that are not                \
-                                 completed but are out-of-date          \
-                                 for the current RMA epoch.             \
-                                 we do not need to wait for             \
-                                 their completion during RMA            \
-                                 epoch, but we need to clean            \
-                                 them up in Win_free. */                \
+    int sync_request_cnt; /* This counter tracks number of              \
+                             incomplete sync requests (used in          \
+                             Win_fence and PSCW). */                    \
     struct MPID_Win *prev;                                              \
     struct MPID_Win *next;                                              \
 
diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index 4d26c98..f6a6731 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -451,8 +451,8 @@ static int fence_barrier_complete(MPID_Request * sreq)
     MPIU_Assert(win_ptr != NULL);
 
     /* decrement pending incomplete ibarrier request counter */
-    win_ptr->dangling_request_cnt--;
-    MPIU_Assert(win_ptr->dangling_request_cnt >= 0);
+    win_ptr->sync_request_cnt--;
+    MPIU_Assert(win_ptr->sync_request_cnt >= 0);
 
   fn_exit:
     MPIDI_FUNC_EXIT(MPID_STATE_FENCE_BARRIER_COMPLETE);
@@ -517,7 +517,7 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
                 if (!MPID_Request_is_complete(req_ptr)) {
                     req_ptr->dev.source_win_handle = win_ptr->handle;
                     req_ptr->request_completed_cb = fence_barrier_complete;
-                    win_ptr->dangling_request_cnt++;
+                    win_ptr->sync_request_cnt++;
                 }
 
                 MPID_Request_release(req_ptr);
@@ -565,7 +565,7 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
             if (!MPID_Request_is_complete(req_ptr)) {
                 req_ptr->dev.source_win_handle = win_ptr->handle;
                 req_ptr->request_completed_cb = fence_barrier_complete;
-                win_ptr->dangling_request_cnt++;
+                win_ptr->sync_request_cnt++;
             }
 
             MPID_Request_release(req_ptr);
diff --git a/src/mpid/ch3/src/mpid_rma.c b/src/mpid/ch3/src/mpid_rma.c
index 2cc7e64..cfbdec4 100644
--- a/src/mpid/ch3/src/mpid_rma.c
+++ b/src/mpid/ch3/src/mpid_rma.c
@@ -298,7 +298,7 @@ static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
     (*win_ptr)->lock_epoch_count = 0;
     (*win_ptr)->outstanding_locks = 0;
     (*win_ptr)->current_target_lock_data_bytes = 0;
-    (*win_ptr)->dangling_request_cnt = 0;
+    (*win_ptr)->sync_request_cnt = 0;
     (*win_ptr)->next = NULL;
     (*win_ptr)->prev = NULL;
 
diff --git a/src/mpid/ch3/src/mpidi_rma.c b/src/mpid/ch3/src/mpidi_rma.c
index 7124be5..d015d1e 100644
--- a/src/mpid/ch3/src/mpidi_rma.c
+++ b/src/mpid/ch3/src/mpidi_rma.c
@@ -181,8 +181,7 @@ int MPID_Win_free(MPID_Win ** win_ptr)
            (*win_ptr)->at_completion_counter != 0 ||
            (*win_ptr)->target_lock_queue_head != NULL ||
            (*win_ptr)->current_target_lock_data_bytes != 0 ||
-           (*win_ptr)->fence_sync_req != MPI_REQUEST_NULL ||
-           (*win_ptr)->dangling_request_cnt != 0) {
+           (*win_ptr)->fence_sync_req != MPI_REQUEST_NULL || (*win_ptr)->sync_request_cnt != 0) {
         mpi_errno = wait_progress_engine();
         if (mpi_errno != MPI_SUCCESS)
             MPIU_ERR_POP(mpi_errno);

http://git.mpich.org/mpich.git/commitdiff/912890e296b12cd8b7327b0b8e7575b9ff5cda02

commit 912890e296b12cd8b7327b0b8e7575b9ff5cda02
Author: Pavan Balaji <balaji at anl.gov>
Date:   Tue Jul 28 22:47:17 2015 -0500

    Rename fence request callback and move it to where it's used.
    
    Signed-off-by: Xin Zhao <xinzhao3 at illinois.edu>

diff --git a/src/mpid/ch3/include/mpidimpl.h b/src/mpid/ch3/include/mpidimpl.h
index 0f7f2f4..06cb0e4 100644
--- a/src/mpid/ch3/include/mpidimpl.h
+++ b/src/mpid/ch3/include/mpidimpl.h
@@ -1875,9 +1875,6 @@ int MPIDI_CH3_ReqHandler_FOPSendComplete( MPIDI_VC_t *, MPID_Request *,
 /* RMA operation request handler */
 int MPIDI_CH3_Req_handler_rma_op_complete(MPID_Request *);
 
-/* RMA Synchronization request handler */
-int MPIDI_CH3_Req_handler_rma_sync_complete(MPID_Request *);
-
 /* Thread Support */
 #ifdef MPICH_IS_THREADED
 #if MPIU_THREAD_GRANULARITY == MPIU_THREAD_GRANULARITY_GLOBAL
diff --git a/src/mpid/ch3/src/ch3u_handle_op_req.c b/src/mpid/ch3/src/ch3u_handle_op_req.c
index 4315cf8..3288c57 100644
--- a/src/mpid/ch3/src/ch3u_handle_op_req.c
+++ b/src/mpid/ch3/src/ch3u_handle_op_req.c
@@ -87,30 +87,3 @@ int MPIDI_CH3_Req_handler_rma_op_complete(MPID_Request * sreq)
   fn_fail:
     goto fn_exit;
 }
-
-#undef FUNCNAME
-#define FUNCNAME MPIDI_CH3_Req_handler_rma_sync_complete
-#undef FCNAME
-#define FCNAME MPIDI_QUOTE(FUNCNAME)
-int MPIDI_CH3_Req_handler_rma_sync_complete(MPID_Request * sreq)
-{
-    int mpi_errno = MPI_SUCCESS;
-    MPID_Win *win_ptr = NULL;
-
-    MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_REQ_HANDLER_RMA_SYNC_COMPLETE);
-    MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_REQ_HANDLER_RMA_SYNC_COMPLETE);
-
-    MPID_Win_get_ptr(sreq->dev.source_win_handle, win_ptr);
-    MPIU_Assert(win_ptr != NULL);
-
-    /* decrement pending incomplete ibarrier request counter */
-    win_ptr->dangling_request_cnt--;
-    MPIU_Assert(win_ptr->dangling_request_cnt >= 0);
-
-  fn_exit:
-    MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3_REQ_HANDLER_RMA_SYNC_COMPLETE);
-    return mpi_errno;
-
-  fn_fail:
-    goto fn_exit;
-}
diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index 41ed281..4d26c98 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -434,6 +434,35 @@ static inline int flush_all(MPID_Win * win_ptr)
     /* --END ERROR HANDLING-- */
 }
 
+
+#undef FUNCNAME
+#define FUNCNAME fence_barrier_complete
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+static int fence_barrier_complete(MPID_Request * sreq)
+{
+    int mpi_errno = MPI_SUCCESS;
+    MPID_Win *win_ptr = NULL;
+
+    MPIDI_STATE_DECL(MPID_STATE_FENCE_BARRIER_COMPLETE);
+    MPIDI_FUNC_ENTER(MPID_STATE_FENCE_BARRIER_COMPLETE);
+
+    MPID_Win_get_ptr(sreq->dev.source_win_handle, win_ptr);
+    MPIU_Assert(win_ptr != NULL);
+
+    /* decrement pending incomplete ibarrier request counter */
+    win_ptr->dangling_request_cnt--;
+    MPIU_Assert(win_ptr->dangling_request_cnt >= 0);
+
+  fn_exit:
+    MPIDI_FUNC_EXIT(MPID_STATE_FENCE_BARRIER_COMPLETE);
+    return mpi_errno;
+
+  fn_fail:
+    goto fn_exit;
+}
+
+
 /********************************************************************************/
 /* Active Target synchronization (including WIN_FENCE, WIN_POST, WIN_START,     */
 /* WIN_COMPLETE, WIN_WAIT, WIN_TEST)                                            */
@@ -487,7 +516,7 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
 
                 if (!MPID_Request_is_complete(req_ptr)) {
                     req_ptr->dev.source_win_handle = win_ptr->handle;
-                    req_ptr->request_completed_cb = MPIDI_CH3_Req_handler_rma_sync_complete;
+                    req_ptr->request_completed_cb = fence_barrier_complete;
                     win_ptr->dangling_request_cnt++;
                 }
 
@@ -535,7 +564,7 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
 
             if (!MPID_Request_is_complete(req_ptr)) {
                 req_ptr->dev.source_win_handle = win_ptr->handle;
-                req_ptr->request_completed_cb = MPIDI_CH3_Req_handler_rma_sync_complete;
+                req_ptr->request_completed_cb = fence_barrier_complete;
                 win_ptr->dangling_request_cnt++;
             }
 

http://git.mpich.org/mpich.git/commitdiff/92d67453362043bc5ea88042084d769a749d0f86

commit 92d67453362043bc5ea88042084d769a749d0f86
Author: Xin Zhao <xinzhao3 at illinois.edu>
Date:   Fri Jul 31 13:54:18 2015 -0500

    Bug-fix: mark stream units are all issued when issued count equals to total count.
    
    Signed-off-by: Pavan Balaji <balaji at anl.gov>

diff --git a/src/mpid/ch3/include/mpid_rma_issue.h b/src/mpid/ch3/include/mpid_rma_issue.h
index d36d74a..c5f9d69 100644
--- a/src/mpid/ch3/include/mpid_rma_issue.h
+++ b/src/mpid/ch3/include/mpid_rma_issue.h
@@ -612,8 +612,10 @@ static int issue_acc_op(MPIDI_RMA_Op_t * rma_op, MPID_Win * win_ptr,
         }
     }   /* end of for loop */
 
-    /* Mark that all stream units have been issued */
-    rma_op->issued_stream_count = ALL_STREAM_UNITS_ISSUED;
+    if (rma_op->issued_stream_count == stream_unit_count) {
+        /* Mark that all stream units have been issued */
+        rma_op->issued_stream_count = ALL_STREAM_UNITS_ISSUED;
+    }
 
   fn_exit:
     MPIDI_RMA_FUNC_EXIT(MPID_STATE_ISSUE_ACC_OP);
@@ -827,8 +829,10 @@ static int issue_get_acc_op(MPIDI_RMA_Op_t * rma_op, MPID_Win * win_ptr,
         }
     }   /* end of for loop */
 
-    /* Mark that all stream units have been issued */
-    rma_op->issued_stream_count = ALL_STREAM_UNITS_ISSUED;
+    if (rma_op->issued_stream_count == stream_unit_count) {
+        /* Mark that all stream units have been issued */
+        rma_op->issued_stream_count = ALL_STREAM_UNITS_ISSUED;
+    }
 
   fn_exit:
     MPIDI_RMA_FUNC_EXIT(MPID_STATE_ISSUE_GET_ACC_OP);

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

Summary of changes:
 .../ch3/channels/nemesis/include/mpid_nem_inline.h |    3 +-
 .../ch3/channels/nemesis/include/mpidi_ch3_pre.h   |    1 -
 src/mpid/ch3/channels/nemesis/src/ch3_progress.c   |    1 -
 src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h |    2 -
 src/mpid/ch3/channels/sock/src/ch3_progress.c      |    1 -
 src/mpid/ch3/include/mpid_rma_issue.h              |   12 +-
 src/mpid/ch3/include/mpid_rma_oplist.h             |   76 +++++++-
 src/mpid/ch3/include/mpid_rma_types.h              |    2 -
 src/mpid/ch3/include/mpidimpl.h                    |    3 -
 src/mpid/ch3/include/mpidpre.h                     |   21 +--
 src/mpid/ch3/include/mpidrma.h                     |   39 ++++-
 src/mpid/ch3/src/ch3u_handle_op_req.c              |   27 ---
 src/mpid/ch3/src/ch3u_rma_pkthandler.c             |   26 ++--
 src/mpid/ch3/src/ch3u_rma_progress.c               |  128 ++-----------
 src/mpid/ch3/src/ch3u_rma_sync.c                   |  194 +++++++++++++-------
 src/mpid/ch3/src/mpid_rma.c                        |   16 +-
 src/mpid/ch3/src/mpidi_rma.c                       |   18 +--
 17 files changed, 282 insertions(+), 288 deletions(-)


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list