[mpich2-commits] r7687 - in mpich2/trunk/src/mpid/ch3: channels/nemesis/include channels/nemesis/nemesis/include channels/nemesis/src channels/sctp/include channels/sock/include include

buntinas at mcs.anl.gov buntinas at mcs.anl.gov
Tue Jan 11 17:28:13 CST 2011


Author: buntinas
Date: 2011-01-11 17:28:13 -0600 (Tue, 11 Jan 2011)
New Revision: 7687

Modified:
   mpich2/trunk/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_post.h
   mpich2/trunk/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_pre.h
   mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/include/mpid_nem_inline.h
   mpich2/trunk/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
   mpich2/trunk/src/mpid/ch3/channels/sctp/include/mpidi_ch3_pre.h
   mpich2/trunk/src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h
   mpich2/trunk/src/mpid/ch3/include/mpidpost.h
Log:
Changed global completion count to use atomics rather than locks.  This will allow us to update the completion count asynchronously from other threads or interrupt contexts

Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_post.h
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_post.h	2011-01-11 20:04:11 UTC (rev 7686)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_post.h	2011-01-11 23:28:13 UTC (rev 7687)
@@ -10,12 +10,8 @@
 /* #define MPIDI_CH3_EAGER_MAX_MSG_SIZE (1500 - sizeof(MPIDI_CH3_Pkt_t)) */
 #define MPIDI_CH3_EAGER_MAX_MSG_SIZE   (128*1024)
 
