Skip to content

Commit 9bfe061

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 9bfe061

File tree

7 files changed

+330
-0
lines changed

7 files changed

+330
-0
lines changed

orte/mca/regx/fwd/regx_fwd.c

+4
Original file line numberDiff line numberDiff line change
@@ -296,5 +296,9 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex)
296296
free(nodenames);
297297
free(tmp);
298298
*regex = tmp2;
299+
opal_output_verbose(5, orte_regx_base_framework.framework_output,
300+
"%s Final regex: <%s>",
301+
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
302+
*regex);
299303
return ORTE_SUCCESS;
300304
}

orte/mca/regx/none/Makefile.am

+36
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

+7
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

+183
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
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_range_t *rng;
55+
opal_list_t dvpids;
56+
opal_list_item_t *item;
57+
char **regexargs = NULL, **vpidargs = NULL, *tmp, *tmp2;
58+
orte_node_t *nptr;
59+
orte_vpid_t vpid;
60+
61+
if (mca_regx_none_component.compress_vpids) {
62+
OBJ_CONSTRUCT(&dvpids, opal_list_t);
63+
}
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+
77+
if (mca_regx_none_component.compress_vpids) {
78+
/* deal with the daemon vpid - see if it is next in the
79+
* current range */
80+
if (NULL == rng) {
81+
/* just starting */
82+
rng = OBJ_NEW(orte_regex_range_t);
83+
rng->vpid = vpid;
84+
rng->cnt = 1;
85+
opal_list_append(&dvpids, &rng->super);
86+
} else if (UINT32_MAX == vpid) {
87+
if (-1 == rng->vpid) {
88+
rng->cnt++;
89+
} else {
90+
/* need to start another range */
91+
rng = OBJ_NEW(orte_regex_range_t);
92+
rng->vpid = vpid;
93+
rng->cnt = 1;
94+
opal_list_append(&dvpids, &rng->super);
95+
}
96+
} else if (-1 == rng->vpid) {
97+
/* need to start another range */
98+
rng = OBJ_NEW(orte_regex_range_t);
99+
rng->vpid = vpid;
100+
rng->cnt = 1;
101+
opal_list_append(&dvpids, &rng->super);
102+
} else {
103+
/* is this the next in line */
104+
if (vpid == (orte_vpid_t)(rng->vpid + rng->cnt)) {
105+
rng->cnt++;
106+
} else {
107+
/* need to start another range */
108+
rng = OBJ_NEW(orte_regex_range_t);
109+
rng->vpid = vpid;
110+
rng->cnt = 1;
111+
opal_list_append(&dvpids, &rng->super);
112+
}
113+
}
114+
}
115+
else {
116+
asprintf(&tmp, "%u", vpid);
117+
opal_argv_append_nosize(&vpidargs, tmp);
118+
free(tmp);
119+
}
120+
121+
node = nptr->name;
122+
opal_output_verbose(5, orte_regx_base_framework.framework_output,
123+
"%s PROCESS NODE <%s>",
124+
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
125+
node);
126+
127+
/* Don't compress the name - just add it to the list */
128+
if (NULL != node) {
129+
/* solitary node */
130+
asprintf(&tmp, "%s", node);
131+
opal_argv_append_nosize(&regexargs, tmp);
132+
free(tmp);
133+
}
134+
}
135+
136+
/* assemble final result */
137+
nodenames = opal_argv_join(regexargs, ',');
138+
/* cleanup */
139+
opal_argv_free(regexargs);
140+
141+
if (mca_regx_none_component.compress_vpids) {
142+
/* do the same for the vpids */
143+
tmp = NULL;
144+
while (NULL != (item = opal_list_remove_first(&dvpids))) {
145+
rng = (orte_regex_range_t*)item;
146+
if (1 < rng->cnt) {
147+
if (NULL == tmp) {
148+
asprintf(&tmp, "%u(%u)", rng->vpid, rng->cnt);
149+
} else {
150+
asprintf(&tmp2, "%s,%u(%u)", tmp, rng->vpid, rng->cnt);
151+
free(tmp);
152+
tmp = tmp2;
153+
}
154+
} else {
155+
if (NULL == tmp) {
156+
asprintf(&tmp, "%u", rng->vpid);
157+
} else {
158+
asprintf(&tmp2, "%s,%u", tmp, rng->vpid);
159+
free(tmp);
160+
tmp = tmp2;
161+
}
162+
}
163+
OBJ_RELEASE(rng);
164+
}
165+
OPAL_LIST_DESTRUCT(&dvpids);
166+
}
167+
else {
168+
tmp = opal_argv_join(vpidargs, ',');
169+
/* cleanup */
170+
opal_argv_free(vpidargs);
171+
}
172+
173+
/* now concatenate the results into one string */
174+
asprintf(&tmp2, "%s@%s", nodenames, tmp);
175+
free(nodenames);
176+
free(tmp);
177+
*regex = tmp2;
178+
opal_output_verbose(5, orte_regx_base_framework.framework_output,
179+
"%s Final regex: <%s>",
180+
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
181+
*regex);
182+
return ORTE_SUCCESS;
183+
}

