@@ -101,7 +101,7 @@ int MPIDI_POSIX_iqueue_init(int rank, int size)
101101 int nprocs = MPIR_Process .local_size ;
102102
103103 int pool_size = MPIDU_genq_shmem_pool_size (cell_size , num_cells , nprocs , num_free_queue );
104- int terminal_size = num_proc * sizeof (MPIDU_genq_shmem_queue_u );
104+ int terminal_size = nprocs * sizeof (MPIDU_genq_shmem_queue_u );
105105
106106 int slab_size = pool_size + terminal_size ;
107107
@@ -133,27 +133,22 @@ int MPIDI_POSIX_iqueue_post_init(void)
133133 return mpi_errno ;
134134}
135135
136- int MPIDI_POSIX_iqueue_set_vcis (MPIR_Comm * comm )
136+ int MPIDI_POSIX_iqueue_set_vcis (MPIR_Comm * comm , int max_vcis )
137137{
138138 int mpi_errno = MPI_SUCCESS ;
139139 MPIR_FUNC_ENTER ;
140140
141- MPIR_Assert (comm == MPIR_Process .comm_world ); /* TODO: relax this */
142- MPIR_Assert (MPIDI_POSIX_eager_iqueue_global .all_slab == NULL );
141+ MPIR_Assert (MPIDI_POSIX_eager_iqueue_global .all_vci_slab == NULL );
143142
144- int max_vcis = MPIDI_POSIX_global .num_vcis ;
145- MPIDI_POSIX_eager_iqueue_global .max_vcis = max_vcis ;
146143 MPIDU_Init_shm_barrier ();
147144
148- MPIDI_POSIX_eager_iqueue_global .max_vcis = max_vcis ;
149145 int slab_size = MPIDI_POSIX_eager_iqueue_global .slab_size * max_vcis * max_vcis ;
150146 /* Create the shared memory regions for all vcis */
151- /* TODO: do shm alloc in a comm */
152147 void * slab ;
153- mpi_errno = MPIDU_Init_shm_alloc ( slab_size , (void * ) & slab );
148+ mpi_errno = MPIDU_Init_shm_comm_alloc ( comm , slab_size , (void * ) & slab );
154149 MPIR_ERR_CHECK (mpi_errno );
155150
156- MPIDI_POSIX_eager_iqueue_global .all_slab = slab ;
151+ MPIDI_POSIX_eager_iqueue_global .all_vci_slab = slab ;
157152
158153 for (int vci_src = 0 ; vci_src < max_vcis ; vci_src ++ ) {
159154 for (int vci_dst = 0 ; vci_dst < max_vcis ; vci_dst ++ ) {
@@ -167,8 +162,10 @@ int MPIDI_POSIX_iqueue_set_vcis(MPIR_Comm * comm)
167162 }
168163 }
169164
170- if (comm ) {
171- mpi_errno = MPIR_Barrier_impl (comm , MPIR_ERR_NONE );
165+ MPIDI_POSIX_eager_iqueue_global .max_vcis = max_vcis ;
166+
167+ if (comm -> node_comm ) {
168+ mpi_errno = MPIR_Barrier_impl (comm -> node_comm , MPIR_ERR_NONE );
172169 MPIR_ERR_CHECK (mpi_errno );
173170 }
174171
@@ -184,34 +181,36 @@ int MPIDI_POSIX_iqueue_finalize(void)
184181
185182 MPIR_FUNC_ENTER ;
186183
187- if (MPIDI_POSIX_eager_iqueue_global .max_vcis . root_slab ) {
184+ if (MPIDI_POSIX_eager_iqueue_global .root_slab ) {
188185 MPIDI_POSIX_eager_iqueue_transport_t * transport ;
189- transport = MPIDI_POSIX_eager_iqueue_get_transport (vci_src , vci_dst );
186+ transport = MPIDI_POSIX_eager_iqueue_get_transport (0 , 0 );
190187
191188 mpi_errno = MPIDU_genq_shmem_pool_destroy (transport -> cell_pool );
192189 MPIR_ERR_CHECK (mpi_errno );
193190
194- mpi_errno = MPIDU_Init_shm_free (MPIDI_POSIX_eager_iqueue_global .max_vcis . root_slab );
191+ mpi_errno = MPIDU_Init_shm_free (MPIDI_POSIX_eager_iqueue_global .root_slab );
195192 MPIR_ERR_CHECK (mpi_errno );
196- MPIDI_POSIX_eager_iqueue_global .max_vcis . root_slab = NULL ;
193+ MPIDI_POSIX_eager_iqueue_global .root_slab = NULL ;
197194 }
198195
199- if (!MPIDI_POSIX_eager_iqueue_global .max_vcis .all_slab ) {
200- goto fn_exit ;
201- }
202- int max_vcis = MPIDI_POSIX_eager_iqueue_global .max_vcis ;
203- for (int vci_src = 0 ; vci_src < max_vcis ; vci_src ++ ) {
204- for (int vci_dst = 0 ; vci_dst < max_vcis ; vci_dst ++ ) {
205- MPIDI_POSIX_eager_iqueue_transport_t * transport ;
206- transport = MPIDI_POSIX_eager_iqueue_get_transport (vci_src , vci_dst );
207-
208- mpi_errno = MPIDU_genq_shmem_pool_destroy (transport -> cell_pool );
209- MPIR_ERR_CHECK (mpi_errno );
196+ if (MPIDI_POSIX_eager_iqueue_global .all_vci_slab ) {
197+ int max_vcis = MPIDI_POSIX_eager_iqueue_global .max_vcis ;
198+ for (int vci_src = 0 ; vci_src < max_vcis ; vci_src ++ ) {
199+ for (int vci_dst = 0 ; vci_dst < max_vcis ; vci_dst ++ ) {
200+ if (vci_src == 0 && vci_dst == 0 ) {
201+ continue ;
202+ }
203+ MPIDI_POSIX_eager_iqueue_transport_t * transport ;
204+ transport = MPIDI_POSIX_eager_iqueue_get_transport (vci_src , vci_dst );
205+
206+ mpi_errno = MPIDU_genq_shmem_pool_destroy (transport -> cell_pool );
207+ MPIR_ERR_CHECK (mpi_errno );
208+ }
210209 }
210+ mpi_errno = MPIDU_Init_shm_free (MPIDI_POSIX_eager_iqueue_global .all_vci_slab );
211+ MPIR_ERR_CHECK (mpi_errno );
212+ MPIDI_POSIX_eager_iqueue_global .all_vci_slab = NULL ;
211213 }
212- mpi_errno = MPIDU_Init_shm_free (MPIDI_POSIX_eager_iqueue_global .max_vcis .all_slab );
213- MPIR_ERR_CHECK (mpi_errno );
214- MPIDI_POSIX_eager_iqueue_global .max_vcis .all_slab = NULL ;
215214
216215 fn_exit :
217216 MPIR_FUNC_EXIT ;
0 commit comments