Skip to content

Commit 9a0f661

Browse files
authored
Merge pull request #7975 from wckzhang/btlcommonlist
btl/ofi: Use common provider include/exclude list
2 parents a44914c + 9b8f463 commit 9a0f661

File tree

4 files changed

+66
-29
lines changed

4 files changed

+66
-29
lines changed

ompi/mca/mtl/ofi/mtl_ofi_component.c

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -306,26 +306,6 @@ ompi_mtl_ofi_progress_no_inline(void)
306306
return ompi_mtl_ofi_progress();
307307
}
308308

309-
static int
310-
is_in_list(char **list, char *item)
311-
{
312-
int i = 0;
313-
314-
if ((NULL == list) || (NULL == item)) {
315-
return 0;
316-
}
317-
318-
while (NULL != list[i]) {
319-
if (0 == strncasecmp(item, list[i], strlen(list[i]))) {
320-
return 1;
321-
} else {
322-
i++;
323-
}
324-
}
325-
326-
return 0;
327-
}
328-
329309
static struct fi_info*
330310
select_ofi_provider(struct fi_info *providers,
331311
char **include_list, char **exclude_list)
@@ -334,7 +314,7 @@ select_ofi_provider(struct fi_info *providers,
334314

335315
if (NULL != include_list) {
336316
while ((NULL != prov) &&
337-
(!is_in_list(include_list, prov->fabric_attr->prov_name))) {
317+
(!opal_common_ofi_is_in_list(include_list, prov->fabric_attr->prov_name))) {
338318
opal_output_verbose(1, opal_common_ofi.output,
339319
"%s:%d: mtl:ofi: \"%s\" not in include list\n",
340320
__FILE__, __LINE__,
@@ -343,7 +323,7 @@ select_ofi_provider(struct fi_info *providers,
343323
}
344324
} else if (NULL != exclude_list) {
345325
while ((NULL != prov) &&
346-
(is_in_list(exclude_list, prov->fabric_attr->prov_name))) {
326+
(opal_common_ofi_is_in_list(exclude_list, prov->fabric_attr->prov_name))) {
347327
opal_output_verbose(1, opal_common_ofi.output,
348328
"%s:%d: mtl:ofi: \"%s\" in exclude list\n",
349329
__FILE__, __LINE__,
@@ -733,8 +713,8 @@ ompi_mtl_ofi_component_init(bool enable_progress_threads,
733713
* this logic if the user specifies an include list without EFA or adds EFA
734714
* to the exclude list.
735715
*/
736-
if ((include_list && is_in_list(include_list, "efa")) ||
737-
(exclude_list && !is_in_list(exclude_list, "efa"))) {
716+
if ((include_list && opal_common_ofi_is_in_list(include_list, "efa")) ||
717+
(exclude_list && !opal_common_ofi_is_in_list(exclude_list, "efa"))) {
738718
hints_dup = fi_dupinfo(hints);
739719
hints_dup->caps &= ~(FI_LOCAL_COMM | FI_REMOTE_COMM);
740720
hints_dup->fabric_attr->prov_name = strdup("efa");

opal/mca/btl/ofi/btl_ofi_component.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,25 @@ static int mca_btl_ofi_init_device(struct fi_info *info);
5353

5454
/* validate information returned from fi_getinfo().
5555
* return OPAL_ERROR if we dont have what we need. */
56-
static int validate_info(struct fi_info *info, uint64_t required_caps)
56+
static int validate_info(struct fi_info *info, uint64_t required_caps,
57+
char **include_list, char **exclude_list)
5758
{
5859
int mr_mode;
5960

61+
if (NULL != include_list && !opal_common_ofi_is_in_list(include_list, info->fabric_attr->prov_name)) {
62+
opal_output_verbose(1, opal_common_ofi.output,
63+
"%s:%d: btl:ofi: \"%s\" not in include list\n",
64+
__FILE__, __LINE__,
65+
info->fabric_attr->prov_name);
66+
return OPAL_ERROR;
67+
} else if (NULL != exclude_list && opal_common_ofi_is_in_list(exclude_list, info->fabric_attr->prov_name)) {
68+
opal_output_verbose(1, opal_common_ofi.output,
69+
"%s:%d: btl:ofi: \"%s\" in exclude list\n",
70+
__FILE__, __LINE__,
71+
info->fabric_attr->prov_name);
72+
return OPAL_ERROR;
73+
}
74+
6075
BTL_VERBOSE(("validating device: %s", info->domain_attr->name));
6176

6277
/* we need exactly all the required bits */
@@ -219,7 +234,7 @@ static mca_btl_base_module_t **mca_btl_ofi_component_init (int *num_btl_modules,
219234
uint64_t progress_mode;
220235
unsigned resource_count = 0;
221236
struct mca_btl_base_module_t **base_modules;
222-
char **include_list = NULL;
237+
char **include_list = NULL, **exclude_list = NULL;
223238

224239
BTL_VERBOSE(("initializing ofi btl"));
225240

@@ -264,10 +279,18 @@ static mca_btl_base_module_t **mca_btl_ofi_component_init (int *num_btl_modules,
264279
}
265280

266281
fabric_attr.prov_name = NULL;
267-
/* Select the provider - sort of. we just take first element in list for now */
282+
283+
opal_output_verbose(1, opal_common_ofi.output,
284+
"%s:%d: btl:ofi:provider_include = \"%s\"\n",
285+
__FILE__, __LINE__, *opal_common_ofi.prov_include);
286+
opal_output_verbose(1, opal_common_ofi.output,
287+
"%s:%d: btl:ofi:provider_exclude = \"%s\"\n",
288+
__FILE__, __LINE__, *opal_common_ofi.prov_exclude);
289+
268290
if (NULL != *opal_common_ofi.prov_include) {
269291
include_list = opal_argv_split(*opal_common_ofi.prov_include, ',');
270-
fabric_attr.prov_name = include_list[0];
292+
} else if (NULL != *opal_common_ofi.prov_exclude) {
293+
exclude_list = opal_argv_split(*opal_common_ofi.prov_exclude, ',');
271294
}
272295

273296
domain_attr.mr_mode = MCA_BTL_OFI_REQUESTED_MR_MODE;
@@ -331,7 +354,7 @@ static mca_btl_base_module_t **mca_btl_ofi_component_init (int *num_btl_modules,
331354
info = info_list;
332355

333356
while(info) {
334-
rc = validate_info(info, required_caps);
357+
rc = validate_info(info, required_caps, include_list, exclude_list);
335358
if (OPAL_SUCCESS == rc) {
336359
/* Device passed sanity check, let's make a module.
337360
*

opal/mca/common/ofi/common_ofi.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ OPAL_DECLSPEC opal_common_ofi_module_t opal_common_ofi = {
3333

3434
static const char default_prov_exclude_list[] = "shm,sockets,tcp,udp,rstream";
3535

36+
OPAL_DECLSPEC int opal_common_ofi_is_in_list(char **list, char *item)
37+
{
38+
int i = 0;
39+
40+
if ((NULL == list) || (NULL == item)) {
41+
return 0;
42+
}
43+
44+
while (NULL != list[i]) {
45+
if (0 == strncasecmp(item, list[i], strlen(list[i]))) {
46+
return 1;
47+
} else {
48+
i++;
49+
}
50+
}
51+
52+
return 0;
53+
}
54+
3655
OPAL_DECLSPEC int opal_common_ofi_register_mca_variables(const mca_base_component_t *component)
3756
{
3857
static int registered = 0;

opal/mca/common/ofi/common_ofi.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ OPAL_DECLSPEC void opal_common_ofi_mca_register(void);
3838
OPAL_DECLSPEC void opal_common_ofi_mca_deregister(void);
3939
OPAL_DECLSPEC struct fi_info* opal_common_ofi_select_ofi_provider(struct fi_info *providers,
4040
char *framework_name);
41+
/*
42+
* @param list (IN) List of strings corresponding to lower providers.
43+
* @param item (IN) Single string corresponding to a provider.
44+
*
45+
* @return 0 The lower provider of the item string is not in
46+
* list or an input was NULL
47+
* @return 1 The lower provider of the item string matches
48+
* a string in the item list.
49+
*
50+
* This function will take a provider name string and a list of lower
51+
* provider name strings as inputs. It will return true if the lower
52+
* provider in the item string matches a lower provider in the list.
53+
*
54+
*/
55+
OPAL_DECLSPEC int opal_common_ofi_is_in_list(char **list, char *item);
4156

4257
END_C_DECLS
4358

0 commit comments

Comments
 (0)