Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / gmxlib / thread_mpi / impl.h
index 0f9150f1fe23b537b84e5a42416eb1b84ec7afc6..43a8ac1e5210939bf50f5fb15547e3e10a33a958 100644 (file)
@@ -490,6 +490,10 @@ struct tmpi_global
     /* spinlock/mutex for manipulating tmpi_user_types */
     tMPI_Spinlock_t  datatype_lock;
 
+    /* Lock to prevent multiple threads manipulating the linked list of comm
+       structures.*/
+    tMPI_Thread_mutex_t comm_link_lock;
+
     /* barrier for tMPI_Finalize(), etc. */
     tMPI_Thread_barrier_t barrier;
 
@@ -584,9 +588,13 @@ struct tmpi_comm_
        TMPI_COMM_WORLD. Used to de-allocate the comm structures after 
        tMPI_Finalize(). */
     struct tmpi_comm_ *next,*prev;
+
+    /* A counter that counts up to N before the comm is freed. */
+    tMPI_Atomic_t destroy_counter;
 };
 
 
+
 /* specific for tMPI_Split: */
 struct tmpi_split
 { 
@@ -733,7 +741,7 @@ int tMPI_Comm_N(tMPI_Comm comm);
 /* allocate a comm object, making space for N threads */
 tMPI_Comm tMPI_Comm_alloc(tMPI_Comm parent, int N);
 /* de-allocate a comm object */
-void tMPI_Comm_destroy(tMPI_Comm comm);
+void tMPI_Comm_destroy(tMPI_Comm comm, tmpi_bool do_link_lock);
 /* allocate a group object */
 tMPI_Group tMPI_Group_alloc(void);