Skip to content

Commit 770c41f

Browse files
authored
Merge pull request #2807 from jjhursey/fix/ibm/event-external
libevent/external: Add opal_event_include to this component
2 parents ebc90f9 + d6b306d commit 770c41f

File tree

3 files changed

+106
-1
lines changed

3 files changed

+106
-1
lines changed

opal/mca/event/external/event_external_component.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
44
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
55
* reserved.
6+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
67
*
78
* $COPYRIGHT$
89
*
@@ -16,6 +17,10 @@
1617

1718
#include "opal/mca/event/event.h"
1819

20+
#include "event.h"
21+
22+
#include "opal/util/argv.h"
23+
1924
/*
2025
* Public string showing the sysinfo ompi_linux component version number
2126
*/
@@ -27,7 +32,9 @@ const char *opal_event_external_component_version_string =
2732
* Local function
2833
*/
2934
static int event_external_open(void);
35+
static int event_external_register (void);
3036

37+
char *event_module_include = NULL;
3138

3239
/*
3340
* Instantiate the public struct with all of our public information
@@ -49,6 +56,7 @@ const opal_event_component_t mca_event_external_component = {
4956

5057
/* Component open and close functions */
5158
.mca_open_component = event_external_open,
59+
.mca_register_component_params = event_external_register
5260
},
5361
.base_data = {
5462
/* The component is checkpoint ready */
@@ -62,3 +70,47 @@ static int event_external_open(void)
6270
eliminate the whole file */
6371
return OPAL_SUCCESS;
6472
}
73+
74+
static int event_external_register (void) {
75+
const char **all_available_eventops;
76+
char *avail = NULL;
77+
char *help_msg = NULL;
78+
int ret;
79+
80+
// Get supported methods
81+
all_available_eventops = event_get_supported_methods();
82+
83+
#ifdef __APPLE__
84+
event_module_include ="select";
85+
#else
86+
event_module_include = "poll";
87+
#endif
88+
89+
avail = opal_argv_join(all_available_eventops, ',');
90+
asprintf( &help_msg,
91+
"Comma-delimited list of libevent subsystems "
92+
"to use (%s -- available on your platform)",
93+
avail );
94+
95+
ret = mca_base_component_var_register (&mca_event_external_component.base_version,
96+
"event_include", help_msg,
97+
MCA_BASE_VAR_TYPE_STRING, NULL, 0,
98+
MCA_BASE_VAR_FLAG_SETTABLE,
99+
OPAL_INFO_LVL_3,
100+
MCA_BASE_VAR_SCOPE_LOCAL,
101+
&event_module_include);
102+
free(help_msg); /* release the help message */
103+
free(avail);
104+
avail = NULL;
105+
106+
if (0 > ret) {
107+
return ret;
108+
}
109+
110+
ret = mca_base_var_register_synonym (ret, "opal", "opal", "event", "include", 0);
111+
if (0 > ret) {
112+
return ret;
113+
}
114+
115+
return OPAL_SUCCESS;
116+
}

opal/mca/event/external/event_external_module.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* All rights reserved.
77
* Copyright (c) 2017 Research Organization for Information Science
88
* and Technology (RIST). All rights reserved.
9+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
910
*/
1011
#include "opal_config.h"
1112
#include "opal/constants.h"
@@ -14,12 +15,63 @@
1415
#include "opal/mca/event/base/base.h"
1516
#include "external.h"
1617

18+
#include "opal/util/argv.h"
19+
20+
extern char *event_module_include;
21+
static struct event_config *config = NULL;
22+
23+
opal_event_base_t* opal_event_base_create(void)
24+
{
25+
opal_event_base_t *base;
26+
27+
base = event_base_new_with_config(config);
28+
if (NULL == base) {
29+
/* there is no backend method that does what we want */
30+
opal_output(0, "No event method available");
31+
}
32+
return base;
33+
}
34+
1735
int opal_event_init(void)
1836
{
37+
const char **all_available_eventops = NULL;
38+
char **includes=NULL;
39+
bool dumpit=false;
40+
int i, j;
41+
1942
if (opal_output_get_verbosity(opal_event_base_framework.framework_output) > 4) {
2043
event_enable_debug_mode();
2144
}
2245

46+
all_available_eventops = event_get_supported_methods();
47+
48+
if (NULL == event_module_include) {
49+
/* Shouldn't happen, but... */
50+
event_module_include = strdup("select");
51+
}
52+
includes = opal_argv_split(event_module_include,',');
53+
54+
/* get a configuration object */
55+
config = event_config_new();
56+
/* cycle thru the available subsystems */
57+
for (i = 0 ; NULL != all_available_eventops[i] ; ++i) {
58+
/* if this module isn't included in the given ones,
59+
* then exclude it
60+
*/
61+
dumpit = true;
62+
for (j=0; NULL != includes[j]; j++) {
63+
if (0 == strcmp("all", includes[j]) ||
64+
0 == strcmp(all_available_eventops[i], includes[j])) {
65+
dumpit = false;
66+
break;
67+
}
68+
}
69+
if (dumpit) {
70+
event_config_avoid_method(config, all_available_eventops[i]);
71+
}
72+
}
73+
opal_argv_free(includes);
74+
2375
return OPAL_SUCCESS;
2476
}
2577

opal/mca/event/external/external.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright (c) 2015 Intel, Inc. All rights reserved.
55
* Copyright (c) 2015-2017 Research Organization for Information Science
66
* and Technology (RIST). All rights reserved.
7+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
78
*
89
* $COPYRIGHT$
910
*
@@ -45,7 +46,7 @@ OPAL_DECLSPEC extern opal_event_base_t *opal_sync_event_base;
4546
#define OPAL_EVLOOP_NONBLOCK EVLOOP_NONBLOCK /**< Do not block. */
4647

4748
/* Global function to create and release an event base */
48-
#define opal_event_base_create() event_base_new()
49+
OPAL_DECLSPEC opal_event_base_t* opal_event_base_create(void);
4950

5051
#define opal_event_base_free(x) event_base_free(x)
5152

0 commit comments

Comments
 (0)