From 8b4b5c979785d5bc591029e844549674ac24975f Mon Sep 17 00:00:00 2001 From: Ken Raffenetti Date: Tue, 7 Oct 2025 20:26:39 -0500 Subject: [PATCH 1/4] ch4/progress: Improvements to global progress When global progress is triggered we should ignore the progress state flags and just call every progress function. We also need to trigger global progress in the single vci case because we plan to make the progress loop locality aware. --- src/mpid/ch4/src/ch4_progress.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mpid/ch4/src/ch4_progress.h b/src/mpid/ch4/src/ch4_progress.h index 67a244a23b0..8dee4dd4d46 100644 --- a/src/mpid/ch4/src/ch4_progress.h +++ b/src/mpid/ch4/src/ch4_progress.h @@ -64,8 +64,7 @@ extern MPL_TLS int no_progress_counter; MPL_STATIC_INLINE_PREFIX int MPIDI_do_global_progress(void) { - if ((MPIDI_global.n_vcis == 1 || !MPIR_CVAR_CH4_GLOBAL_PROGRESS) && - !MPIR_CVAR_CH4_PROGRESS_THROTTLE) { + if (!MPIR_CVAR_CH4_GLOBAL_PROGRESS && !MPIR_CVAR_CH4_PROGRESS_THROTTLE) { return 0; } else { global_vci_poll_count++; @@ -88,7 +87,7 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_do_global_progress(void) #ifdef MPIDI_CH4_DIRECT_NETMOD #define MPIDI_PROGRESS(vci, is_global) \ do { \ - if (state->flag & MPIDI_PROGRESS_NM && (is_global || !made_progress)) { \ + if (is_global || (state->flag & MPIDI_PROGRESS_NM && !made_progress)) { \ MPIDI_THREAD_CS_ENTER_VCI_OPTIONAL(vci); \ mpi_errno = MPIDI_NM_progress(vci, &made_progress); \ MPIDI_THREAD_CS_EXIT_VCI_OPTIONAL(vci); \ @@ -99,13 +98,13 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_do_global_progress(void) #else #define MPIDI_PROGRESS(vci, is_global) \ do { \ - if (state->flag & MPIDI_PROGRESS_SHM && (is_global || !made_progress)) { \ + if (is_global || (state->flag & MPIDI_PROGRESS_SHM && !made_progress)) { \ MPID_THREAD_CS_ENTER(VCI, MPIDI_VCI_LOCK(vci)); \ mpi_errno = MPIDI_SHM_progress(vci, &made_progress); \ MPID_THREAD_CS_EXIT(VCI, MPIDI_VCI_LOCK(vci)); \ MPIR_ERR_CHECK(mpi_errno); \ } \ - if (state->flag & MPIDI_PROGRESS_NM && (is_global || !made_progress)) { \ + if (is_global || (state->flag & MPIDI_PROGRESS_NM && !made_progress)) { \ MPIDI_THREAD_CS_ENTER_VCI_OPTIONAL(vci); \ mpi_errno = MPIDI_NM_progress(vci, &made_progress); \ MPIDI_THREAD_CS_EXIT_VCI_OPTIONAL(vci); \ From 527a225f76634613e837ae57eb106968282372b5 Mon Sep 17 00:00:00 2001 From: Ken Raffenetti Date: Mon, 13 Oct 2025 13:55:16 -0500 Subject: [PATCH 2/4] ch4: Initialize request locality at creation When a request is created, initialize is_local to false. Avoids accidentally reading an uninitialized value. Other layers will update the value to true where appropriate, such as the shared memory or generic active message code. --- src/mpid/ch4/include/mpidpost.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mpid/ch4/include/mpidpost.h b/src/mpid/ch4/include/mpidpost.h index 0776e979d9e..af4dd7ba0fe 100644 --- a/src/mpid/ch4/include/mpidpost.h +++ b/src/mpid/ch4/include/mpidpost.h @@ -28,6 +28,7 @@ MPL_STATIC_INLINE_PREFIX void MPID_Request_create_hook(MPIR_Request * req) req->dev.type = MPIDI_REQ_TYPE_NONE; #ifndef MPIDI_CH4_DIRECT_NETMOD req->dev.anysrc_partner = NULL; + req->dev.is_local = 0; #endif MPIR_FUNC_EXIT; From d1f41d89fb81d39f5f0f6650f2bda746ed2ea1cf Mon Sep 17 00:00:00 2001 From: Ken Raffenetti Date: Mon, 13 Oct 2025 14:45:54 -0500 Subject: [PATCH 3/4] ch4/ipc: Add missing locality setting IPC protocol is local by definition, so make sure to reflect that in any requests created in IPC code. --- src/mpid/ch4/shm/ipc/src/ipc_p2p.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mpid/ch4/shm/ipc/src/ipc_p2p.h b/src/mpid/ch4/shm/ipc/src/ipc_p2p.h index 299e9ee39b2..a7d52e3f5e9 100644 --- a/src/mpid/ch4/shm/ipc/src/ipc_p2p.h +++ b/src/mpid/ch4/shm/ipc/src/ipc_p2p.h @@ -203,6 +203,7 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_IPCI_send_lmt(const void *buf, MPI_Aint count MPIDIG_REQUEST(sreq, u.ipc.peer_rank) = rank; MPIDIG_REQUEST(sreq, u.ipc.peer_req) = NULL; MPIDIG_REQUEST(sreq, u.ipc.src_dt_ptr) = NULL; + MPIDI_REQUEST_SET_LOCAL(sreq, 1, NULL); MPIDI_SHM_REQUEST(sreq, ipc.ipc_type) = ipc_attr->ipc_type; /* Allocate am_hdr and fill ipc_hdr */ From 67241fe9d6f8f6e44f3878392c4c699bed768e2a Mon Sep 17 00:00:00 2001 From: Ken Raffenetti Date: Fri, 10 Oct 2025 09:02:52 -0500 Subject: [PATCH 4/4] ch4/wait: Optimize progress for local requests Skip netmod progress when the request(s) being waited on are determined to be local only. --- src/mpid/ch4/src/ch4_wait.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/mpid/ch4/src/ch4_wait.h b/src/mpid/ch4/src/ch4_wait.h index d6456a26c2b..d46321e4b02 100644 --- a/src/mpid/ch4/src/ch4_wait.h +++ b/src/mpid/ch4/src/ch4_wait.h @@ -11,18 +11,27 @@ MPL_STATIC_INLINE_PREFIX void MPIDI_set_progress_vci(MPIR_Request * req, MPID_Progress_state * state) { - state->flag = MPIDI_PROGRESS_ALL; /* TODO: check request is_local/anysource */ + state->flag = MPIDI_PROGRESS_ALL; int vci = MPIDI_Request_get_vci(req); state->vci_count = 1; state->vci[0] = vci; + +#ifndef MPIDI_CH4_DIRECT_NETMOD + if (!req->dev.anysrc_partner && MPIDI_REQUEST(req, is_local)) { + state->flag &= ~MPIDI_PROGRESS_NM; + } +#endif } MPL_STATIC_INLINE_PREFIX void MPIDI_set_progress_vci_n(int n, MPIR_Request ** reqs, MPID_Progress_state * state) { - state->flag = MPIDI_PROGRESS_ALL; /* TODO: check request is_local/anysource */ + state->flag = MPIDI_PROGRESS_ALL; +#ifndef MPIDI_CH4_DIRECT_NETMOD + state->flag &= ~MPIDI_PROGRESS_NM; +#endif int idx = 0; for (int i = 0; i < n; i++) { @@ -45,6 +54,11 @@ MPL_STATIC_INLINE_PREFIX void MPIDI_set_progress_vci_n(int n, MPIR_Request ** re if (!found) { state->vci[idx++] = vci; } +#ifndef MPIDI_CH4_DIRECT_NETMOD + if (!MPIDI_REQUEST(reqs[i], is_local) || reqs[i]->dev.anysrc_partner) { + state->flag |= MPIDI_PROGRESS_NM; + } +#endif } state->vci_count = idx; }