Merge pull request #5241 from thananon/opal_progress
Add MCA param for multithread opal_progress().
Этот коммит содержится в:
Коммит
3dc1629771
@ -76,6 +76,8 @@ bool opal_leave_pinned_pipeline = false;
|
|||||||
bool opal_abort_print_stack = false;
|
bool opal_abort_print_stack = false;
|
||||||
int opal_abort_delay = 0;
|
int opal_abort_delay = 0;
|
||||||
|
|
||||||
|
int opal_max_thread_in_progress = 1;
|
||||||
|
|
||||||
static bool opal_register_done = false;
|
static bool opal_register_done = false;
|
||||||
|
|
||||||
int opal_register_params(void)
|
int opal_register_params(void)
|
||||||
@ -360,6 +362,12 @@ int opal_register_params(void)
|
|||||||
MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_INTERNAL, OPAL_INFO_LVL_3,
|
MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_INTERNAL, OPAL_INFO_LVL_3,
|
||||||
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_internal);
|
MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_internal);
|
||||||
|
|
||||||
|
/* Number of threads allowed in opal_progress. This might increase multithreaded performance. */
|
||||||
|
(void)mca_base_var_register ("opal", "opal", NULL, "max_thread_in_progress",
|
||||||
|
"Number of thread allowed in opal_progress. Default: 1",
|
||||||
|
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, OPAL_INFO_LVL_8,
|
||||||
|
MCA_BASE_VAR_SCOPE_READONLY, &opal_max_thread_in_progress);
|
||||||
|
|
||||||
/* The ddt engine has a few parameters */
|
/* The ddt engine has a few parameters */
|
||||||
ret = opal_datatype_register_params();
|
ret = opal_datatype_register_params();
|
||||||
if (OPAL_SUCCESS != ret) {
|
if (OPAL_SUCCESS != ret) {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
static opal_mutex_t wait_sync_lock = OPAL_MUTEX_STATIC_INIT;
|
static opal_mutex_t wait_sync_lock = OPAL_MUTEX_STATIC_INIT;
|
||||||
static ompi_wait_sync_t* wait_sync_list = NULL;
|
static ompi_wait_sync_t* wait_sync_list = NULL;
|
||||||
|
|
||||||
|
static opal_atomic_int32_t num_thread_in_progress = 0;
|
||||||
|
|
||||||
#define WAIT_SYNC_PASS_OWNERSHIP(who) \
|
#define WAIT_SYNC_PASS_OWNERSHIP(who) \
|
||||||
do { \
|
do { \
|
||||||
pthread_mutex_lock( &(who)->lock); \
|
pthread_mutex_lock( &(who)->lock); \
|
||||||
@ -63,7 +65,7 @@ int ompi_sync_wait_mt(ompi_wait_sync_t *sync)
|
|||||||
* - our sync has been triggered.
|
* - our sync has been triggered.
|
||||||
*/
|
*/
|
||||||
check_status:
|
check_status:
|
||||||
if( sync != wait_sync_list ) {
|
if( sync != wait_sync_list && num_thread_in_progress >= opal_max_thread_in_progress) {
|
||||||
pthread_cond_wait(&sync->condition, &sync->lock);
|
pthread_cond_wait(&sync->condition, &sync->lock);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,11 +81,14 @@ int ompi_sync_wait_mt(ompi_wait_sync_t *sync)
|
|||||||
/* either promoted, or spurious wakeup ! */
|
/* either promoted, or spurious wakeup ! */
|
||||||
goto check_status;
|
goto check_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&sync->lock);
|
pthread_mutex_unlock(&sync->lock);
|
||||||
|
|
||||||
|
OPAL_THREAD_ADD_FETCH32(&num_thread_in_progress, 1);
|
||||||
while(sync->count > 0) { /* progress till completion */
|
while(sync->count > 0) { /* progress till completion */
|
||||||
opal_progress(); /* don't progress with the sync lock locked or you'll deadlock */
|
opal_progress(); /* don't progress with the sync lock locked or you'll deadlock */
|
||||||
}
|
}
|
||||||
|
OPAL_THREAD_ADD_FETCH32(&num_thread_in_progress, -1);
|
||||||
|
|
||||||
assert(sync == wait_sync_list);
|
assert(sync == wait_sync_list);
|
||||||
|
|
||||||
i_am_done:
|
i_am_done:
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
BEGIN_C_DECLS
|
BEGIN_C_DECLS
|
||||||
|
|
||||||
|
extern int opal_max_thread_in_progress;
|
||||||
|
|
||||||
typedef struct ompi_wait_sync_t {
|
typedef struct ompi_wait_sync_t {
|
||||||
opal_atomic_int32_t count;
|
opal_atomic_int32_t count;
|
||||||
int32_t status;
|
int32_t status;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user