1 /*****************************************************************************\
2  **  pmi.c - PMI common definitions
3  *****************************************************************************
4  *  Copyright (C) 2011-2012 National University of Defense Technology.
5  *  Written by Hongjia Cao <hjcao@nudt.edu.cn>.
6  *  All rights reserved.
7  *
8  *  This file is part of Slurm, a resource management program.
9  *  For details, see <https://slurm.schedmd.com/>.
10  *  Please also read the included file: DISCLAIMER.
11  *
12  *  Slurm is free software; you can redistribute it and/or modify it under
13  *  the terms of the GNU General Public License as published by the Free
14  *  Software Foundation; either version 2 of the License, or (at your option)
15  *  any later version.
16  *
17  *  In addition, as a special exception, the copyright holders give permission
18  *  to link the code of portions of this program with the OpenSSL library under
19  *  certain conditions as described in each individual source file, and
20  *  distribute linked combinations including the two. You must obey the GNU
21  *  General Public License in all respects for all of the code used other than
22  *  OpenSSL. If you modify file(s) with this exception, you may extend this
23  *  exception to your version of the file(s), but you are not obligated to do
24  *  so. If you do not wish to do so, delete this exception statement from your
25  *  version.  If you delete this exception statement from all source files in
26  *  the program, then also delete it here.
27  *
28  *  Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
29  *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
30  *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
31  *  details.
32  *
33  *  You should have received a copy of the GNU General Public License along
34  *  with Slurm; if not, write to the Free Software Foundation, Inc.,
35  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
36 \*****************************************************************************/
37 
38 #ifndef _PMI_H
39 #define _PMI_H
40 
41 /***********************************************************\
42  * PMI1 definitions
43 \***********************************************************/
44 /* from src/pmi/simple/simeple_pmiutil.h */
45 #define PMIU_MAXLINE 1024
46 
47 /* from src/pm/hydra/pm/pmiserv/pmi_common.h */
48 #define MAXKEYLEN    64 /* max length of key in keyval space */
49 #define MAXVALLEN  1024 /* max length of value in keyval space */
50 #define MAXNAMELEN  256 /* max length of various names */
51 #define MAXKVSNAME  MAXNAMELEN  /* max length of a kvsname */
52 
53 
54 #define GETMAXES_CMD             "get_maxes"
55 #define MAXES_CMD                "maxes"
56 #define GETUNIVSIZE_CMD          "get_universe_size"
57 #define UNIVSIZE_CMD             "universe_size"
58 #define GETAPPNUM_CMD            "get_appnum"
59 #define APPNUM_CMD               "appnum"
60 #define BARRIERIN_CMD            "barrier_in"
61 #define BARRIEROUT_CMD           "barrier_out"
62 #define FINALIZE_CMD             "finalize"
63 #define FINALIZEACK_CMD          "finalize_ack"
64 #define ABORT_CMD                "abort"
65 #define PUT_CMD                  "put"
66 #define PUTRESULT_CMD            "put_result"
67 #define GET_CMD                  "get"
68 #define GETRESULT_CMD            "get_result"
69 #define GETBYIDX_CMD             "getbyidx"
70 #define GETBYIDXRESULTS_CMD      "getbyidx_results"
71 #define SPAWNRESULT_CMD          "spawn_result"
72 
73 #define MCMD_KEY           "mcmd"
74 #define ENDCMD_KEY         "endcmd"
75 #define KVSNAMEMAX_KEY     "kvsname_max"
76 #define KEYLENMAX_KEY      "keylen_max"
77 #define VALLENMAX_KEY      "vallen_max"
78 #define SIZE_KEY           "size"
79 #define APPNUM_KEY         "appnum"
80 #define EXECNAME_KEY       "execname"
81 #define NPROCS_KEY         "nprocs"
82 #define ARGCNT_KEY         "argcnt"
83 #define INFONUM_KEY        "info_num"
84 #define TOTSPAWNS_KEY      "totspawns"
85 #define SPAWNSSOFAR_KEY    "spawnssofar"
86 #define KVSNAME_KEY        "kvsname"
87 #define PREPUTNUM_KEY      "preput_num"
88 #define PREPUTKEY_KEY      "preput_key_"
89 #define PREPUTVAL_KEY      "preput_val_"
90 
91 
92 /***********************************************************\
93  * PMI2 definitions
94 \***********************************************************/
95 
96 /* from src/include/pmi2.h of mpich2 */
97 #define PMI2_SUCCESS                0
98 #define PMI2_FAIL                   -1
99 #define PMI2_ERR_INIT               1
100 #define PMI2_ERR_NOMEM              2
101 #define PMI2_ERR_INVALID_ARG        3
102 #define PMI2_ERR_INVALID_KEY        4
103 #define PMI2_ERR_INVALID_KEY_LENGTH 5
104 #define PMI2_ERR_INVALID_VAL        6
105 #define PMI2_ERR_INVALID_VAL_LENGTH 7
106 #define PMI2_ERR_INVALID_LENGTH     8
107 #define PMI2_ERR_INVALID_NUM_ARGS   9
108 #define PMI2_ERR_INVALID_ARGS       10
109 #define PMI2_ERR_INVALID_NUM_PARSED 11
110 #define PMI2_ERR_INVALID_KEYVALP    12
111 #define PMI2_ERR_INVALID_SIZE       13
112 #define PMI2_ERR_OTHER              14
113 
114 #define PMI2_MAX_KEYLEN 64
115 #define PMI2_MAX_VALLEN 1024
116 #define PMI2_MAX_ATTRVALUE 1024
117 #define PMI2_ID_NULL -1
118 
119 /* modified from src/pmi/pmi2/simple2pmi.h of mpich2 */
120 #define FULLINIT_CMD           "fullinit"
121 #define FULLINITRESP_CMD       "fullinit-response"
122 #define FINALIZE_CMD           "finalize"
123 #define FINALIZERESP_CMD       "finalize-response"
124 #define ABORT_CMD              "abort"
125 #define JOBGETID_CMD           "job-getid"
126 #define JOBGETIDRESP_CMD       "job-getid-response"
127 #define JOBCONNECT_CMD         "job-connect"
128 #define JOBCONNECTRESP_CMD     "job-connect-response"
129 #define JOBDISCONNECT_CMD      "job-disconnect"
130 #define JOBDISCONNECTRESP_CMD  "job-disconnect-response"
131 #define KVSPUT_CMD             "kvs-put"
132 #define KVSPUTRESP_CMD         "kvs-put-response"
133 #define KVSFENCE_CMD           "kvs-fence"
134 #define KVSFENCERESP_CMD       "kvs-fence-response"
135 #define KVSGET_CMD             "kvs-get"
136 #define KVSGETRESP_CMD         "kvs-get-response"
137 #define GETNODEATTR_CMD        "info-getnodeattr"
138 #define GETNODEATTRRESP_CMD    "info-getnodeattr-response"
139 #define PUTNODEATTR_CMD        "info-putnodeattr"
140 #define PUTNODEATTRRESP_CMD    "info-putnodeattr-response"
141 #define GETJOBATTR_CMD         "info-getjobattr"
142 #define GETJOBATTRRESP_CMD     "info-getjobattr-response"
143 #define NAMEPUBLISH_CMD        "name-publish"
144 #define NAMEPUBLISHRESP_CMD    "name-publish-response"
145 #define NAMEUNPUBLISH_CMD      "name-unpublish"
146 #define NAMEUNPUBLISHRESP_CMD  "name-unpublish-response"
147 #define NAMELOOKUP_CMD         "name-lookup"
148 #define NAMELOOKUPRESP_CMD     "name-lookup-response"
149 #define SPAWN_CMD              "spawn"
150 #define SPAWNRESP_CMD          "spawn-response"
151 #define RING_CMD               "ring"
152 #define RINGRESP_CMD           "ring-response"
153 
154 #define GETMYKVSNAME_CMD       "get_my_kvsname"
155 #define GETMYKVSNAMERESP_CMD   "my_kvsname"
156 #define CREATEKVS_CMD          "create_kvs"
157 #define DESTROYKVS_CMD         "destroy_kvs"
158 #define PUBLISHNAME_CMD        "publish_name"
159 #define UNPUBLISHNAME_CMD      "unpublish_name"
160 #define LOOKUPNAME_CMD         "lookup_name"
161 #define PUBLISHRESULT_CMD      "publish_result"
162 #define UNPUBLISHRESULT_CMD    "unpublish_result"
163 #define LOOKUPRESULT_CMD       "lookup_result"
164 #define MCMD_CMD               "mcmd"
165 
166 
167 #define CMD_KEY           "cmd"
168 #define PMIJOBID_KEY      "pmijobid"
169 #define PMIRANK_KEY       "pmirank"
170 #define SRCID_KEY         "srcid"
171 #define THREADED_KEY      "threaded"
172 #define RC_KEY            "rc"
173 #define ERRMSG_KEY        "errmsg"
174 #define PMIVERSION_KEY    "pmi-version"
175 #define PMISUBVER_KEY     "pmi-subversion"
176 #define RANK_KEY          "rank"
177 #define SIZE_KEY          "size"
178 #define APPNUM_KEY        "appnum"
179 #define SPAWNERJOBID_KEY  "spawner-jobid"
180 #define DEBUGGED_KEY      "debugged"
181 #define PMIVERBOSE_KEY    "pmiverbose"
182 #define ISWORLD_KEY       "isworld"
183 #define MSG_KEY           "msg"
184 #define JOBID_KEY         "jobid"
185 #define KVSCOPY_KEY       "kvscopy"
186 #define KEY_KEY           "key"
187 #define VALUE_KEY         "value"
188 #define FOUND_KEY         "found"
189 #define WAIT_KEY          "wait"
190 #define NAME_KEY          "name"
191 #define PORT_KEY          "port"
192 #define THRID_KEY         "thrid"
193 #define INFOKEYCOUNT_KEY  "infokeycount"
194 #define INFOKEY_KEY       "infokey"
195 #define INFOVAL_KEY       "infoval"
196 #define FOUND_KEY         "found"
197 #define NCMDS_KEY         "ncmds"
198 #define PREPUTCOUNT_KEY   "preputcount"
199 #define PPKEY_KEY         "ppkey"
200 #define PPVAL_KEY         "ppval"
201 #define SUBCMD_KEY        "subcmd"
202 #define MAXPROCS_KEY      "maxprocs"
203 #define ARGC_KEY          "argc"
204 #define ARGV_KEY          "argv"
205 #define INFOKEYCOUNT_KEY  "infokeycount"
206 #define ERRCODES_KEY      "errcodes"
207 #define SERVICE_KEY       "service"
208 #define INFO_KEY          "info"
209 #define RING_COUNT_KEY    "ring-count"
210 #define RING_LEFT_KEY     "ring-left"
211 #define RING_RIGHT_KEY    "ring-right"
212 
213 #define TRUE_VAL          "TRUE"
214 #define FALSE_VAL         "FALSE"
215 
216 #define JOB_ATTR_PROC_MAP       "PMI_process_mapping"
217 #define JOB_ATTR_UNIV_SIZE      "universeSize"
218 #define JOB_ATTR_NETINFO        "PMI_netinfo_of_task"
219 #define JOB_ATTR_RESV_PORTS     "mpi_reserved_ports"
220 
221 /***********************************************************\
222  * Environment variables
223 \***********************************************************/
224 #define PMI2_SRUN_PORT_ENV      "SLURM_PMI2_SRUN_PORT"
225 #define PMI2_STEP_NODES_ENV     "SLURM_PMI2_STEP_NODES"
226 #define PMI2_TREE_WIDTH_ENV     "SLURM_PMI2_TREE_WIDTH"
227 #define PMI2_PROC_MAPPING_ENV   "SLURM_PMI2_PROC_MAPPING"
228 #define PMI2_PMI_JOBID_ENV      "SLURM_PMI2_PMI_JOBID"
229 #define PMI2_SPAWN_SEQ_ENV      "SLURM_PMI2_SPAWN_SEQ"
230 #define PMI2_SPAWNER_JOBID_ENV  "SLURM_PMI2_SPAWNER_JOBID"
231 #define PMI2_SPAWNER_PORT_ENV   "SLURM_PMI2_SPAWNER_PORT"
232 #define PMI2_PREPUT_CNT_ENV     "SLURM_PMI2_PREPUT_COUNT"
233 #define PMI2_PPKEY_ENV          "SLURM_PMI2_PPKEY"
234 #define PMI2_PPVAL_ENV          "SLURM_PMI2_PPVAL"
235 #define SLURM_STEP_RESV_PORTS   "SLURM_STEP_RESV_PORTS"
236 #define PMIX_RING_TREE_WIDTH_ENV "SLURM_PMIX_RING_WIDTH"
237 /* old PMIv1 envs */
238 #define PMI2_PMI_DEBUGGED_ENV   "PMI_DEBUG"
239 #define PMI2_KVS_NO_DUP_KEYS_ENV "SLURM_PMI_KVS_NO_DUP_KEYS"
240 
241 
242 extern int handle_pmi1_cmd(int fd, int lrank);
243 extern int handle_pmi2_cmd(int fd, int lrank);
244 
245 #endif /* _PMI_H */
246