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

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