Skip to content

Commit 806b351

Browse files
authored
Merge pull request #7261 from bosilca/fix/vprotocol
Fix/vprotocol initialization
2 parents c79c950 + 7fac7a0 commit 806b351

File tree

3 files changed

+51
-18
lines changed

3 files changed

+51
-18
lines changed

ompi/mca/pml/base/pml_base_frame.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,19 @@ static int mca_pml_base_open(mca_base_open_flag_t flags)
218218
opal_pointer_array_add(&mca_pml_base_pml, strdup("ucx"));
219219
opal_pointer_array_add(&mca_pml_base_pml, strdup("cm"));
220220
} else {
221+
#if OPAL_ENABLE_DEBUG
222+
char **req_pml = opal_argv_split(default_pml[0], ',');
223+
if( NULL != req_pml[1] ) {
224+
opal_output(0, "Only one PML must be provided. Using %s PML (the"
225+
" first on the MCA pml list)", req_pml[0]);
226+
opal_pointer_array_add(&mca_pml_base_pml, strdup(req_pml[0]));
227+
} else {
228+
opal_pointer_array_add(&mca_pml_base_pml, strdup(default_pml[0]));
229+
}
230+
opal_argv_free(req_pml);
231+
#else
221232
opal_pointer_array_add(&mca_pml_base_pml, strdup(default_pml[0]));
233+
#endif /* OPAL_ENABLE_DEBUG */
222234
}
223235
}
224236
#if OPAL_ENABLE_FT_CR == 1

ompi/mca/pml/v/pml_v_component.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "ompi/mca/vprotocol/base/base.h"
2929
#include "pml_v_output.h"
3030
#include "pml_v.h"
31+
#include "ompi/runtime/mpiruntime.h"
3132

3233
static int mca_pml_v_component_register(void);
3334
static int mca_pml_v_component_open(void);
@@ -61,9 +62,6 @@ mca_pml_base_component_2_0_0_t mca_pml_v_component =
6162
.pmlm_finalize = mca_pml_v_component_finalize,
6263
};
6364

64-
static bool pml_v_enable_progress_treads = OPAL_ENABLE_PROGRESS_THREADS;
65-
static bool pml_v_enable_mpi_thread_multiple = 1;
66-
6765
static char *ompi_pml_vprotocol_include_list;
6866
static char *ompi_pml_v_output;
6967
static int ompi_pml_v_verbose;
@@ -205,17 +203,19 @@ static int mca_pml_v_component_parasite_close(void)
205203

206204

207205
/*******************************************************************************
208-
* Init/finalize for MCA PML components
206+
* The init function for the V PML is never supposed to be called, as the mechanism
207+
* that enables the PML V to work require a real PML to move data across. Thus, a
208+
* normal PML should be selected (so the PML V cannot be in the MCA list of PMLs)
209+
* and if the PML V is enabled (via the activation of a vprotocol) it will insert
210+
* itself before the selected PML (assuming no DIRECT_call PML).
209211
*/
210-
static mca_pml_base_module_t *mca_pml_v_component_init(int *priority,
211-
bool enable_progress_threads,
212-
bool enable_mpi_thread_multiple)
212+
static mca_pml_base_module_t*
213+
mca_pml_v_component_init(int *priority,
214+
bool enable_progress_threads,
215+
bool enable_mpi_thread_multiple)
213216
{
214217
V_OUTPUT_VERBOSE(1, "init: I'm not supposed to be here until BTL loading stuff gets fixed!? That's strange...");
215218

216-
pml_v_enable_progress_treads = enable_progress_threads;
217-
pml_v_enable_mpi_thread_multiple = enable_mpi_thread_multiple;
218-
219219
/* I NEVER want to be the selected PML, so I report less than possible
220220
* priority and a NULL module
221221
*/
@@ -249,8 +249,8 @@ static int mca_pml_v_enable(bool enable)
249249
if(enable) {
250250
/* Check if a protocol have been selected during init */
251251
if(! mca_vprotocol_base_selected())
252-
mca_vprotocol_base_select(pml_v_enable_progress_treads,
253-
pml_v_enable_mpi_thread_multiple);
252+
mca_vprotocol_base_select(OPAL_ENABLE_PROGRESS_THREADS,
253+
ompi_mpi_thread_multiple);
254254

255255
/* Check if we succeeded selecting a protocol */
256256
if(mca_vprotocol_base_selected()) {

ompi/mca/vprotocol/pessimist/vprotocol_pessimist_component.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static int _free_list_inc;
3030
static int _sender_based_size;
3131
static int _event_buffer_size;
3232
static char *_mmap_file_name;
33+
static int ompi_vprotocol_pessimist_allow_thread_multiple;
3334

3435
mca_vprotocol_base_component_2_0_0_t mca_vprotocol_pessimist_component =
3536
{
@@ -94,13 +95,27 @@ static int mca_vprotocol_pessimist_component_register(void)
9495
"sender_based_file", NULL, MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
9596
OPAL_INFO_LVL_9,
9697
MCA_BASE_VAR_SCOPE_READONLY, &_mmap_file_name);
98+
/* Provide an overwrite allowing the PML V to run even if the OMPI library has been
99+
* initialized with full support for THREAD_MULTIPLE.
100+
*/
101+
ompi_vprotocol_pessimist_allow_thread_multiple = 0;
102+
(void) mca_base_component_var_register(&mca_vprotocol_pessimist_component.pmlm_version,
103+
"allow_thread_multiple", "Allow the PML V to work even when the MPI"
104+
" library is initialized with MPI_THREAD_MULTIPLE support. By "
105+
"default the PML V is disabled in such instances, to protect "
106+
"applications that are not send deterministic.",
107+
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
108+
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
109+
&ompi_vprotocol_pessimist_allow_thread_multiple);
110+
111+
97112
return OMPI_SUCCESS;
98113
}
99114

100115
static int mca_vprotocol_pessimist_component_open(void)
101116
{
102117
V_OUTPUT_VERBOSE(500, "vprotocol_pessimist: component_open: read priority %d", _priority);
103-
return OMPI_SUCCESS;
118+
return OMPI_SUCCESS;
104119
}
105120

106121
static int mca_vprotocol_pessimist_component_close(void)
@@ -111,16 +126,22 @@ static int mca_vprotocol_pessimist_component_close(void)
111126

112127
/** VPROTOCOL level functions (same as PML one)
113128
*/
114-
static mca_vprotocol_base_module_t *mca_vprotocol_pessimist_component_init( int* priority,
115-
bool enable_progress_threads,
116-
bool enable_mpi_threads)
129+
static mca_vprotocol_base_module_t*
130+
mca_vprotocol_pessimist_component_init( int* priority,
131+
bool enable_progress_threads,
132+
bool enable_mpi_threads)
117133
{
118134
V_OUTPUT_VERBOSE(500, "vprotocol_pessimist: component_init");
119135
*priority = _priority;
120136

121137
/* sanity check */
122-
if(enable_mpi_threads)
123-
{
138+
if(enable_mpi_threads && !ompi_vprotocol_pessimist_allow_thread_multiple) {
139+
/**
140+
* Prevent the pessimistic protocol from activating if we are in a potentially multithreaded
141+
* applications. The reason is that without tracking the thread initiator of messages it is
142+
* extrmely difficult to provide a global message ordering in threaded-scenarios. Thus, the
143+
* safe approach is to turn off the logger.
144+
*/
124145
opal_output(0, "vprotocol_pessimist: component_init: threads are enabled, and not supported by vprotocol pessimist fault tolerant layer, will not load");
125146
return NULL;
126147
}

0 commit comments

Comments
 (0)