Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 6daa76a

Browse files
committed
opal_progress: add a MCA variable to control lp progress
This commit adds a MCA variable to control how often low-priority callbacks are made relative to high-priority callbacks. This was added per discussion on telcon on May 24, 2016. Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
1 parent 148dd57 commit 6daa76a

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

opal/runtime/opal_params.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "opal/dss/dss.h"
4646
#include "opal/util/show_help.h"
4747
#include "opal/util/timings.h"
48+
#include "opal/util/bit_ops.h"
4849

4950
char *opal_signal_string = NULL;
5051
char *opal_net_private_ipv4 = NULL;
@@ -66,6 +67,7 @@ int opal_leave_pinned = -1;
6667
bool opal_leave_pinned_pipeline = false;
6768
bool opal_abort_print_stack = false;
6869
int opal_abort_delay = 0;
70+
unsigned int opal_progress_lp_call_ratio = 8;
6971

7072
static bool opal_register_done = false;
7173

@@ -279,6 +281,23 @@ int opal_register_params(void)
279281
return ret;
280282
}
281283

284+
opal_progress_lp_call_ratio = 8;
285+
ret = mca_base_var_register("opal", "opal", NULL, "progress_lp_call_ratio",
286+
"Ratio of calls to high-priority to low-priority progress "
287+
"functions. Higher numbers decrease the frequency of the callback "
288+
"rate. Must be a power of two (default: 8)",
289+
MCA_BASE_VAR_TYPE_UNSIGNED_INT, NULL, 0, 0,
290+
OPAL_INFO_LVL_5,
291+
MCA_BASE_VAR_SCOPE_READONLY,
292+
&opal_progress_lp_call_ratio);
293+
if (0 > ret) {
294+
return ret;
295+
}
296+
297+
if (opal_progress_lp_call_ratio & (opal_progress_lp_call_ratio - 1)) {
298+
opal_progress_lp_call_ratio = (unsigned int) opal_next_poweroftwo_inclusive ((int) opal_progress_lp_call_ratio);
299+
}
300+
282301
opal_abort_print_stack = false;
283302
ret = mca_base_var_register("opal", "opal", NULL, "abort_print_stack",
284303
"If nonzero, print out a stack trace when abort is invoked",

opal/runtime/opal_params.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ OPAL_DECLSPEC extern bool opal_abort_print_stack;
7373
*/
7474
OPAL_DECLSPEC extern int opal_abort_delay;
7575

76+
/**
77+
* Ratio of calls to high-priority to low-priority progress functions.
78+
* Must be a power of two.
79+
*/
80+
OPAL_DECLSPEC extern unsigned int opal_progress_lp_call_ratio;
81+
7682
#if OPAL_ENABLE_DEBUG
7783
extern bool opal_progress_debug;
7884
#endif

opal/runtime/opal_progress.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static size_t callbacks_size = 0;
6262
static opal_progress_callback_t *callbacks_lp = NULL;
6363
static size_t callbacks_lp_len = 0;
6464
static size_t callbacks_lp_size = 0;
65+
static uint64_t callbacks_lp_mask = 0x7;
6566

6667
/* do we want to call sched_yield() if nothing happened */
6768
bool opal_progress_yield_when_idle = false;
@@ -109,6 +110,8 @@ opal_progress_init(void)
109110
}
110111
#endif
111112

113+
callbacks_lp_mask = opal_progress_lp_call_ratio - 1;
114+
112115
OPAL_OUTPUT((debug_output, "progress: initialized event flag to: %x",
113116
opal_progress_event_flag));
114117
OPAL_OUTPUT((debug_output, "progress: initialized yield_when_idle to: %s",
@@ -194,7 +197,7 @@ opal_progress(void)
194197
events += (callbacks[i])();
195198
}
196199

197-
if ((OPAL_THREAD_ADD64((volatile int64_t *) &num_calls, 1) & 0x7) == 0) {
200+
if ((OPAL_THREAD_ADD64((volatile int64_t *) &num_calls, 1) & callbacks_lp_mask) == 0) {
198201
/* run low priority callbacks once every 8 calls to opal_progress() */
199202
for (i = 0 ; i < callbacks_lp_len ; ++i) {
200203
events += (callbacks_lp[i])();

0 commit comments

Comments
 (0)