Skip to content

Commit 007b4ff

Browse files
author
Scott Miller
committed
v4.0.x: regx/none: add regx/none component
Signed-off-by: Scott Miller <scott.miller1@ibm.com>
1 parent d3587f5 commit 007b4ff

File tree

5 files changed

+291
-0
lines changed

5 files changed

+291
-0
lines changed

orte/mca/regx/none/Makefile.am

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Copyright (c) 2016-2018 Intel, Inc. All rights reserved.
3+
# Copyright (c) 2019 IBM Corporation. All rights reserved.
4+
# $COPYRIGHT$
5+
#
6+
# Additional copyrights may follow
7+
#
8+
# $HEADER$
9+
#
10+
11+
sources = \
12+
regx_none_component.c \
13+
regx_none.h \
14+
regx_none.c
15+
16+
# Make the output library in this directory, and name it either
17+
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
18+
# (for static builds).
19+
20+
if MCA_BUILD_orte_regx_none_DSO
21+
component_noinst =
22+
component_install = mca_regx_none.la
23+
else
24+
component_noinst = libmca_regx_none.la
25+
component_install =
26+
endif
27+
28+
mcacomponentdir = $(ortelibdir)
29+
mcacomponent_LTLIBRARIES = $(component_install)
30+
mca_regx_none_la_SOURCES = $(sources)
31+
mca_regx_none_la_LDFLAGS = -module -avoid-version
32+
mca_regx_none_la_LIBADD = $(top_builddir)/orte/lib@ORTE_LIB_PREFIX@open-rte.la
33+
34+
noinst_LTLIBRARIES = $(component_noinst)
35+
libmca_regx_none_la_SOURCES = $(sources)
36+
libmca_regx_none_la_LDFLAGS = -module -avoid-version

orte/mca/regx/none/owner.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# owner/status file
3+
# owner: institution that is responsible for this package
4+
# status: e.g. active, maintenance, unmaintained
5+
#
6+
owner: IBM
7+
status: active

orte/mca/regx/none/regx_none.c

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
/*
2+
* Copyright (c) 2016-2018 Intel, Inc. All rights reserved.
3+
* Copyright (c) 2019 IBM Corporation. All rights reserved.
4+
* Copyright (c) 2018 Research Organization for Information Science
5+
* and Technology (RIST). All rights reserved.
6+
* $COPYRIGHT$
7+
*
8+
* Additional copyrights may follow
9+
*
10+
* $HEADER$
11+
*
12+
*/
13+
14+
#include "orte_config.h"
15+
#include "orte/types.h"
16+
#include "opal/types.h"
17+
18+
#ifdef HAVE_UNISTD_H
19+
#include <unistd.h>
20+
#endif
21+
#include <ctype.h>
22+
23+
#include "opal/util/argv.h"
24+
#include "opal/util/basename.h"
25+
#include "opal/util/opal_environ.h"
26+
27+
#include "orte/runtime/orte_globals.h"
28+
#include "orte/util/name_fns.h"
29+
#include "orte/util/show_help.h"
30+
#include "orte/mca/errmgr/errmgr.h"
31+
#include "orte/mca/rmaps/base/base.h"
32+
#include "orte/mca/routed/routed.h"
33+
#include "orte/mca/regx/base/base.h"
34+
35+
#include "regx_none.h"
36+
37+
static int nidmap_create(opal_pointer_array_t *pool, char **regex);
38+
39+
orte_regx_base_module_t orte_regx_none_module = {
40+
.nidmap_create = nidmap_create,
41+
.nidmap_parse = orte_regx_base_nidmap_parse,
42+
.extract_node_names = orte_regx_base_extract_node_names,
43+
.encode_nodemap = orte_regx_base_encode_nodemap,
44+
.decode_daemon_nodemap = orte_regx_base_decode_daemon_nodemap,
45+
.generate_ppn = orte_regx_base_generate_ppn,
46+
.parse_ppn = orte_regx_base_parse_ppn
47+
};
48+
49+
static int nidmap_create(opal_pointer_array_t *pool, char **regex)
50+
{
51+
char *node;
52+
int n;
53+
char *nodenames;
54+
orte_regex_node_t *ndreg;
55+
orte_regex_range_t *rng;
56+
opal_list_t nodenms, dvpids;
57+
opal_list_item_t *item;
58+
char **regexargs = NULL, *tmp, *tmp2;
59+
orte_node_t *nptr;
60+
orte_vpid_t vpid;
61+
62+
OBJ_CONSTRUCT(&nodenms, opal_list_t);
63+
OBJ_CONSTRUCT(&dvpids, opal_list_t);
64+
65+
rng = NULL;
66+
for (n=0; n < pool->size; n++) {
67+
if (NULL == (nptr = (orte_node_t*)opal_pointer_array_get_item(pool, n))) {
68+
continue;
69+
}
70+
/* if no daemon has been assigned, then this node is not being used */
71+
if (NULL == nptr->daemon) {
72+
vpid = -1; // indicates no daemon assigned
73+
} else {
74+
vpid = nptr->daemon->name.vpid;
75+
}
76+
/* deal with the daemon vpid - see if it is next in the
77+
* current range */
78+
if (NULL == rng) {
79+
/* just starting */
80+
rng = OBJ_NEW(orte_regex_range_t);
81+
rng->vpid = vpid;
82+
rng->cnt = 1;
83+
opal_list_append(&dvpids, &rng->super);
84+
} else if (UINT32_MAX == vpid) {
85+
if (-1 == rng->vpid) {
86+
rng->cnt++;
87+
} else {
88+
/* need to start another range */
89+
rng = OBJ_NEW(orte_regex_range_t);
90+
rng->vpid = vpid;
91+
rng->cnt = 1;
92+
opal_list_append(&dvpids, &rng->super);
93+
}
94+
} else if (-1 == rng->vpid) {
95+
/* need to start another range */
96+
rng = OBJ_NEW(orte_regex_range_t);
97+
rng->vpid = vpid;
98+
rng->cnt = 1;
99+
opal_list_append(&dvpids, &rng->super);
100+
} else {
101+
/* is this the next in line */
102+
if (vpid == (orte_vpid_t)(rng->vpid + rng->cnt)) {
103+
rng->cnt++;
104+
} else {
105+
/* need to start another range */
106+
rng = OBJ_NEW(orte_regex_range_t);
107+
rng->vpid = vpid;
108+
rng->cnt = 1;
109+
opal_list_append(&dvpids, &rng->super);
110+
}
111+
}
112+
node = nptr->name;
113+
opal_output_verbose(5, orte_regx_base_framework.framework_output,
114+
"%s PROCESS NODE <%s>",
115+
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
116+
node);
117+
118+
/* Don't compress the name - just add it to the list */
119+
ndreg = OBJ_NEW(orte_regex_node_t);
120+
ndreg->prefix = strdup(node);
121+
opal_list_append(&nodenms, &ndreg->super);
122+
}
123+
/* begin constructing the regular expression */
124+
while (NULL != (item = opal_list_remove_first(&nodenms))) {
125+
ndreg = (orte_regex_node_t*)item;
126+
127+
/* if no ranges, then just add the name */
128+
if (0 == opal_list_get_size(&ndreg->ranges)) {
129+
if (NULL != ndreg->prefix) {
130+
/* solitary node */
131+
asprintf(&tmp, "%s", ndreg->prefix);
132+
opal_argv_append_nosize(&regexargs, tmp);
133+
free(tmp);
134+
}
135+
OBJ_RELEASE(ndreg);
136+
}
137+
}
138+
139+
/* assemble final result */
140+
nodenames = opal_argv_join(regexargs, ',');
141+
/* cleanup */
142+
opal_argv_free(regexargs);
143+
OBJ_DESTRUCT(&nodenms);
144+
145+
/* do the same for the vpids */
146+
tmp = NULL;
147+
while (NULL != (item = opal_list_remove_first(&dvpids))) {
148+
rng = (orte_regex_range_t*)item;
149+
if (1 < rng->cnt) {
150+
if (NULL == tmp) {
151+
asprintf(&tmp, "%u(%u)", rng->vpid, rng->cnt);
152+
} else {
153+
asprintf(&tmp2, "%s,%u(%u)", tmp, rng->vpid, rng->cnt);
154+
free(tmp);
155+
tmp = tmp2;
156+
}
157+
} else {
158+
if (NULL == tmp) {
159+
asprintf(&tmp, "%u", rng->vpid);
160+
} else {
161+
asprintf(&tmp2, "%s,%u", tmp, rng->vpid);
162+
free(tmp);
163+
tmp = tmp2;
164+
}
165+
}
166+
OBJ_RELEASE(rng);
167+
}
168+
OPAL_LIST_DESTRUCT(&dvpids);
169+
170+
/* now concatenate the results into one string */
171+
asprintf(&tmp2, "%s@%s", nodenames, tmp);
172+
free(nodenames);
173+
free(tmp);
174+
*regex = tmp2;
175+
return ORTE_SUCCESS;
176+
}

