This source file includes following definitions.
- main
1
2
3
4
5
6
7
8 #include "orte_config.h"
9
10 #include <stdio.h>
11 #include <unistd.h>
12
13 #include "opal/util/argv.h"
14
15 #include "orte/util/proc_info.h"
16 #include "orte/mca/errmgr/errmgr.h"
17 #include "orte/runtime/runtime.h"
18 #include "orte/mca/regx/regx.h"
19 #include "orte/mca/regx/base/base.h"
20
21 int main(int argc, char **argv)
22 {
23 int rc;
24 char *regex = NULL, **nodelist;
25 char **nodes=NULL;
26 int i;
27 opal_pointer_array_t *node_pool;
28 orte_node_t *nptr;
29
30 if (argc < 1 || NULL == argv[1]) {
31 fprintf(stderr, "usage: regex <comma-separated list of nodes>\n");
32 return 1;
33 }
34
35 orte_init(&argc, &argv, ORTE_PROC_NON_MPI);
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
46 if (NULL != strchr(argv[1], '[')) {
47
48 fprintf(stderr, "ANALYZING REGEX: %s\n", argv[1]);
49 if (ORTE_SUCCESS != (rc = orte_regx.extract_node_names(argv[1], &nodes))) {
50 ORTE_ERROR_LOG(rc);
51 }
52 for (i=0; NULL != nodes[i]; i++) {
53 fprintf(stderr, "%s\n", nodes[i]);
54 }
55 opal_argv_free(nodes);
56 orte_finalize();
57 return 0;
58 }
59
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
75
76
77 if (ORTE_SUCCESS != (rc = orte_regx.nidmap_create(node_pool, ®ex))) {
78 ORTE_ERROR_LOG(rc);
79 } else {
80 char *vpids = strchr(regex, '@');
81 vpids[0] = '\0';
82 fprintf(stderr, "REGEX: %s\n", regex);
83 if (ORTE_SUCCESS != (rc = orte_regx.extract_node_names(regex, &nodes))) {
84 ORTE_ERROR_LOG(rc);
85 }
86 free(regex);
87 regex = opal_argv_join(nodes, ',');
88 if (0 == strcmp(regex, argv[1])) {
89 fprintf(stderr, "EXACT MATCH\n");
90 } else {
91 fprintf(stderr, "ERROR: %s\n", regex);
92 if (opal_argv_count(nodes) != opal_argv_count(nodelist)) {
93 fprintf(stderr, "ERROR: number of nodes %d, expected %d\n",
94 opal_argv_count(nodes), opal_argv_count(nodelist));
95 goto exit;
96 }
97 for (i=0; NULL != nodelist[i]; i++) {
98 if (0 == strcmp(nodelist[i], nodes[i])) {
99 fprintf(stderr, "%s OK\n", nodelist[i]);
100 }
101 fprintf(stderr, "%s ERROR, expect %s\n", nodes[i], nodelist[i]);
102 }
103 }
104 free(regex);
105 regex = NULL;
106 }
107 exit:
108 opal_argv_free(nodelist);
109 opal_argv_free(nodes);
110
111
112 for (i=0; (nptr = opal_pointer_array_get_item(node_pool, i)) != NULL; i++) {
113 free(nptr->name);
114 OBJ_RELEASE(nptr->daemon);
115 }
116 OBJ_RELEASE(node_pool);
117 }