1
1

Merge pull request #2807 from jjhursey/fix/ibm/event-external

libevent/external: Add opal_event_include to this component
Этот коммит содержится в:
Josh Hursey 2017-01-26 14:26:50 -06:00 коммит произвёл GitHub
родитель ebc90f926e d6b306d716
Коммит 770c41f493
3 изменённых файлов: 106 добавлений и 1 удалений

Просмотреть файл

@ -3,6 +3,7 @@
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
*
* $COPYRIGHT$
*
@ -16,6 +17,10 @@
#include "opal/mca/event/event.h"
#include "event.h"
#include "opal/util/argv.h"
/*
* Public string showing the sysinfo ompi_linux component version number
*/
@ -27,7 +32,9 @@ const char *opal_event_external_component_version_string =
* Local function
*/
static int event_external_open(void);
static int event_external_register (void);
char *event_module_include = NULL;
/*
* Instantiate the public struct with all of our public information
@ -49,6 +56,7 @@ const opal_event_component_t mca_event_external_component = {
/* Component open and close functions */
.mca_open_component = event_external_open,
.mca_register_component_params = event_external_register
},
.base_data = {
/* The component is checkpoint ready */
@ -62,3 +70,47 @@ static int event_external_open(void)
eliminate the whole file */
return OPAL_SUCCESS;
}
static int event_external_register (void) {
const char **all_available_eventops;
char *avail = NULL;
char *help_msg = NULL;
int ret;
// Get supported methods
all_available_eventops = event_get_supported_methods();
#ifdef __APPLE__
event_module_include ="select";
#else
event_module_include = "poll";
#endif
avail = opal_argv_join(all_available_eventops, ',');
asprintf( &help_msg,
"Comma-delimited list of libevent subsystems "
"to use (%s -- available on your platform)",
avail );
ret = mca_base_component_var_register (&mca_event_external_component.base_version,
"event_include", help_msg,
MCA_BASE_VAR_TYPE_STRING, NULL, 0,
MCA_BASE_VAR_FLAG_SETTABLE,
OPAL_INFO_LVL_3,
MCA_BASE_VAR_SCOPE_LOCAL,
&event_module_include);
free(help_msg); /* release the help message */
free(avail);
avail = NULL;
if (0 > ret) {
return ret;
}
ret = mca_base_var_register_synonym (ret, "opal", "opal", "event", "include", 0);
if (0 > ret) {
return ret;
}
return OPAL_SUCCESS;
}

Просмотреть файл

@ -6,6 +6,7 @@
* All rights reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
*/
#include "opal_config.h"
#include "opal/constants.h"
@ -14,12 +15,63 @@
#include "opal/mca/event/base/base.h"
#include "external.h"
#include "opal/util/argv.h"
extern char *event_module_include;
static struct event_config *config = NULL;
opal_event_base_t* opal_event_base_create(void)
{
opal_event_base_t *base;
base = event_base_new_with_config(config);
if (NULL == base) {
/* there is no backend method that does what we want */
opal_output(0, "No event method available");
}
return base;
}
int opal_event_init(void)
{
const char **all_available_eventops = NULL;
char **includes=NULL;
bool dumpit=false;
int i, j;
if (opal_output_get_verbosity(opal_event_base_framework.framework_output) > 4) {
event_enable_debug_mode();
}
all_available_eventops = event_get_supported_methods();
if (NULL == event_module_include) {
/* Shouldn't happen, but... */
event_module_include = strdup("select");
}
includes = opal_argv_split(event_module_include,',');
/* get a configuration object */
config = event_config_new();
/* cycle thru the available subsystems */
for (i = 0 ; NULL != all_available_eventops[i] ; ++i) {
/* if this module isn't included in the given ones,
* then exclude it
*/
dumpit = true;
for (j=0; NULL != includes[j]; j++) {
if (0 == strcmp("all", includes[j]) ||
0 == strcmp(all_available_eventops[i], includes[j])) {
dumpit = false;
break;
}
}
if (dumpit) {
event_config_avoid_method(config, all_available_eventops[i]);
}
}
opal_argv_free(includes);
return OPAL_SUCCESS;
}

3
opal/mca/event/external/external.h поставляемый
Просмотреть файл

@ -4,6 +4,7 @@
* Copyright (c) 2015 Intel, Inc. All rights reserved.
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
*
* $COPYRIGHT$
*
@ -45,7 +46,7 @@ OPAL_DECLSPEC extern opal_event_base_t *opal_sync_event_base;
#define OPAL_EVLOOP_NONBLOCK EVLOOP_NONBLOCK /**< Do not block. */
/* Global function to create and release an event base */
#define opal_event_base_create() event_base_new()
OPAL_DECLSPEC opal_event_base_t* opal_event_base_create(void);
#define opal_event_base_free(x) event_base_free(x)