Skip to content

Commit 8b52d55

Browse files
committed
posix/iqueue: support comm_set_vcis
1 parent a7a5618 commit 8b52d55

File tree

7 files changed

+49
-48
lines changed

7 files changed

+49
-48
lines changed

src/mpid/ch4/shm/posix/eager/include/posix_eager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
typedef int (*MPIDI_POSIX_eager_init_t) (int rank, int size);
1414
typedef int (*MPIDI_POSIX_eager_post_init_t) (void);
15-
typedef int (*MPIDI_POSIX_eager_set_vcis_t) (MPIR_Comm * comm);
15+
typedef int (*MPIDI_POSIX_eager_set_vcis_t) (MPIR_Comm * comm, int num_vcis);
1616
typedef int (*MPIDI_POSIX_eager_finalize_t) (void);
1717

1818
typedef int (*MPIDI_POSIX_eager_send_t) (int grank, MPIDI_POSIX_am_header_t * msg_hdr,
@@ -61,7 +61,7 @@ extern char MPIDI_POSIX_eager_strings[][MPIDI_MAX_POSIX_EAGER_STRING_LEN];
6161

6262
int MPIDI_POSIX_eager_init(int rank, int size);
6363
int MPIDI_POSIX_eager_post_init(void);
64-
int MPIDI_POSIX_eager_set_vcis(MPIR_Comm * comm);
64+
int MPIDI_POSIX_eager_set_vcis(MPIR_Comm * comm, int num_vcis);
6565
int MPIDI_POSIX_eager_finalize(void);
6666

6767
MPL_STATIC_INLINE_PREFIX int MPIDI_POSIX_eager_send(int grank, MPIDI_POSIX_am_header_t * msg_hdr,

src/mpid/ch4/shm/posix/eager/iqueue/iqueue_init.c

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

src/mpid/ch4/shm/posix/eager/iqueue/iqueue_noinline.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
int MPIDI_POSIX_iqueue_init(int rank, int size);
1313
int MPIDI_POSIX_iqueue_post_init(void);
14-
int MPIDI_POSIX_iqueue_set_vcis(MPIR_Comm * comm);
14+
int MPIDI_POSIX_iqueue_set_vcis(MPIR_Comm * comm, int num_vcis);
1515
int MPIDI_POSIX_iqueue_finalize(void);
1616

1717
#ifdef POSIX_EAGER_INLINE

src/mpid/ch4/shm/posix/eager/iqueue/iqueue_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef struct MPIDI_POSIX_eager_iqueue_global {
4040
int terminal_offset;
4141
/* shmem slabs */
4242
void *root_slab;
43-
void *all_slab;
43+
void *all_vci_slab;
4444
/* 2d array indexed with [src_vci][dst_vci] */
4545
MPIDI_POSIX_eager_iqueue_transport_t transports[MPIDI_CH4_MAX_VCIS][MPIDI_CH4_MAX_VCIS];
4646
} MPIDI_POSIX_eager_iqueue_global_t;

src/mpid/ch4/shm/posix/eager/src/posix_eager_impl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ int MPIDI_POSIX_eager_post_init(void)
1919
return MPIDI_POSIX_eager_func->post_init();
2020
}
2121

22-
int MPIDI_POSIX_eager_set_vcis(MPIR_Comm * comm)
22+
int MPIDI_POSIX_eager_set_vcis(MPIR_Comm * comm, int num_vcis)
2323
{
24-
return MPIDI_POSIX_eager_func->set_vcis(comm);
24+
return MPIDI_POSIX_eager_func->set_vcis(comm, num_vcis);
2525
}
2626

2727
int MPIDI_POSIX_eager_finalize(void)

src/mpid/ch4/shm/posix/eager/stub/stub_noinline.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
int MPIDI_POSIX_stub_init(int rank, int size);
1212
int MPIDI_POSIX_stub_post_init(void);
13-
int MPIDI_POSIX_stub_set_vcis(MPIR_Comm * comm);
13+
int MPIDI_POSIX_stub_set_vcis(MPIR_Comm * comm, int num_vcis);
1414
int MPIDI_POSIX_stub_finalize(void);
1515

1616
#ifdef POSIX_EAGER_INLINE

src/mpid/ch4/shm/posix/posix_vci.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,27 @@ int MPIDI_POSIX_comm_set_vcis(MPIR_Comm * comm, int num_vcis)
1313
/* We only set up vcis once */
1414
MPIR_Assert(MPIDI_POSIX_global.num_vcis == 1);
1515

16+
int max_vcis;
1617
MPIR_Comm *node_comm = comm->node_comm;
1718
if (node_comm == NULL) {
18-
/* nothing to do if there is no local domain */
19-
goto fn_exit;
19+
max_vcis = num_vcis;
20+
} else {
21+
mpi_errno = MPIR_Allreduce_impl(&num_vcis, &max_vcis, 1, MPIR_INT_INTERNAL, MPI_MAX,
22+
node_comm, MPIR_ERR_NONE);
23+
MPIR_ERR_CHECK(mpi_errno);
2024
}
2125

22-
int max_vcis;
23-
mpi_errno = MPIR_Allreduce_impl(&num_vcis, &max_vcis, 1, MPI_INT, MPI_MAX, node_comm,
24-
MPIR_ERR_NONE);
25-
26-
MPIDI_POSIX_global.num_vcis = max_vcis;
26+
if (max_vcis > 1) {
27+
for (int i = 1; i < max_vcis; i++) {
28+
mpi_errno = MPIDI_POSIX_init_vci(i);
29+
MPIR_ERR_CHECK(mpi_errno);
30+
}
2731

28-
for (int i = 1; i < MPIDI_POSIX_global.num_vcis; i++) {
29-
mpi_errno = MPIDI_POSIX_init_vci(i);
32+
mpi_errno = MPIDI_POSIX_eager_set_vcis(comm, max_vcis);
3033
MPIR_ERR_CHECK(mpi_errno);
3134
}
3235

33-
mpi_errno = MPIDI_POSIX_eager_set_vcis(comm);
34-
MPIR_ERR_CHECK(mpi_errno);
36+
MPIDI_POSIX_global.num_vcis = max_vcis;
3537

3638
fn_exit:
3739
return mpi_errno;

0 commit comments

Comments
 (0)