13
13
#include "opal/util/argv.h"
14
14
15
15
#include "orte/util/proc_info.h"
16
- #include "orte/util/regex.h"
17
16
#include "orte/mca/errmgr/errmgr.h"
18
17
#include "orte/runtime/runtime.h"
18
+ #include "orte/mca/regx/regx.h"
19
+ #include "orte/mca/regx/base/base.h"
19
20
20
21
int main (int argc , char * * argv )
21
22
{
22
23
int rc ;
23
- char * regex , * save ;
24
+ char * regex , * * nodelist ;
24
25
char * * nodes = NULL ;
25
26
int i ;
27
+ opal_pointer_array_t * node_pool ;
28
+ orte_node_t * nptr ;
26
29
27
30
if (argc < 1 || NULL == argv [1 ]) {
28
31
fprintf (stderr , "usage: regex <comma-separated list of nodes>\n" );
@@ -31,10 +34,19 @@ int main(int argc, char **argv)
31
34
32
35
orte_init (& argc , & argv , ORTE_PROC_NON_MPI );
33
36
37
+ if (ORTE_SUCCESS != (rc = mca_base_framework_open (& orte_regx_base_framework , 0 ))) {
38
+ ORTE_ERROR_LOG (rc );
39
+ return rc ;
40
+ }
41
+ if (ORTE_SUCCESS != (rc = orte_regx_base_select ())) {
42
+ ORTE_ERROR_LOG (rc );
43
+ return rc ;
44
+ }
45
+
34
46
if (NULL != strchr (argv [1 ], '[' )) {
35
47
/* given a regex to analyze */
36
48
fprintf (stderr , "ANALYZING REGEX: %s\n" , argv [1 ]);
37
- if (ORTE_SUCCESS != (rc = orte_regex_extract_node_names (argv [1 ], & nodes ))) {
49
+ if (ORTE_SUCCESS != (rc = orte_regx . extract_node_names (argv [1 ], & nodes ))) {
38
50
ORTE_ERROR_LOG (rc );
39
51
}
40
52
for (i = 0 ; NULL != nodes [i ]; i ++ ) {
@@ -45,12 +57,30 @@ int main(int argc, char **argv)
45
57
return 0 ;
46
58
}
47
59
48
- save = strdup (argv [1 ]);
49
- if (ORTE_SUCCESS != (rc = orte_regex_create (save , & regex ))) {
60
+ node_pool = OBJ_NEW (opal_pointer_array_t );
61
+ nodelist = opal_argv_split (argv [1 ], ',' );
62
+ for (i = 0 ; NULL != nodelist [i ]; i ++ ) {
63
+ orte_proc_t * daemon = NULL ;
64
+
65
+ nptr = OBJ_NEW (orte_node_t );
66
+ nptr -> name = strdup (nodelist [i ]);
67
+ daemon = OBJ_NEW (orte_proc_t );
68
+ daemon -> name .jobid = 123 ;
69
+ daemon -> name .vpid = i ;
70
+ nptr -> daemon = daemon ;
71
+
72
+ nptr -> index = opal_pointer_array_add (node_pool , nptr );
73
+ }
74
+ opal_argv_free (nodelist );
75
+
76
+
77
+ if (ORTE_SUCCESS != (rc = orte_regx .nidmap_create (node_pool , & regex ))) {
50
78
ORTE_ERROR_LOG (rc );
51
79
} else {
80
+ char * vpids = strchr (regex , '@' );
81
+ vpids [0 ] = '\0' ;
52
82
fprintf (stderr , "REGEX: %s\n" , regex );
53
- if (ORTE_SUCCESS != (rc = orte_regex_extract_node_names (regex , & nodes ))) {
83
+ if (ORTE_SUCCESS != (rc = orte_regx . extract_node_names (regex , & nodes ))) {
54
84
ORTE_ERROR_LOG (rc );
55
85
}
56
86
free (regex );
@@ -63,5 +93,10 @@ int main(int argc, char **argv)
63
93
}
64
94
free (regex );
65
95
}
66
- free (save );
96
+
97
+ for (i = 0 ; (nptr = opal_pointer_array_get_item (node_pool , i )) != NULL ; i ++ ) {
98
+ free (nptr -> name );
99
+ OBJ_RELEASE (nptr -> daemon );
100
+ }
101
+ OBJ_RELEASE (node_pool );
67
102
}
0 commit comments