orte/mca/regx/none/regx_none.h

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
struct orte_regx_none_component_t {
24+
orte_regx_base_component_t super;
25+
bool compress_vpids;
26+
};
27+
typedef struct orte_regx_none_component_t orte_regx_none_component_t;
28+
29+
ORTE_MODULE_DECLSPEC extern orte_regx_none_component_t mca_regx_none_component;
30+
extern orte_regx_base_module_t orte_regx_none_module;
31+
32+
END_C_DECLS
33+
34+
#endif /* MCA_REGX_ORTE_H_ */
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
static int component_register(void);
22+
23+
/*
24+
* Struct of function pointers and all that to let us be initialized
25+
*/
26+
orte_regx_none_component_t mca_regx_none_component = {
27+
{
28+
.base_version = {
29+
MCA_REGX_BASE_VERSION_1_0_0,
30+
.mca_component_name = "none",
31+
MCA_BASE_MAKE_VERSION(component, ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION,
32+
ORTE_RELEASE_VERSION),
33+
.mca_query_component = component_query,
34+
.mca_register_component_params = component_register,
35+
},
36+
.base_data = {
37+
/* The component is checkpoint ready */
38+
MCA_BASE_METADATA_PARAM_CHECKPOINT
39+
},
40+
}
41+
};
42+
43+
static int component_query(mca_base_module_t **module, int *priority)
44+
{
45+
*module = (mca_base_module_t*)&orte_regx_none_module;
46+
*priority = 1;
47+
return ORTE_SUCCESS;
48+
}
49+
50+
static int component_register(void)
51+
{
52+
mca_base_component_t *c = &mca_regx_none_component.super.base_version;
53+
54+
mca_regx_none_component.compress_vpids = false;
55+
(void) mca_base_component_var_register (c, "compress_vpids", "Enable compression of vpids (default: false)",
56+
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
57+
OPAL_INFO_LVL_9,
58+
MCA_BASE_VAR_SCOPE_READONLY,
59+
&mca_regx_none_component.compress_vpids);
60+
61+
return ORTE_SUCCESS;
62+
}

orte/mca/regx/reverse/regx_reverse.c

+4
Original file line numberDiff line numberDiff line change
@@ -315,5 +315,9 @@ static int nidmap_create(opal_pointer_array_t *pool, char **regex)
315315
free(nodenames);
316316
free(tmp);
317317
*regex = tmp2;
318+
opal_output_verbose(5, orte_regx_base_framework.framework_output,
319+
"%s Final regex: <%s>",
320+
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
321+
*regex);
318322
return ORTE_SUCCESS;
319323
}

0 commit comments

Comments
 (0)