1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2011 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2011-2012 Los Alamos National Security, LLC.
13 * All rights reserved.
14 * Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
15 * Copyright (c) 2017 Cisco Systems, Inc. All rights reserved
16 * $COPYRIGHT$
17 *
18 * Additional copyrights may follow
19 *
20 * $HEADER$
21 */
22
23 /** @file:
24 *
25 * Populates global structure with process-specific information.
26 *
27 *
28 */
29
30 #ifndef _ORTE_PROC_INFO_H_
31 #define _ORTE_PROC_INFO_H_
32
33 #include "orte_config.h"
34
35 #include <stdint.h>
36
37 #ifdef HAVE_SYS_TYPES_H
38 #include <sys/types.h>
39 #endif
40
41 #include "orte/types.h"
42
43 #include "opal/dss/dss_types.h"
44 #include "opal/mca/hwloc/hwloc-internal.h"
45 #include "opal/util/proc.h"
46
47 BEGIN_C_DECLS
48
49 typedef uint32_t orte_proc_type_t;
50 #define ORTE_PROC_TYPE_NONE 0x0000
51 #define ORTE_PROC_SINGLETON 0x0001
52 #define ORTE_PROC_DAEMON 0x0002
53 #define ORTE_PROC_HNP 0x0004
54 #define ORTE_PROC_TOOL 0x0008
55 #define ORTE_PROC_NON_MPI 0x0010
56 #define ORTE_PROC_MPI 0x0020
57 #define ORTE_PROC_APP 0x0030
58 #define ORTE_PROC_DVM 0x0102 // DVM + daemon
59 #define ORTE_PROC_IOF_ENDPT 0x1000
60 #define ORTE_PROC_MASTER_ACTUAL 0x4000
61 #define ORTE_PROC_MASTER (ORTE_PROC_MASTER_ACTUAL + ORTE_PROC_HNP)
62
63 #define ORTE_PROC_IS_SINGLETON (ORTE_PROC_SINGLETON & orte_process_info.proc_type)
64 #define ORTE_PROC_IS_DAEMON (ORTE_PROC_DAEMON & orte_process_info.proc_type)
65 #define ORTE_PROC_IS_HNP (ORTE_PROC_HNP & orte_process_info.proc_type)
66 #define ORTE_PROC_IS_TOOL (ORTE_PROC_TOOL & orte_process_info.proc_type)
67 #define ORTE_PROC_IS_NON_MPI (ORTE_PROC_NON_MPI & orte_process_info.proc_type)
68 #define ORTE_PROC_IS_MPI (ORTE_PROC_MPI & orte_process_info.proc_type)
69 #define ORTE_PROC_IS_APP (ORTE_PROC_APP & orte_process_info.proc_type)
70 #define ORTE_PROC_IS_DVM (ORTE_PROC_DVM & orte_process_info.proc_type)
71 #define ORTE_PROC_IS_IOF_ENDPT (ORTE_PROC_IOF_ENDPT & orte_process_info.proc_type)
72 #define ORTE_PROC_IS_MASTER (ORTE_PROC_MASTER_ACTUAL & orte_process_info.proc_type)
73
74
75 /**
76 * Process information structure
77 *
78 * The orte_proc_info() function fills the pid field and obtains the
79 * process name, storing that information in the global structure. The
80 * structure also holds path names to the universe, job, and process
81 * session directories, and to the stdin, stdout, and stderr temp
82 * files - however, these are all initialized elsewhere.
83 */
84 struct orte_proc_info_t {
85 opal_proc_t super;
86 orte_process_name_t my_name; /**< My official process name */
87 orte_process_name_t my_daemon; /**< Name of my local daemon */
88 char *my_daemon_uri; /**< Contact info to local daemon */
89 orte_process_name_t my_hnp; /**< Name of my hnp */
90 char *my_hnp_uri; /**< Contact info for my hnp */
91 orte_process_name_t my_parent; /**< Name of my parent (or my HNP if no parent was specified) */
92 pid_t hnp_pid; /**< hnp pid - used if singleton */
93 orte_app_idx_t app_num; /**< our index into the app_context array */
94 orte_vpid_t num_procs; /**< number of processes in this job */
95 orte_vpid_t max_procs; /**< Maximum number of processes ever in the job */
96 orte_vpid_t num_daemons; /**< number of daemons in system */
97 int num_nodes; /**< number of nodes in the job */
98 char *nodename; /**< string name for this node */
99 char **aliases; /**< aliases for this node */
100 pid_t pid; /**< Local process ID for this process */
101 orte_proc_type_t proc_type; /**< Type of process */
102 uint16_t my_port; /**< TCP port for out-of-band comm */
103 int num_restarts; /**< number of times this proc has restarted */
104 orte_node_rank_t my_node_rank; /**< node rank */
105 orte_local_rank_t my_local_rank; /**< local rank */
106 int32_t num_local_peers; /**< number of procs from my job that share my node with me */
107 /* The session directory has the form
108 * <prefix>/<openmpi-sessions-user>/<jobid>/<procid>, where the prefix
109 * can either be provided by the user via the
110 * --tmpdir command-line flag, the use of one of several
111 * environmental variables, or else a default location.
112 */
113 char *tmpdir_base; /**< Base directory of the session dir tree */
114 char *top_session_dir; /**< Top-most directory of the session tree */
115 char *jobfam_session_dir; /**< Session directory for this family of jobs (i.e., share same mpirun) */
116 char *job_session_dir; /**< Session directory for job */
117 char *proc_session_dir; /**< Session directory for the process */
118 bool rm_session_dirs; /**< Session directories will be cleaned up by RM */
119
120 char *sock_stdin; /**< Path name to temp file for stdin. */
121 char *sock_stdout; /**< Path name to temp file for stdout. */
122 char *sock_stderr; /**< Path name to temp file for stderr. */
123 char *cpuset; /**< String-representation of bitmap where we are bound */
124 int app_rank; /**< rank within my app_context */
125 orte_vpid_t my_hostid; /** identifies the local host for a coprocessor */
126 };
127 typedef struct orte_proc_info_t orte_proc_info_t;
128
129
130 /**
131 *
132 * Global process info descriptor. Initialized to almost no
133 * meaningful information - data is provided by calling \c
134 * orte_rte_init() (which calls \c orte_proc_info() to fill in the
135 * structure).
136 *
137 * The exception to this rule is the \c orte_process_info.seed field,
138 * which will be initialized to \c false, but should be set to \c true
139 * before calling \c orte_rte_info() if the caller is a seed daemon.
140 */
141 ORTE_DECLSPEC extern orte_proc_info_t orte_process_info;
142
143
144 /**
145 * \internal
146 *
147 * Global structure to store a wide range of information about the
148 * process. orte_proc_info populates a global variable with
149 * information about the process being executing. This function should
150 * be called only once, from orte_rte_init().
151 *
152 * @param None.
153 *
154 * @retval ORTE_SUCCESS Successfully initialized the various fields.
155 * @retval OMPI_ERROR Failed to initialize one or more fields.
156 */
157
158 ORTE_DECLSPEC int orte_proc_info(void);
159
160 ORTE_DECLSPEC int orte_proc_info_finalize(void);
161
162 ORTE_DECLSPEC bool orte_ifislocal(const char *name);
163
164 END_C_DECLS
165
166 #endif