root/opal/mca/event/libevent2022/libevent2022_component.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. libevent2022_register
  2. libevent2022_open

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2010      Cisco Systems, Inc.  All rights reserved.
   4  * Copyright (c) 2012-2015 Los Alamos National Security, LLC.  All rights reserved.
   5  * Copyright (c) 2015      Intel, Inc. All rights reserved.
   6  *
   7  * Copyright (c) 2017      IBM Corporation. All rights reserved.
   8  * Copyright (c) 2018      Amazon.com, Inc. or its affiliates.  All Rights reserved.
   9  * $COPYRIGHT$
  10  *
  11  * Additional copyrights may follow
  12  *
  13  * $HEADER$
  14  *
  15  * These symbols are in a file by themselves to provide nice linker
  16  * semantics.  Since linkers generally pull in symbols by object
  17  * files, keeping these symbols as the only symbols in this file
  18  * prevents utility programs such as "ompi_info" from having to import
  19  * entire components just to query their version and parameters.
  20  */
  21 
  22 #include "opal_config.h"
  23 #include "opal/constants.h"
  24 #include "opal/util/printf.h"
  25 
  26 #include "opal/mca/event/event.h"
  27 #include "libevent2022.h"
  28 
  29 #include "libevent/event.h"
  30 #include "libevent/event-internal.h"
  31 
  32 /*
  33  * Public string showing the sysinfo ompi_linux component version number
  34  */
  35 const char *opal_event_libevent2022_component_version_string =
  36     "OPAL libevent2022 event MCA component version " OPAL_VERSION;
  37 
  38 /*
  39  * MCA variables
  40  */
  41 char *ompi_event_module_include = NULL;
  42 
  43 /* copied from event.c */
  44 #if defined(_EVENT_HAVE_EVENT_PORTS) && _EVENT_HAVE_EVENT_PORTS
  45 extern const struct eventop evportops;
  46 #endif
  47 #if defined(_EVENT_HAVE_SELECT) && _EVENT_HAVE_SELECT
  48 extern const struct eventop selectops;
  49 #endif
  50 #if defined(_EVENT_HAVE_POLL) && _EVENT_HAVE_POLL
  51 extern const struct eventop pollops;
  52 #endif
  53 #if defined(_EVENT_HAVE_EPOLL) && _EVENT_HAVE_EPOLL
  54 extern const struct eventop epollops;
  55 #endif
  56 #if defined(_EVENT_HAVE_WORKING_KQUEUE) && _EVENT_HAVE_WORKING_KQUEUE
  57 extern const struct eventop kqops;
  58 #endif
  59 #if defined(_EVENT_HAVE_DEVPOLL) && _EVENT_HAVE_DEVPOLL
  60 extern const struct eventop devpollops;
  61 #endif
  62 #ifdef WIN32
  63 extern const struct eventop win32ops;
  64 #endif
  65 
  66 /* Array of backends in order of preference. */
  67 const struct eventop *ompi_eventops[] = {
  68 #if defined(_EVENT_HAVE_EVENT_PORTS) && _EVENT_HAVE_EVENT_PORTS
  69         &evportops,
  70 #endif
  71 #if defined(_EVENT_HAVE_WORKING_KQUEUE) && _EVENT_HAVE_WORKING_KQUEUE
  72         &kqops,
  73 #endif
  74 #if defined(_EVENT_HAVE_EPOLL) && _EVENT_HAVE_EPOLL
  75         &epollops,
  76 #endif
  77 #if defined(_EVENT_HAVE_DEVPOLL) && _EVENT_HAVE_DEVPOLL
  78         &devpollops,
  79 #endif
  80 #if defined(_EVENT_HAVE_POLL) && _EVENT_HAVE_POLL
  81         &pollops,
  82 #endif
  83 #if defined(_EVENT_HAVE_SELECT) && _EVENT_HAVE_SELECT
  84         &selectops,
  85 #endif
  86 #ifdef WIN32
  87         &win32ops,
  88 #endif
  89         NULL
  90 };
  91 
  92 /*
  93  * Local functions
  94  */
  95 static int libevent2022_register (void);
  96 static int libevent2022_open(void);
  97 
  98 /*
  99  * Instantiate the public struct with all of our public information
 100  * and pointers to our public functions in it
 101  */
 102 
 103 const opal_event_component_t mca_event_libevent2022_component = {
 104 
 105     /* First, the mca_component_t struct containing meta information
 106        about the component itself */
 107 
 108     .base_version = {
 109         OPAL_EVENT_BASE_VERSION_2_0_0,
 110 
 111         /* Component name and version */
 112         .mca_component_name = "libevent2022",
 113         MCA_BASE_MAKE_VERSION(component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION,
 114                               OPAL_RELEASE_VERSION),
 115 
 116         /* Component functions */
 117         .mca_open_component = libevent2022_open,
 118         .mca_register_component_params = libevent2022_register
 119     },
 120     .base_data = {
 121         /* The component is checkpoint ready */
 122         MCA_BASE_METADATA_PARAM_CHECKPOINT
 123     }
 124 };
 125 
 126 static int libevent2022_register (void)
 127 {
 128     const struct eventop** _eventop = ompi_eventops;
 129     char available_eventops[BUFSIZ] = "none";
 130     char *help_msg = NULL;
 131     int ret;
 132 
 133     /* Retrieve the upper level specified event system, if any.
 134      * Default to select() on OS X and poll() everywhere else because
 135      * various parts of OMPI / ORTE use libevent with pty's.  pty's
 136      * *only* work with select on OS X (tested on Tiger and Leopard);
 137      * we *know* that both select and poll works with pty's everywhere
 138      * else we care about (other mechansisms such as epoll *may* work
 139      * with pty's -- we have not tested comprehensively with newer
 140      * versions of Linux, etc.).  So the safe thing to do is:
 141      *
 142      * - On OS X, default to using "select" only
 143      * - Everywhere else, default to using "poll" only (because poll
 144      *   is more scalable than select)
 145      *
 146      * An upper layer may override this setting if it knows that pty's
 147      * won't be used with libevent.  For example, we currently have
 148      * ompi_mpi_init() set to use "all" (to include epoll and friends)
 149      * so that the TCP BTL can be a bit more scalable -- because we
 150      * *know* that MPI apps don't use pty's with libevent.
 151      * Note that other tools explicitly *do* use pty's with libevent:
 152      *
 153      * - orted
 154      * - orterun (probably only if it launches locally)
 155      * - ...?
 156      */
 157 
 158     if (NULL != (*_eventop)) {
 159         const int len = sizeof (available_eventops);
 160         int cur_len = snprintf (available_eventops, len, "%s", (*(_eventop++))->name);
 161 
 162         for (int i = 1 ; ompi_eventops[i] && cur_len < len ; ++i) {
 163             cur_len += snprintf (available_eventops + cur_len, len - cur_len, ", %s",
 164                                  ompi_eventops[i]->name);
 165         }
 166         /* ensure the available_eventops string is always NULL-terminated  */
 167         available_eventops[len - 1] = '\0';
 168     }
 169 
 170 #ifdef __APPLE__
 171     ompi_event_module_include ="select";
 172 #else
 173     ompi_event_module_include = "poll";
 174 #endif
 175 
 176     opal_asprintf( &help_msg,
 177               "Comma-delimited list of libevent subsystems "
 178               "to use (%s -- available on your platform)",
 179               available_eventops );
 180 
 181     ret = mca_base_component_var_register (&mca_event_libevent2022_component.base_version,
 182                                            "event_include", help_msg,
 183                                            MCA_BASE_VAR_TYPE_STRING, NULL, 0,
 184                                            MCA_BASE_VAR_FLAG_SETTABLE,
 185                                            OPAL_INFO_LVL_3,
 186                                            MCA_BASE_VAR_SCOPE_LOCAL,
 187                                            &ompi_event_module_include);
 188     free(help_msg);  /* release the help message */
 189 
 190     if (0 > ret) {
 191         return ret;
 192     }
 193 
 194     ret = mca_base_var_register_synonym (ret, "opal", "opal", "event", "include", 0);
 195     if (0 > ret) {
 196         return ret;
 197     }
 198 
 199     return OPAL_SUCCESS;
 200 }
 201 
 202 static int libevent2022_open(void)
 203 {
 204     return OPAL_SUCCESS;
 205 }

/* [<][>][^][v][top][bottom][index][help] */