Skip to content

Commit c41032d

Browse files
committed
ch4/progress: add MPIR_CVAR_CH4_PROGRESS_THROTTLE_NUM_PAUSES
Add alternative method to throttle, e.g. sched_yield or PAUSE, and use MPIR_CVAR_CH4_PROGRESS_THROTTLE_NUM_PAUSES to control the amount of throttle.
1 parent 845981c commit c41032d

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/mpid/ch4/src/ch4_progress.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include "ch4_impl.h"
1010
#include "stream_workq.h"
11+
/* FIXME: configure check sched_yield */
12+
#include <sched.h>
1113

1214
/*
1315
=== BEGIN_MPI_T_CVAR_INFO_BLOCK ===
@@ -59,6 +61,17 @@
5961
When MPIR_CVAR_CH4_PROGRESS_THROTTLE=true, do throttle when minimum of MPIR_CVAR_CH4_PROGRESS_THROTTLE_MIN_PROCS
6062
processes enter the throttle state (no_progress_counter reach MPIR_CVAR_CH4_PROGRESS_THROTTLE_NO_PROGRESS_COUNT).
6163
64+
- name : MPIR_CVAR_CH4_PROGRESS_THROTTLE_NUM_PAUSES
65+
category : CH4
66+
type : int
67+
default : 1
68+
class : none
69+
verbosity : MPI_T_VERBOSITY_USER_BASIC
70+
scope : MPI_T_SCOPE_LOCAL
71+
description : >-
72+
Set the number of PAUSE (or thread_yield) for each progress throttle. If set to 0 (default), it uses
73+
usleep(1) for throttle.
74+
6275
=== END_MPI_T_CVAR_INFO_BLOCK ===
6376
*/
6477

@@ -175,9 +188,6 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_progress_test(MPID_Progress_state * state)
175188
for (int vci = 0; vci < MPIDI_global.n_vcis; vci++) {
176189
MPIDI_PROGRESS(vci, true);
177190
}
178-
if (!made_progress && MPIR_CVAR_CH4_PROGRESS_THROTTLE) {
179-
usleep(1);
180-
}
181191
} else {
182192
for (int i = 0; i < state->vci_count; i++) {
183193
int vci = state->vci[i];
@@ -202,7 +212,13 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_progress_test(MPID_Progress_state * state)
202212
} else if (no_progress_counter > MPIR_CVAR_CH4_PROGRESS_THROTTLE_NO_PROGRESS_COUNT) {
203213
int throttle_id = MPIDI_progress_throttle_start();
204214
if (throttle_id > MPIR_CVAR_CH4_PROGRESS_THROTTLE_MIN_PROCS) {
205-
usleep(1);
215+
if (MPIR_CVAR_CH4_PROGRESS_THROTTLE_NUM_PAUSES == 0) {
216+
usleep(1);
217+
} else {
218+
for (int i = 0; i < MPIR_CVAR_CH4_PROGRESS_THROTTLE_NUM_PAUSES; i++) {
219+
sched_yield();
220+
}
221+
}
206222
}
207223
} else {
208224
no_progress_counter++;

0 commit comments

Comments
 (0)