Blame SOURCES/0001-Revert-ucx-check-supported-transports-and-devices-fo.patch

e855d8
From 63c80c7692e55f634cbca6f67cc5c9cdef3a04d2 Mon Sep 17 00:00:00 2001
e855d8
From: Honggang Li <honli@redhat.com>
e855d8
Date: Mon, 28 Jun 2021 21:38:13 +0800
e855d8
Subject: [PATCH] Revert "ucx: check supported transports and devices for
e855d8
 setting priority"
e855d8
e855d8
This reverts commit c36d7459b6331c4da825cad5a64326e7c1a272aa.
e855d8
---
e855d8
 contrib/platform/mellanox/optimized.conf |   2 -
e855d8
 ompi/mca/pml/ucx/pml_ucx_component.c     |  15 +-
e855d8
 opal/mca/common/ucx/common_ucx.c         | 202 +----------------------
e855d8
 opal/mca/common/ucx/common_ucx.h         |  15 --
e855d8
 opal/mca/common/ucx/configure.m4         |   2 -
e855d8
 5 files changed, 2 insertions(+), 234 deletions(-)
e855d8
e855d8
diff --git a/contrib/platform/mellanox/optimized.conf b/contrib/platform/mellanox/optimized.conf
e855d8
index 543fd8d1e224..b86b37c9e2fa 100644
e855d8
--- a/contrib/platform/mellanox/optimized.conf
e855d8
+++ b/contrib/platform/mellanox/optimized.conf
e855d8
@@ -61,8 +61,6 @@
e855d8
 coll = ^ml
e855d8
 hwloc_base_binding_policy = core
e855d8
 btl = self
e855d8
-pml_ucx_tls = any
e855d8
-pml_ucx_devices = any
e855d8
 # Basic behavior to smooth startup
e855d8
 mca_base_component_show_load_errors = 0
e855d8
 orte_abort_timeout = 10
e855d8
diff --git a/ompi/mca/pml/ucx/pml_ucx_component.c b/ompi/mca/pml/ucx/pml_ucx_component.c
e855d8
index 6aed6c41d11d..ed9cc6573e8e 100644
e855d8
--- a/ompi/mca/pml/ucx/pml_ucx_component.c
e855d8
+++ b/ompi/mca/pml/ucx/pml_ucx_component.c
e855d8
@@ -107,26 +107,13 @@ static mca_pml_base_module_t*
e855d8
 mca_pml_ucx_component_init(int* priority, bool enable_progress_threads,
e855d8
                            bool enable_mpi_threads)
e855d8
 {
e855d8
-    opal_common_ucx_support_level_t support_level;
e855d8
     int ret;
e855d8
 
e855d8
-    support_level = opal_common_ucx_support_level(ompi_pml_ucx.ucp_context);
e855d8
-    if (support_level == OPAL_COMMON_UCX_SUPPORT_NONE) {
e855d8
-        return NULL;
e855d8
-    }
e855d8
-
e855d8
     if ( (ret = mca_pml_ucx_init(enable_mpi_threads)) != 0) {
e855d8
         return NULL;
e855d8
     }
e855d8
 
e855d8
-    /*
e855d8
-     * If found supported devices - set to the configured (high) priority.
e855d8
-     * Otherwise - Found only supported transports (which could be exposed by
e855d8
-     *             unsupported devices), so set a priority lower than ob1.
e855d8
-     */
e855d8
-    *priority = (support_level == OPAL_COMMON_UCX_SUPPORT_DEVICE) ?
e855d8
-                ompi_pml_ucx.priority : 19;
e855d8
-    PML_UCX_VERBOSE(2, "returning priority %d", *priority);
e855d8
+    *priority = ompi_pml_ucx.priority;
e855d8
     return &ompi_pml_ucx.super;
e855d8
 }
e855d8
 
e855d8
diff --git a/opal/mca/common/ucx/common_ucx.c b/opal/mca/common/ucx/common_ucx.c
e855d8
index ac7a17d799a5..ae8e66877ab6 100644
e855d8
--- a/opal/mca/common/ucx/common_ucx.c
e855d8
+++ b/opal/mca/common/ucx/common_ucx.c
e855d8
@@ -14,11 +14,8 @@
e855d8
 #include "opal/mca/base/mca_base_framework.h"
