Skip to content

Commit 9e0a42a

Browse files
committed
ch4/ipc: skip usage of initshm if local_size is 1
MPIDU_Init_shm_get will assert fail for single local process since the initshm won't be created. In fact, we should skip ipc initialization entirely if local_size is 1 since IPC won't be needed.
1 parent 15e0508 commit 9e0a42a

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/mpid/ch4/shm/ipc/gpu/gpu_init.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ int MPIDI_GPU_init_world(void)
6262
if (device_count < 0)
6363
goto fn_exit;
6464

65+
if (MPIR_Process.local_size == 1) {
66+
goto fn_exit;
67+
}
68+
6569
local_gpu_info.max_dev_id = remote_gpu_info.max_dev_id = my_max_dev_id;
6670
local_gpu_info.max_subdev_id = remote_gpu_info.max_subdev_id = my_max_subdev_id;
6771

src/mpid/ch4/shm/ipc/src/ipc_fd.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ static int MPIDI_IPC_mpi_fd_cleanup(void)
5858
char strerrbuf[MPIR_STRERROR_BUF_SIZE] ATTRIBUTE((unused));
5959
int i;
6060

61+
if (!MPIDI_IPCI_global_fd_pids || !MPIDI_IPCI_global_fd_socks) {
62+
/* skip if not initialized */
63+
goto fn_exit;
64+
}
65+
6166
/* Close sockets */
6267
for (i = 0; i < MPIR_Process.local_size; ++i) {
6368
if (MPIDI_IPCI_global_fd_socks[i] != -1) {
@@ -151,6 +156,11 @@ int MPIDI_IPC_mpi_socks_init(void)
151156
pid_t pid;
152157
int enable = 1;
153158

159+
if (MPIR_Process.local_size == 1) {
160+
/* skip if not needed */
161+
goto fn_exit;
162+
}
163+
154164
memset(&sockaddr, 0, sizeof(sockaddr));
155165

156166
fd_count = MPIR_Process.local_size;
@@ -322,6 +332,8 @@ int MPIDI_IPC_mpi_fd_send(int rank, int fd, void *payload, size_t payload_len)
322332
char strerrbuf[MPIR_STRERROR_BUF_SIZE] ATTRIBUTE((unused));
323333
char empty_buf;
324334

335+
MPIR_Assert(rank != MPIR_Process.local_rank);
336+
325337
/* Setup a payload if provided */
326338
if (payload == NULL) {
327339
iov.iov_base = &empty_buf;
@@ -369,6 +381,8 @@ int MPIDI_IPC_mpi_fd_recv(int rank, int *fd, void *payload, size_t payload_len,
369381
char empty_buf;
370382
bool trunc_check;
371383

384+
MPIR_Assert(rank != MPIR_Process.local_rank);
385+
372386
/* Setup a payload if provided */
373387
if (payload == NULL) {
374388
iov.iov_base = &empty_buf;

src/mpid/ch4/shm/ipc/xpmem/xpmem_init.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ int MPIDI_XPMEM_init_world(void)
2525
goto fn_exit;
2626
}
2727

28+
if (MPIR_Process.local_size == 1) {
29+
goto fn_exit;
30+
}
31+
2832
MPIR_FUNC_ENTER;
2933
MPIR_CHKPMEM_DECL();
3034

0 commit comments

Comments
 (0)