orte/mca/regx/none/regx_none.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2016-2018 Intel, Inc. All rights reserved.
3+
* $COPYRIGHT$
4+
*
5+
* Additional copyrights may follow
6+
*
7+
* $HEADER$
8+
*/
9+
10+
#ifndef _MCA_REGX_NONE_H_
11+
#define _MCA_REGX_NONE_H_
12+
13+
#include "orte_config.h"
14+
15+
#include "orte/types.h"
16+
17+
#include "opal/mca/base/base.h"
18+
#include "orte/mca/regx/regx.h"
19+
20+
21+
BEGIN_C_DECLS
22+
23+
ORTE_MODULE_DECLSPEC extern orte_regx_base_component_t mca_regx_none_component;
24+
extern orte_regx_base_module_t orte_regx_none_module;
25+
26+
END_C_DECLS
27+
28+
#endif /* MCA_REGX_ORTE_H_ */
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2016-2018 Intel, Inc. All rights reserved.
4+
* $COPYRIGHT$
5+
*
6+
* Additional copyrights may follow
7+
*
8+
* $HEADER$
9+
*/
10+
11+
#include "orte_config.h"
12+
#include "orte/types.h"
13+
#include "opal/types.h"
14+
15+
#include "opal/util/show_help.h"
16+
17+
#include "orte/mca/regx/regx.h"
18+
#include "regx_none.h"
19+
20+
static int component_query(mca_base_module_t **module, int *priority);
21+
22+
/*
23+
* Struct of function pointers and all that to let us be initialized
24+
*/
25+
orte_regx_base_component_t mca_regx_none_component = {
26+
.base_version = {
27+
MCA_REGX_BASE_VERSION_1_0_0,
28+
.mca_component_name = "none",
29+
MCA_BASE_MAKE_VERSION(component, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION,
30+
ORTE_RELEASE_VERSION),
31+
.mca_query_component = component_query,
32+
},
33+
.base_data = {
34+
/* The component is checkpoint ready */
35+
MCA_BASE_METADATA_PARAM_CHECKPOINT
36+
},
37+
};
38+
39+
static int component_query(mca_base_module_t **module, int *priority)
40+
{
41+
*module = (mca_base_module_t*)&orte_regx_none_module;
42+
*priority = 1;
43+
return ORTE_SUCCESS;
44+
}

0 commit comments

Comments
 (0)