e855d8
 #include "opal/mca/pmix/pmix.h"
e855d8
 #include "opal/memoryhooks/memory.h"
e855d8
-#include "opal/util/argv.h"
e855d8
 
e855d8
 #include <ucm/api/ucm.h>
e855d8
-#include <fnmatch.h>
e855d8
-#include <stdio.h>
e855d8
 
e855d8
 /***********************************************************************/
e855d8
 
e855d8
@@ -28,8 +25,7 @@ opal_common_ucx_module_t opal_common_ucx = {
e855d8
     .verbose             = 0,
e855d8
     .progress_iterations = 100,
e855d8
     .registered          = 0,
e855d8
-    .opal_mem_hooks      = 0,
e855d8
-    .tls                 = NULL
e855d8
+    .opal_mem_hooks      = 0
e855d8
 };
e855d8
 
e855d8
 static void opal_common_ucx_mem_release_cb(void *buf, size_t length,
e855d8
@@ -40,15 +36,10 @@ static void opal_common_ucx_mem_release_cb(void *buf, size_t length,
e855d8
 
e855d8
 OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t *component)
e855d8
 {
e855d8
-    static const char *default_tls     = "rc_verbs,ud_verbs,rc_mlx5,dc_mlx5,cuda_ipc,rocm_ipc";
e855d8
-    static const char *default_devices = "mlx*";
e855d8
     static int registered = 0;
e855d8
     static int hook_index;
e855d8
     static int verbose_index;
e855d8
     static int progress_index;
e855d8
-    static int tls_index;
e855d8
-    static int devices_index;
e855d8
-
e855d8
     if (!registered) {
e855d8
         verbose_index = mca_base_var_register("opal", "opal_common", "ucx", "verbose",
e855d8
                                               "Verbose level of the UCX components",
e855d8
@@ -69,29 +60,6 @@ OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t *
e855d8
                                            OPAL_INFO_LVL_3,
e855d8
                                            MCA_BASE_VAR_SCOPE_LOCAL,
e855d8
                                            &opal_common_ucx.opal_mem_hooks);
e855d8
-
e855d8
-        opal_common_ucx.tls  = malloc(sizeof(*opal_common_ucx.tls));
e855d8
-        *opal_common_ucx.tls = strdup(default_tls);
e855d8
-        tls_index = mca_base_var_register("opal", "opal_common", "ucx", "tls",
e855d8
-                                          "List of UCX transports which should be supported on the system, to enable "
e855d8
-                                          "selecting the UCX component. Special values: any (any available). "
e855d8
-                                          "A '^' prefix negates the list. "
e855d8
-                                          "For example, in order to exclude on shared memory and TCP transports, "
e855d8
-                                          "please set to '^posix,sysv,self,tcp,cma,knem,xpmem'.",
e855d8
-                                          MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
e855d8
-                                          OPAL_INFO_LVL_3,
e855d8
-                                          MCA_BASE_VAR_SCOPE_LOCAL,
e855d8
-                                          opal_common_ucx.tls);
e855d8
-
e855d8
-        opal_common_ucx.devices  = malloc(sizeof(*opal_common_ucx.devices));
e855d8
-        *opal_common_ucx.devices = strdup(default_devices);
e855d8
-        devices_index = mca_base_var_register("opal", "opal_common", "ucx", "devices",
e855d8
-                                              "List of device driver pattern names, which, if supported by UCX, will "
e855d8
-                                              "bump its priority above ob1. Special values: any (any available)",
e855d8
-                                              MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
e855d8
-                                              OPAL_INFO_LVL_3,
e855d8
-                                              MCA_BASE_VAR_SCOPE_LOCAL,
e855d8
-                                              opal_common_ucx.devices);
e855d8
         registered = 1;
e855d8
     }
e855d8
     if (component) {
e855d8
@@ -107,14 +75,6 @@ OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t *
e855d8
                                       component->mca_type_name,
e855d8
                                       component->mca_component_name,
e855d8
                                       "opal_mem_hooks", 0);
e855d8
-        mca_base_var_register_synonym(tls_index, component->mca_project_name,
e855d8
-                                      component->mca_type_name,
e855d8
-                                      component->mca_component_name,
e855d8
-                                      "tls", 0);
e855d8
-        mca_base_var_register_synonym(devices_index, component->mca_project_name,
e855d8
-                                      component->mca_type_name,
e855d8
-                                      component->mca_component_name,
e855d8
-                                      "devices", 0);
e855d8
     }
e855d8
 }
