Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions opal/mca/event/external/event_external_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -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$
*
Expand All @@ -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
*/
Expand All @@ -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
Expand All @@ -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 */
Expand All @@ -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;
}
52 changes: 52 additions & 0 deletions opal/mca/event/external/event_external_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
*/
#include "opal_config.h"
#include "opal/constants.h"
Expand All @@ -12,12 +13,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;
}

Expand Down
3 changes: 2 additions & 1 deletion opal/mca/event/external/external.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (c) 2015 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
*
* $COPYRIGHT$
*
Expand Down Expand Up @@ -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)

Expand Down