-#define MPIDI_CH3_Progress_start(progress_state_)                                       \
-do {                                                                                    \
-    MPIU_THREAD_CS_ENTER(COMPLETION,);                                                  \
-    (progress_state_)->ch.completion_count = MPIDI_CH3I_progress_completion_count;      \
-    MPIU_THREAD_CS_EXIT(COMPLETION,);                                                   \
-} while (0)
+#define MPIDI_CH3_Progress_start(progress_state_)                                                       \
+        (progress_state_)->ch.completion_count = OPA_load_int(&MPIDI_CH3I_progress_completion_count);
 #define MPIDI_CH3_Progress_end(progress_state_)
 
 enum {

Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_pre.h
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_pre.h	2011-01-11 20:04:11 UTC (rev 7686)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_pre.h	2011-01-11 23:28:13 UTC (rev 7687)
@@ -14,6 +14,7 @@
     #include <winsock2.h>
     #include <windows.h>
 #endif
+#include "opa_primitives.h"
 
 /*#define MPID_USE_SEQUENCE_NUMBERS*/
 /*#define HAVE_CH3_PRE_INIT*/
@@ -130,5 +131,14 @@
 
 #define MPIDI_CH3_PROGRESS_STATE_DECL MPIDI_CH3I_Progress_state ch;
 
+extern OPA_int_t MPIDI_CH3I_progress_completion_count;
+#define MPIDI_CH3I_INCR_PROGRESS_COMPLETION_COUNT do {                                  \
+        OPA_write_barrier();                                                            \
+        OPA_incr_int(&MPIDI_CH3I_progress_completion_count);                            \
+        MPIU_DBG_MSG_D(CH3_PROGRESS,VERBOSE,                                            \
+                       "just incremented MPIDI_CH3I_progress_completion_count=%d",      \
+                       OPA_load_int(&MPIDI_CH3I_progress_completion_count));            \
+    } while(0)
+
 #endif /* !defined(MPICH_MPIDI_CH3_PRE_H_INCLUDED) */
 

Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/include/mpid_nem_inline.h
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/include/mpid_nem_inline.h	2011-01-11 20:04:11 UTC (rev 7686)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/include/mpid_nem_inline.h	2011-01-11 23:28:13 UTC (rev 7687)
@@ -866,7 +866,7 @@
 MPID_nem_mpich2_blocking_recv(MPID_nem_cell_ptr_t *cell, int *in_fbox)
 {
     int mpi_errno = MPI_SUCCESS;
-    unsigned completions = MPIDI_CH3I_progress_completion_count;
+    unsigned completions = OPA_load_int(&MPIDI_CH3I_progress_completion_count);
 #ifndef ENABLE_NO_YIELD
     int pollcount = 0;
 #endif
@@ -905,8 +905,8 @@
 	    mpi_errno = MPID_nem_network_poll(TRUE /* blocking */);
             if (mpi_errno) MPIU_ERR_POP (mpi_errno);
 
-            if (completions != MPIDI_CH3I_progress_completion_count || MPID_nem_local_lmt_pending || MPIDI_CH3I_active_send[CH3_NORMAL_QUEUE]
-                || MPIDI_CH3I_SendQ_head(CH3_NORMAL_QUEUE))
+            if (completions != OPA_load_int(&MPIDI_CH3I_progress_completion_count) || MPID_nem_local_lmt_pending
+                || MPIDI_CH3I_active_send[CH3_NORMAL_QUEUE] || MPIDI_CH3I_SendQ_head(CH3_NORMAL_QUEUE))
             {
                 *cell = NULL;
                 *in_fbox = 0;

Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/src/ch3_progress.c	2011-01-11 20:04:11 UTC (rev 7686)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/src/ch3_progress.c	2011-01-11 23:28:13 UTC (rev 7687)
@@ -33,11 +33,7 @@
 extern MPID_Request ** const MPID_Recvq_unexpected_tail_ptr;
 #endif
 
-/* MT any races on this var reported by DRD/helgrind/TSan are probably bugs.
- * This var is protected by the COMPLETION critical section in non-global mode. */
-/* FIXME volatile is probably unnecessary, access is arbitrated entirely by
- * mutex, but the decl is shared among channels */
-volatile unsigned int MPIDI_CH3I_progress_completion_count = 0;
+OPA_int_t MPIDI_CH3I_progress_completion_count = OPA_INT_T_INITIALIZER(0);
 
 /* NEMESIS MULTITHREADING: Extra Data Structures Added */
 #ifdef MPICH_IS_THREADED
@@ -448,19 +444,20 @@
     
         /* in the case of progress_wait, bail out if anything completed (CC-1) */
         if (is_blocking) {
-            int made_progress = FALSE;
-            MPIU_THREAD_CS_ENTER(COMPLETION,);
-            if (progress_state->ch.completion_count != MPIDI_CH3I_progress_completion_count) {
-                made_progress = TRUE;
+            int completion_count = OPA_load_int(&MPIDI_CH3I_progress_completion_count);
+            if (progress_state->ch.completion_count != completion_count) {
+                /* Read barrier to make sure no reads get values before the
+                   completion counter was incremented  */
+                OPA_read_barrier();
                 /* reset for the next iteration */
-                progress_state->ch.completion_count = MPIDI_CH3I_progress_completion_count;
+                progress_state->ch.completion_count = completion_count;
+                break;
             }
-            MPIU_THREAD_CS_EXIT(COMPLETION,);
-            if (made_progress) break;
         }
     }
     while (is_blocking);
 
+    
 #ifdef MPICH_IS_THREADED
     MPIU_THREAD_CHECK_BEGIN;
     {
@@ -498,15 +495,9 @@
     {
 	while (1)
 	{
-            /* we also currently hold the MPIDCOMM CS */
-            MPIU_THREAD_CS_ENTER(COMPLETION,);
-            if (completion_count != MPIDI_CH3I_progress_completion_count ||
+            if (completion_count != OPA_load_int(&MPIDI_CH3I_progress_completion_count) ||
                 MPIDI_CH3I_progress_blocked != TRUE)
-            {
-                MPIU_THREAD_CS_EXIT(COMPLETION,);
                 break;
-            }
-            MPIU_THREAD_CS_EXIT(COMPLETION,);
 	    MPID_Thread_cond_wait(&MPIDI_CH3I_progress_completion_cond, &MPIR_ThreadInfo.global_mutex/*MPIDCOMM*/);
 	}
     }

Modified: mpich2/trunk/src/mpid/ch3/channels/sctp/include/mpidi_ch3_pre.h
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/sctp/include/mpidi_ch3_pre.h	2011-01-11 20:04:11 UTC (rev 7686)
+++ mpich2/trunk/src/mpid/ch3/channels/sctp/include/mpidi_ch3_pre.h	2011-01-11 23:28:13 UTC (rev 7687)
@@ -229,4 +229,9 @@
 
 #define MPIDI_CH3_PROGRESS_STATE_DECL MPIDI_CH3I_Progress_state ch;
 
+
+/* This variable is used in the definitions of the MPID_Progress_xxx macros,
+   and must be available to the routines in src/mpi */
+extern volatile unsigned int MPIDI_CH3I_progress_completion_count;
+
 #endif /* !defined(MPICH_MPIDI_CH3_PRE_H_INCLUDED) */

Modified: mpich2/trunk/src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h	2011-01-11 20:04:11 UTC (rev 7686)
+++ mpich2/trunk/src/mpid/ch3/channels/sock/include/mpidi_ch3_pre.h	2011-01-11 23:28:13 UTC (rev 7687)
@@ -58,6 +58,11 @@
 
 #define MPIDI_CH3_PROGRESS_STATE_DECL MPIDI_CH3I_Progress_state ch;
 
+/* This variable is used in the definitions of the MPID_Progress_xxx macros,
+   and must be available to the routines in src/mpi */
+extern volatile unsigned int MPIDI_CH3I_progress_completion_count;
+
+
 /* MPICH_IS_THREADED isn't defined yet (handled by mpiimplthread.h) */
 #if (MPICH_THREAD_LEVEL == MPI_THREAD_MULTIPLE)
 #define MPIDI_CH3I_PROGRESS_WAKEUP                                                                \

Modified: mpich2/trunk/src/mpid/ch3/include/mpidpost.h
===================================================================
--- mpich2/trunk/src/mpid/ch3/include/mpidpost.h	2011-01-11 20:04:11 UTC (rev 7686)
+++ mpich2/trunk/src/mpid/ch3/include/mpidpost.h	2011-01-11 23:28:13 UTC (rev 7687)
@@ -159,10 +159,6 @@
 @*/
 void MPIDI_CH3U_Request_destroy(MPID_Request * req);
 
-/* This variable is used in the definitions of the MPID_Progress_xxx macros,
-   and must be available to the routines in src/mpi */
-extern volatile unsigned int MPIDI_CH3I_progress_completion_count;
-
 /* Include definitions from the channel which require items defined by this 
    file (mpidimpl.h) or the file it includes
    (mpiimpl.h). */



More information about the mpich2-commits mailing list