e855d8
 
e855d8
@@ -163,166 +123,6 @@ OPAL_DECLSPEC void opal_common_ucx_mca_deregister(void)
e855d8
     opal_output_close(opal_common_ucx.output);
e855d8
 }
e855d8
 
e855d8
-#if HAVE_DECL_OPEN_MEMSTREAM
e855d8
-static bool opal_common_ucx_check_device(const char *device_name, char **device_list)
e855d8
-{
e855d8
-    char sysfs_driver_link[PATH_MAX];
e855d8
-    char driver_path[PATH_MAX];
e855d8
-    char *ib_device_name;
e855d8
-    char *driver_name;
e855d8
-    char **list_item;
e855d8
-    ssize_t ret;
e855d8
-
e855d8
-    /* mlx5_0:1 */
e855d8
-    ret = sscanf(device_name, "%m[^:]%*d", &ib_device_name);
e855d8
-    if (ret != 1) {
e855d8
-        return false;
e855d8
-    }
e855d8
-
e855d8
-    sysfs_driver_link[sizeof(sysfs_driver_link) - 1] = '\0';
e855d8
-    snprintf(sysfs_driver_link, sizeof(sysfs_driver_link) - 1,
e855d8
-             "/sys/class/infiniband/%s/device/driver", ib_device_name);
e855d8
-    free(ib_device_name);
e855d8
-
e855d8
-    driver_path[sizeof(driver_path) - 1] = '\0';
e855d8
-    ret = readlink(sysfs_driver_link, driver_path, sizeof(driver_path) - 1);
e855d8
-    if (ret < 0) {
e855d8
-        MCA_COMMON_UCX_VERBOSE(2, "readlink(%s) failed: %s", sysfs_driver_link,
e855d8
-                               strerror(errno));
e855d8
-        return false;
e855d8
-    }
e855d8
-
e855d8
-    driver_name = basename(driver_path);
e855d8
-    for (list_item = device_list; *list_item != NULL; ++list_item) {
e855d8
-        if (!fnmatch(*list_item, driver_name, 0)) {
e855d8
-            MCA_COMMON_UCX_VERBOSE(2, "driver '%s' matched by '%s'",
e855d8
-                                   driver_path, *list_item);
e855d8
-            return true;
e855d8
-        }
e855d8
-    }
e855d8
-
e855d8
-    return false;
e855d8
-}
e855d8
-#endif
e855d8
-
e855d8
-OPAL_DECLSPEC opal_common_ucx_support_level_t
e855d8
-opal_common_ucx_support_level(ucp_context_h context)
e855d8
-{
e855d8
-    opal_common_ucx_support_level_t support_level = OPAL_COMMON_UCX_SUPPORT_NONE;
e855d8
-    static const char *support_level_names[] = {
e855d8
-        [OPAL_COMMON_UCX_SUPPORT_NONE]      = "none",
e855d8
-        [OPAL_COMMON_UCX_SUPPORT_TRANSPORT] = "transports only",
e855d8
-        [OPAL_COMMON_UCX_SUPPORT_DEVICE]    = "transports and devices"
e855d8
-    };
e855d8
-#if HAVE_DECL_OPEN_MEMSTREAM
e855d8
-    char *rsc_tl_name, *rsc_device_name;
e855d8
-    char **tl_list, **device_list, **list_item;
e855d8
-    bool is_any_tl, is_any_device;
e855d8
-    bool found_tl, negate;
e855d8
-    char line[128];
e855d8
-    FILE *stream;
e855d8
-    char *buffer;
e855d8
-    size_t size;
e855d8
-    int ret;
e855d8
-#endif
e855d8
-
e855d8
-    is_any_tl     = !strcmp(*opal_common_ucx.tls, "any");
e855d8
-    is_any_device = !strcmp(*opal_common_ucx.devices, "any");
e855d8
-
e855d8
-    /* Check for special value "any" */
e855d8
-    if (is_any_tl && is_any_device) {
e855d8
-        MCA_COMMON_UCX_VERBOSE(1, "ucx is enabled on any transport or device",
e855d8
-                               *opal_common_ucx.tls);
e855d8
-        support_level = OPAL_COMMON_UCX_SUPPORT_DEVICE;
e855d8
-        goto out;
e855d8
-    }
e855d8
-
e855d8
-#if HAVE_DECL_OPEN_MEMSTREAM
e855d8
-    /* Split transports list */
e855d8
-    negate  = ('^' == (*opal_common_ucx.tls)[0]);
e855d8
-    tl_list = opal_argv_split(*opal_common_ucx.tls + (negate ? 1 : 0), ',');
e855d8
-    if (tl_list == NULL) {
e855d8
-        MCA_COMMON_UCX_VERBOSE(1, "failed to split tl list '%s', ucx is disabled",
e855d8
-                               *opal_common_ucx.tls);
e855d8
-        goto out;
e855d8
-    }
e855d8
-
e855d8
-    /* Split devices list */
e855d8
-    device_list = opal_argv_split(*opal_common_ucx.devices, ',');
e855d8
-    if (device_list == NULL) {
e855d8
-        MCA_COMMON_UCX_VERBOSE(1, "failed to split devices list '%s', ucx is disabled",
e855d8
-                               *opal_common_ucx.devices);
e855d8
-        goto out_free_tl_list;
e855d8
-    }
e855d8
-
e855d8
-    /* Open memory stream to dump UCX information to */
e855d8
-    stream = open_memstream(&buffer, &size);
e855d8
-    if (stream == NULL) {
e855d8
-        MCA_COMMON_UCX_VERBOSE(1, "failed to open memory stream for ucx info (%s), "
e855d8
-                               "ucx is disabled", strerror(errno));
e855d8
-        goto out_free_device_list;
e855d8
-    }
e855d8
-
e855d8
-    /* Print ucx transports information to the memory stream */
e855d8
-    ucp_context_print_info(context, stream);
e855d8
-
e855d8
-    /* Rewind and read transports/devices list from the stream */
e855d8
-    fseek(stream, 0, SEEK_SET);
e855d8
-    while ((support_level != OPAL_COMMON_UCX_SUPPORT_DEVICE) &&
e855d8
-           (fgets(line, sizeof(line), stream) != NULL)) {
e855d8
-        rsc_tl_name = NULL;
e855d8
-        ret = sscanf(line,
e855d8
-                     /* "# resource 6  :  md 5  dev 4  flags -- rc_verbs/mlx5_0:1" */
e855d8
-                     "# resource %*d : md %*d dev %*d flags -- %m[^/ \n\r]/%m[^/ \n\r]",
e855d8
-                     &rsc_tl_name, &rsc_device_name);
e855d8
-        if (ret != 2) {
e855d8
-            free(rsc_tl_name);
e855d8
-            continue;
e855d8
-        }
e855d8
-
e855d8
-        /* Check if 'rsc_tl_name' is found  provided list */
e855d8
-        found_tl = is_any_tl;
e855d8
-        for (list_item = tl_list; !found_tl && (*list_item != NULL); ++list_item) {
e855d8
-            found_tl = !strcmp(*list_item, rsc_tl_name);
e855d8
-        }
e855d8
-
e855d8
-        /* Check if the transport has a match (either positive or negative) */
e855d8
-        assert(!(is_any_tl && negate));
e855d8
-        if (found_tl != negate) {
e855d8
-            if (is_any_device ||
e855d8
-                opal_common_ucx_check_device(rsc_device_name, device_list)) {
e855d8
-                MCA_COMMON_UCX_VERBOSE(2, "%s/%s: matched both transport and device list",
e855d8
-                                    rsc_tl_name, rsc_device_name);
e855d8
-                support_level = OPAL_COMMON_UCX_SUPPORT_DEVICE;
e855d8
-            } else {
e855d8
-                MCA_COMMON_UCX_VERBOSE(2, "%s/%s: matched transport list but not device list",
e855d8
-                                    rsc_tl_name, rsc_device_name);
e855d8
-                support_level = OPAL_COMMON_UCX_SUPPORT_TRANSPORT;
e855d8
-            }
e855d8
-        } else {
e855d8
-            MCA_COMMON_UCX_VERBOSE(2, "%s/%s: did not match transport list",
e855d8
-                                   rsc_tl_name, rsc_device_name);
e855d8
-        }
e855d8
-
e855d8
-        free(rsc_device_name);
e855d8
-        free(rsc_tl_name);
e855d8
-    }
e855d8
-
e855d8
-    MCA_COMMON_UCX_VERBOSE(2, "support level is %s", support_level_names[support_level]);
e855d8
-    fclose(stream);
e855d8
-    free(buffer);
e855d8
-
e855d8
-out_free_device_list:
e855d8
-    opal_argv_free(device_list);
e855d8
-out_free_tl_list:
e855d8
-    opal_argv_free(tl_list);
e855d8
-out:
e855d8
-#else
e855d8
-    MCA_COMMON_UCX_VERBOSE(2, "open_memstream() was not found, ucx is disabled");
e855d8
-#endif
e855d8
-    return support_level;
e855d8
-}
e855d8
-
e855d8
 void opal_common_ucx_empty_complete_cb(void *request, ucs_status_t status)
