This source file includes following definitions.
- main
1
2
3
4
5
6
7
8 #include <stdio.h>
9 #include <unistd.h>
10
11 #include "opal/dss/dss.h"
12 #include "opal/util/opal_getcwd.h"
13
14 #include "orte/mca/errmgr/errmgr.h"
15 #include "orte/util/comm/comm.h"
16 #include "orte/util/hnp_contact.h"
17 #include "orte/util/proc_info.h"
18 #include "orte/runtime/orte_globals.h"
19 #include "orte/runtime/runtime.h"
20
21 int main(int argc, char* argv[])
22 {
23 int rc=ORTE_SUCCESS;
24 orte_job_t *jdata=NULL, **jobs=NULL;
25 opal_list_t hnp_list;
26 orte_hnp_contact_t *hnp;
27 orte_std_cntr_t num_jobs, i;
28 orte_app_context_t *app;
29 char cwd[OPAL_PATH_MAX];
30
31 if (0 > (rc = orte_init(&argc, &argv, ORTE_PROC_TOOL))) {
32 fprintf(stderr, "orte_tool: couldn't init orte\n");
33 return rc;
34 }
35
36
37
38
39 OBJ_CONSTRUCT(&hnp_list, opal_list_t);
40
41
42
43
44 if (ORTE_SUCCESS != (rc = orte_list_local_hnps(&hnp_list, true) ) ) {
45 fprintf(stderr, "orte_tool: couldn't get list of HNP's on this system - error %s\n",
46 ORTE_ERROR_NAME(rc));
47 goto cleanup;
48 }
49
50
51 if (opal_list_is_empty(&hnp_list)) {
52 fprintf(stderr, "orte_tool: no HNP's were found\n");
53 goto cleanup;
54 }
55
56
57 hnp = (orte_hnp_contact_t*)opal_list_remove_first(&hnp_list);
58
59
60 jdata = OBJ_NEW(orte_job_t);
61
62
63 app = OBJ_NEW(orte_app_context_t);
64
65 opal_pointer_array_add(jdata->apps, app);
66 jdata->num_apps++;
67
68
69 app->app = strdup("hostname");
70
71 app->argv = (char**)malloc(2 * sizeof(char*));
72 app->argv[0] = strdup(app->app);
73
74 app->num_procs = 1;
75
76 opal_getcwd(cwd, OPAL_PATH_MAX);
77 app->cwd = strdup(cwd);
78
79
80 if (ORTE_SUCCESS != (rc = orte_util_comm_spawn_job(&hnp->name, jdata))) {
81 ORTE_ERROR_LOG(rc);
82 goto cleanup;
83 }
84
85
86 fprintf(stderr, "orte_tool: spawned jobid %s\n", ORTE_JOBID_PRINT(jdata->jobid));
87 #if 0
88 if (ORTE_SUCCESS != (rc = orte_util_comm_query_job_info(&hnp->name, ORTE_JOBID_WILDCARD,
89 &num_jobs, &jobs))) {
90 ORTE_ERROR_LOG(rc);
91 }
92 printf("num jobs: %d\n", num_jobs);
93 opal_dss.dump(0, jobs[0], ORTE_JOB);
94 #endif
95
96 cleanup:
97 if (NULL != jdata) OBJ_RELEASE(jdata);
98 if (NULL != jobs) {
99 for (i=0; i < num_jobs; i++) OBJ_RELEASE(jobs[i]);
100 if (NULL != jobs) free(jobs);
101 }
102 orte_finalize();
103 return rc;
104 }