e855d8
 {
e855d8
 }
e855d8
diff --git a/opal/mca/common/ucx/common_ucx.h b/opal/mca/common/ucx/common_ucx.h
e855d8
index 92cdd738ef98..202131ac8907 100644
e855d8
--- a/opal/mca/common/ucx/common_ucx.h
e855d8
+++ b/opal/mca/common/ucx/common_ucx.h
e855d8
@@ -88,8 +88,6 @@ typedef struct opal_common_ucx_module {
e855d8
     int  progress_iterations;
e855d8
     int  registered;
e855d8
     bool opal_mem_hooks;
e855d8
-    char **tls;
e855d8
-    char **devices;
e855d8
 } opal_common_ucx_module_t;
e855d8
 
e855d8
 typedef struct opal_common_ucx_del_proc {
e855d8
@@ -97,23 +95,10 @@ typedef struct opal_common_ucx_del_proc {
e855d8
     size_t   vpid;
e855d8
 } opal_common_ucx_del_proc_t;
e855d8
 
e855d8
-typedef enum {
e855d8
-    /* No supported transports found (according to configured list of supported
e855d8
-       transports) */
e855d8
-    OPAL_COMMON_UCX_SUPPORT_NONE,
e855d8
-
e855d8
-    /* Have supported transports but not supported devices */
e855d8
-    OPAL_COMMON_UCX_SUPPORT_TRANSPORT,
e855d8
-
e855d8
-    /* Have both supported transports and supported devices */
e855d8
-    OPAL_COMMON_UCX_SUPPORT_DEVICE,
e855d8
-} opal_common_ucx_support_level_t;
e855d8
-
e855d8
 extern opal_common_ucx_module_t opal_common_ucx;
e855d8
 
e855d8
 OPAL_DECLSPEC void opal_common_ucx_mca_register(void);
e855d8
 OPAL_DECLSPEC void opal_common_ucx_mca_deregister(void);
e855d8
-OPAL_DECLSPEC opal_common_ucx_support_level_t opal_common_ucx_support_level(ucp_context_h context);
e855d8
 OPAL_DECLSPEC void opal_common_ucx_mca_proc_added(void);
e855d8
 OPAL_DECLSPEC void opal_common_ucx_empty_complete_cb(void *request, ucs_status_t status);
e855d8
 OPAL_DECLSPEC int opal_common_ucx_mca_pmix_fence(ucp_worker_h worker);
e855d8
diff --git a/opal/mca/common/ucx/configure.m4 b/opal/mca/common/ucx/configure.m4
e855d8
index af8628a889c6..27e07c2005b2 100644
e855d8
--- a/opal/mca/common/ucx/configure.m4
e855d8
+++ b/opal/mca/common/ucx/configure.m4
e855d8
@@ -18,8 +18,6 @@ AC_DEFUN([MCA_opal_common_ucx_CONFIG],[
e855d8
                [common_ucx_happy="yes"],
e855d8
                [common_ucx_happy="no"])
e855d8
 
e855d8
-    AC_CHECK_DECLS([open_memstream], [], [], [[#include <stdio.h>]])
e855d8
-
e855d8
     AS_IF([test "$common_ucx_happy" = "yes"],
e855d8
           [$1],
e855d8
           [$2])
e855d8
-- 
e855d8
2.31.1
e855d8