root/mpich2/trunk/src/include/pmi.h @ 4888

Revision 4888, 19.4 KB (checked in by buntinas, 5 months ago)

squashed more warnings

Line 
1/* -*- Mode: C; c-basic-offset:4 ; -*- */
2/*
3 *  (C) 2001 by Argonne National Laboratory.
4 *      See COPYRIGHT in top-level directory.
5 */
6
7#ifndef PMI_H_INCLUDED
8#define PMI_H_INCLUDED
9
10#ifdef USE_PMI2_API
11#error This header file defines the PMI v1 API, but PMI2 was selected
12#endif
13
14/* prototypes for the PMI interface in MPICH2 */
15
16#if defined(__cplusplus)
17extern "C" {
18#endif
19
20/*D
21PMI_CONSTANTS - PMI definitions
22
23Error Codes:
24+ PMI_SUCCESS - operation completed successfully
25. PMI_FAIL - operation failed
26. PMI_ERR_NOMEM - input buffer not large enough
27. PMI_ERR_INIT - PMI not initialized
28. PMI_ERR_INVALID_ARG - invalid argument
29. PMI_ERR_INVALID_KEY - invalid key argument
30. PMI_ERR_INVALID_KEY_LENGTH - invalid key length argument
31. PMI_ERR_INVALID_VAL - invalid val argument
32. PMI_ERR_INVALID_VAL_LENGTH - invalid val length argument
33. PMI_ERR_INVALID_LENGTH - invalid length argument
34. PMI_ERR_INVALID_NUM_ARGS - invalid number of arguments
35. PMI_ERR_INVALID_ARGS - invalid args argument
36. PMI_ERR_INVALID_NUM_PARSED - invalid num_parsed length argument
37. PMI_ERR_INVALID_KEYVALP - invalid keyvalp argument
38- PMI_ERR_INVALID_SIZE - invalid size argument
39
40Booleans:
41+ PMI_TRUE - true
42- PMI_FALSE - false
43
44D*/
45#define PMI_SUCCESS                  0
46#define PMI_FAIL                    -1
47#define PMI_ERR_INIT                 1
48#define PMI_ERR_NOMEM                2
49#define PMI_ERR_INVALID_ARG          3
50#define PMI_ERR_INVALID_KEY          4
51#define PMI_ERR_INVALID_KEY_LENGTH   5
52#define PMI_ERR_INVALID_VAL          6
53#define PMI_ERR_INVALID_VAL_LENGTH   7
54#define PMI_ERR_INVALID_LENGTH       8
55#define PMI_ERR_INVALID_NUM_ARGS     9
56#define PMI_ERR_INVALID_ARGS        10
57#define PMI_ERR_INVALID_NUM_PARSED  11
58#define PMI_ERR_INVALID_KEYVALP     12
59#define PMI_ERR_INVALID_SIZE        13
60
61typedef int PMI_BOOL;
62#define PMI_TRUE     1
63#define PMI_FALSE    0
64
65/* PMI Group functions */
66
67/*@
68PMI_Init - initialize the Process Manager Interface
69
70Output Parameter:
71. spawned - spawned flag
72
73Return values:
74+ PMI_SUCCESS - initialization completed successfully
75. PMI_ERR_INVALID_ARG - invalid argument
76- PMI_FAIL - initialization failed
77
78Notes:
79Initialize PMI for this process group. The value of spawned indicates whether
80this process was created by 'PMI_Spawn_multiple'.  'spawned' will be 'PMI_TRUE' if
81this process group has a parent and 'PMI_FALSE' if it does not.
82
83@*/
84int PMI_Init( int *spawned );
85
86/*@
87PMI_Initialized - check if PMI has been initialized
88
89Output Parameter:
90. initialized - boolean value
91
92Return values:
93+ PMI_SUCCESS - initialized successfully set
94. PMI_ERR_INVALID_ARG - invalid argument
95- PMI_FAIL - unable to set the variable
96
97Notes:
98On successful output, initialized will either be 'PMI_TRUE' or 'PMI_FALSE'.
99
100+ PMI_TRUE - initialize has been called.
101- PMI_FALSE - initialize has not been called or previously failed.
102
103@*/
104int PMI_Initialized( PMI_BOOL *initialized );
105
106/*@
107PMI_Finalize - finalize the Process Manager Interface
108
109Return values:
110+ PMI_SUCCESS - finalization completed successfully
111- PMI_FAIL - finalization failed
112
113Notes:
114 Finalize PMI for this process group.
115
116@*/
117int PMI_Finalize( void );
118
119/*@
120PMI_Get_size - obtain the size of the process group
121
122Output Parameters:
123. size - pointer to an integer that receives the size of the process group
124
125Return values:
126+ PMI_SUCCESS - size successfully obtained
127. PMI_ERR_INVALID_ARG - invalid argument
128- PMI_FAIL - unable to return the size
129
130Notes:
131This function returns the size of the process group to which the local process
132belongs.
133
134@*/
135int PMI_Get_size( int *size );
136
137/*@
138PMI_Get_rank - obtain the rank of the local process in the process group
139
140Output Parameters:
141. rank - pointer to an integer that receives the rank in the process group
142
143Return values:
144+ PMI_SUCCESS - rank successfully obtained
145. PMI_ERR_INVALID_ARG - invalid argument
146- PMI_FAIL - unable to return the rank
147
148Notes:
149This function returns the rank of the local process in its process group.
150
151@*/
152int PMI_Get_rank( int *rank );
153
154/*@
155PMI_Get_universe_size - obtain the universe size
156
157Output Parameters:
158. size - pointer to an integer that receives the size
159
160Return values:
161+ PMI_SUCCESS - size successfully obtained
162. PMI_ERR_INVALID_ARG - invalid argument
163- PMI_FAIL - unable to return the size
164
165
166@*/
167int PMI_Get_universe_size( int *size );
168
169/*@
170PMI_Get_appnum - obtain the application number
171
172Output parameters:
173. appnum - pointer to an integer that receives the appnum
174
175Return values:
176+ PMI_SUCCESS - appnum successfully obtained
177. PMI_ERR_INVALID_ARG - invalid argument
178- PMI_FAIL - unable to return the size
179
180
181@*/
182int PMI_Get_appnum( int *appnum );
183
184/*@
185PMI_Publish_name - publish a name
186
187Input parameters:
188. service_name - string representing the service being published
189. port - string representing the port on which to contact the service
190
191Return values:
192+ PMI_SUCCESS - port for service successfully published
193. PMI_ERR_INVALID_ARG - invalid argument
194- PMI_FAIL - unable to publish service
195
196
197@*/
198int PMI_Publish_name( const char service_name[], const char port[] );
199
200/*@
201PMI_Unpublish_name - unpublish a name
202
203Input parameters:
204. service_name - string representing the service being unpublished
205
206Return values:
207+ PMI_SUCCESS - port for service successfully published
208. PMI_ERR_INVALID_ARG - invalid argument
209- PMI_FAIL - unable to unpublish service
210
211
212@*/
213int PMI_Unpublish_name( const char service_name[] );
214
215/*@
216PMI_Lookup_name - lookup a service by name
217
218Input parameters:
219. service_name - string representing the service being published
220
221Output parameters:
222. port - string representing the port on which to contact the service
223
224Return values:
225+ PMI_SUCCESS - port for service successfully obtained
226. PMI_ERR_INVALID_ARG - invalid argument
227- PMI_FAIL - unable to lookup service
228
229
230@*/
231int PMI_Lookup_name( const char service_name[], char port[] );
232
233/*@
234PMI_Get_id - obtain the id of the process group
235
236Input Parameter:
237. length - length of the id_str character array
238
239Output Parameter:
240. id_str - character array that receives the id of the process group
241
242Return values:
243+ PMI_SUCCESS - id successfully obtained
244. PMI_ERR_INVALID_ARG - invalid rank argument
245. PMI_ERR_INVALID_LENGTH - invalid length argument
246- PMI_FAIL - unable to return the id
247
248Notes:
249This function returns a string that uniquely identifies the process group
250that the local process belongs to.  The string passed in must be at least
251as long as the number returned by 'PMI_Get_id_length_max()'.
252
253@*/
254int PMI_Get_id( char id_str[], int length );
255
256/*@
257PMI_Get_kvs_domain_id - obtain the id of the PMI domain
258
259Input Parameter:
260. length - length of id_str character array
261
262Output Parameter:
263. id_str - character array that receives the id of the PMI domain
264
265Return values:
266+ PMI_SUCCESS - id successfully obtained
267. PMI_ERR_INVALID_ARG - invalid argument
268. PMI_ERR_INVALID_LENGTH - invalid length argument
269- PMI_FAIL - unable to return the id
270
271Notes:
272This function returns a string that uniquely identifies the PMI domain
273where keyval spaces can be shared.  The string passed in must be at least
274as long as the number returned by 'PMI_Get_id_length_max()'.
275
276@*/
277int PMI_Get_kvs_domain_id( char id_str[], int length );
278
279/*@
280PMI_Get_id_length_max - obtain the maximum length of an id string
281
282Output Parameters:
283. length - the maximum length of an id string
284
285Return values:
286+ PMI_SUCCESS - length successfully set
287. PMI_ERR_INVALID_ARG - invalid argument
288- PMI_FAIL - unable to return the maximum length
289
290Notes:
291This function returns the maximum length of a process group id string.
292
293@*/
294int PMI_Get_id_length_max( int *length );
295
296/*@
297PMI_Barrier - barrier across the process group
298
299Return values:
300+ PMI_SUCCESS - barrier successfully finished
301- PMI_FAIL - barrier failed
302
303Notes:
304This function is a collective call across all processes in the process group
305the local process belongs to.  It will not return until all the processes
306have called 'PMI_Barrier()'.
307
308@*/
309int PMI_Barrier( void );
310
311/*@
312PMI_Get_clique_size - obtain the number of processes on the local node
313
314Output Parameters:
315. size - pointer to an integer that receives the size of the clique
316
317Return values:
318+ PMI_SUCCESS - size successfully obtained
319. PMI_ERR_INVALID_ARG - invalid argument
320- PMI_FAIL - unable to return the clique size
321
322Notes:
323This function returns the number of processes in the local process group that
324are on the local node along with the local process.  This is a simple topology
325function to distinguish between processes that can communicate through IPC
326mechanisms (e.g., shared memory) and other network mechanisms.
327
328@*/
329int PMI_Get_clique_size( int *size );
330
331/*@
332PMI_Get_clique_ranks - get the ranks of the local processes in the process group
333
334Input Parameters:
335. length - length of the ranks array
336
337Output Parameters:
338. ranks - pointer to an array of integers that receive the local ranks
339
340Return values:
341+ PMI_SUCCESS - ranks successfully obtained
342. PMI_ERR_INVALID_ARG - invalid argument
343. PMI_ERR_INVALID_LENGTH - invalid length argument
344- PMI_FAIL - unable to return the ranks
345
346Notes:
347This function returns the ranks of the processes on the local node.  The array
348must be at least as large as the size returned by 'PMI_Get_clique_size()'.  This
349is a simple topology function to distinguish between processes that can
350communicate through IPC mechanisms (e.g., shared memory) and other network
351mechanisms.
352
353@*/
354int PMI_Get_clique_ranks( int ranks[], int length );
355
356/*@
357PMI_Abort - abort the process group associated with this process
358
359Input Parameters:
360+ exit_code - exit code to be returned by this process
361- error_msg - error message to be printed
362
363Return values:
364. none - this function should not return
365@*/
366int PMI_Abort(int exit_code, const char error_msg[]);
367
368/* PMI Keymap functions */
369/*@
370PMI_KVS_Get_my_name - obtain the name of the keyval space the local process group has access to
371
372Input Parameters:
373. length - length of the kvsname character array
374
375Output Parameters:
376. kvsname - a string that receives the keyval space name
377
378Return values:
379+ PMI_SUCCESS - kvsname successfully obtained
380. PMI_ERR_INVALID_ARG - invalid argument
381. PMI_ERR_INVALID_LENGTH - invalid length argument
382- PMI_FAIL - unable to return the kvsname
383
384Notes:
385This function returns the name of the keyval space that this process and all
386other processes in the process group have access to.  The output parameter,
387kvsname, must be at least as long as the value returned by
388'PMI_KVS_Get_name_length_max()'.
389
390@*/
391int PMI_KVS_Get_my_name( char kvsname[], int length );
392
393/*@
394PMI_KVS_Get_name_length_max - obtain the length necessary to store a kvsname
395
396Output Parameter:
397. length - maximum length required to hold a keyval space name
398
399Return values:
400+ PMI_SUCCESS - length successfully set
401. PMI_ERR_INVALID_ARG - invalid argument
402- PMI_FAIL - unable to set the length
403
404Notes:
405This function returns the string length required to store a keyval space name.
406
407A routine is used rather than setting a maximum value in 'pmi.h' to allow
408different implementations of PMI to be used with the same executable.  These
409different implementations may allow different maximum lengths; by using a
410routine here, we can interface with a variety of implementations of PMI.
411
412@*/
413int PMI_KVS_Get_name_length_max( int *length );
414
415/*@
416PMI_KVS_Get_key_length_max - obtain the length necessary to store a key
417
418Output Parameter:
419. length - maximum length required to hold a key string.
420
421Return values:
422+ PMI_SUCCESS - length successfully set
423. PMI_ERR_INVALID_ARG - invalid argument
424- PMI_FAIL - unable to set the length
425
426Notes:
427This function returns the string length required to store a key.
428
429@*/
430int PMI_KVS_Get_key_length_max( int *length );
431
432/*@
433PMI_KVS_Get_value_length_max - obtain the length necessary to store a value
434
435Output Parameter:
436. length - maximum length required to hold a keyval space value
437
438Return values:
439+ PMI_SUCCESS - length successfully set
440. PMI_ERR_INVALID_ARG - invalid argument
441- PMI_FAIL - unable to set the length
442
443Notes:
444This function returns the string length required to store a value from a
445keyval space.
446
447@*/
448int PMI_KVS_Get_value_length_max( int *length );
449
450/*@
451PMI_KVS_Create - create a new keyval space
452
453Input Parameter:
454. length - length of the kvsname character array
455
456Output Parameters:
457. kvsname - a string that receives the keyval space name
458
459Return values:
460+ PMI_SUCCESS - keyval space successfully created
461. PMI_ERR_INVALID_ARG - invalid argument
462. PMI_ERR_INVALID_LENGTH - invalid length argument
463- PMI_FAIL - unable to create a new keyval space
464
465Notes:
466This function creates a new keyval space.  Everyone in the same process group
467can access this keyval space by the name returned by this function.  The
468function is not collective.  Only one process calls this function.  The output
469parameter, kvsname, must be at least as long as the value returned by
470'PMI_KVS_Get_name_length_max()'.
471
472@*/
473int PMI_KVS_Create( char kvsname[], int length );
474
475/*@
476PMI_KVS_Destroy - destroy keyval space
477
478Input Parameters:
479. kvsname - keyval space name
480
481Return values:
482+ PMI_SUCCESS - keyval space successfully destroyed
483. PMI_ERR_INVALID_ARG - invalid argument
484- PMI_FAIL - unable to destroy the keyval space
485
486Notes:
487This function destroys a keyval space created by 'PMI_KVS_Create()'.
488
489@*/
490int PMI_KVS_Destroy( const char kvsname[] );
491
492/*@
493PMI_KVS_Put - put a key/value pair in a keyval space
494
495Input Parameters:
496+ kvsname - keyval space name
497. key - key
498- value - value
499
500Return values:
501+ PMI_SUCCESS - keyval pair successfully put in keyval space
502. PMI_ERR_INVALID_KVS - invalid kvsname argument
503. PMI_ERR_INVALID_KEY - invalid key argument
504. PMI_ERR_INVALID_VAL - invalid val argument
505- PMI_FAIL - put failed
506
507Notes:
508This function puts the key/value pair in the specified keyval space.  The
509value is not visible to other processes until 'PMI_KVS_Commit()' is called. 
510The function may complete locally.  After 'PMI_KVS_Commit()' is called, the
511value may be retrieved by calling 'PMI_KVS_Get()'.  All keys put to a keyval
512space must be unique to the keyval space.  You may not put more than once
513with the same key.
514
515@*/
516int PMI_KVS_Put( const char kvsname[], const char key[], const char value[]);
517
518/*@
519PMI_KVS_Commit - commit all previous puts to the keyval space
520
521Input Parameters:
522. kvsname - keyval space name
523
524Return values:
525+ PMI_SUCCESS - commit succeeded
526. PMI_ERR_INVALID_ARG - invalid argument
527- PMI_FAIL - commit failed
528
529Notes:
530This function commits all previous puts since the last 'PMI_KVS_Commit()' into
531the specified keyval space. It is a process local operation.
532
533@*/
534int PMI_KVS_Commit( const char kvsname[] );
535
536/*@
537PMI_KVS_Get - get a key/value pair from a keyval space
538
539Input Parameters:
540+ kvsname - keyval space name
541. key - key
542- length - length of value character array
543
544Output Parameters:
545. value - value
546
547Return values:
548+ PMI_SUCCESS - get succeeded
549. PMI_ERR_INVALID_KVS - invalid kvsname argument
550. PMI_ERR_INVALID_KEY - invalid key argument
551. PMI_ERR_INVALID_VAL - invalid val argument
552. PMI_ERR_INVALID_LENGTH - invalid length argument
553- PMI_FAIL - get failed
554
555Notes:
556This function gets the value of the specified key in the keyval space.
557
558@*/
559int PMI_KVS_Get( const char kvsname[], const char key[], char value[], int length);
560
561/*@
562PMI_KVS_Iter_first - initialize the iterator and get the first value
563
564Input Parameters:
565+ kvsname - keyval space name
566. key_len - length of key character array
567- val_len - length of val character array
568
569Output Parameters:
570+ key - key
571- value - value
572
573Return values:
574+ PMI_SUCCESS - keyval pair successfully retrieved from the keyval space
575. PMI_ERR_INVALID_KVS - invalid kvsname argument
576. PMI_ERR_INVALID_KEY - invalid key argument
577. PMI_ERR_INVALID_KEY_LENGTH - invalid key length argument
578. PMI_ERR_INVALID_VAL - invalid val argument
579. PMI_ERR_INVALID_VAL_LENGTH - invalid val length argument
580- PMI_FAIL - failed to initialize the iterator and get the first keyval pair
581
582Notes:
583This function initializes the iterator for the specified keyval space and
584retrieves the first key/val pair.  The end of the keyval space is specified
585by returning an empty key string.  key and val must be at least as long as
586the values returned by 'PMI_KVS_Get_key_length_max()' and
587'PMI_KVS_Get_value_length_max()'.
588
589@*/
590int PMI_KVS_Iter_first(const char kvsname[], char key[], int key_len, char val[], int val_len);
591
592/*@
593PMI_KVS_Iter_next - get the next keyval pair from the keyval space
594
595Input Parameters:
596+ kvsname - keyval space name
597. key_len - length of key character array
598- val_len - length of val character array
599
600Output Parameters:
601+ key - key
602- value - value
603
604Return values:
605+ PMI_SUCCESS - keyval pair successfully retrieved from the keyval space
606. PMI_ERR_INVALID_KVS - invalid kvsname argument
607. PMI_ERR_INVALID_KEY - invalid key argument
608. PMI_ERR_INVALID_KEY_LENGTH - invalid key length argument
609. PMI_ERR_INVALID_VAL - invalid val argument
610. PMI_ERR_INVALID_VAL_LENGTH - invalid val length argument
611- PMI_FAIL - failed to get the next keyval pair
612
613Notes:
614This function retrieves the next keyval pair from the specified keyval space. 
615'PMI_KVS_Iter_first()' must have been previously called.  The end of the keyval
616space is specified by returning an empty key string.  The output parameters,
617key and val, must be at least as long as the values returned by
618'PMI_KVS_Get_key_length_max()' and 'PMI_KVS_Get_value_length_max()'.
619
620@*/
621int PMI_KVS_Iter_next(const char kvsname[], char key[], int key_len, char val[], int val_len);
622
623/* PMI Process Creation functions */
624
625/*S
626PMI_keyval_t - keyval structure used by PMI_Spawn_mulitiple
627
628Fields:
629+ key - name of the key
630- val - value of the key
631
632S*/
633typedef struct PMI_keyval_t
634{
635    const char * key;
636    char * val;
637} PMI_keyval_t;
638
639/*@
640PMI_Spawn_multiple - spawn a new set of processes
641
642Input Parameters:
643+ count - count of commands
644. cmds - array of command strings
645. argvs - array of argv arrays for each command string
646. maxprocs - array of maximum processes to spawn for each command string
647. info_keyval_sizes - array giving the number of elements in each of the
648  'info_keyval_vectors'
649. info_keyval_vectors - array of keyval vector arrays
650. preput_keyval_size - Number of elements in 'preput_keyval_vector'
651- preput_keyval_vector - array of keyvals to be pre-put in the spawned keyval space
652
653Output Parameter:
654. errors - array of errors for each command
655
656Return values:
657+ PMI_SUCCESS - spawn successful
658. PMI_ERR_INVALID_ARG - invalid argument
659- PMI_FAIL - spawn failed
660
661Notes:
662This function spawns a set of processes into a new process group.  The 'count'
663field refers to the size of the array parameters - 'cmd', 'argvs', 'maxprocs',
664'info_keyval_sizes' and 'info_keyval_vectors'.  The 'preput_keyval_size' refers
665to the size of the 'preput_keyval_vector' array.  The 'preput_keyval_vector'
666contains keyval pairs that will be put in the keyval space of the newly
667created process group before the processes are started.  The 'maxprocs' array
668specifies the desired number of processes to create for each 'cmd' string. 
669The actual number of processes may be less than the numbers specified in
670maxprocs.  The acceptable number of processes spawned may be controlled by
671``soft'' keyvals in the info arrays.  The ``soft'' option is specified by
672mpiexec in the MPI-2 standard.  Environment variables may be passed to the
673spawned processes through PMI implementation specific 'info_keyval' parameters.
674@*/
675int PMI_Spawn_multiple(int count,
676                       const char * cmds[],
677                       const char ** argvs[],
678                       const int maxprocs[],
679                       const int info_keyval_sizesp[],
680                       const PMI_keyval_t * info_keyval_vectors[],
681                       int preput_keyval_size,
682                       const PMI_keyval_t preput_keyval_vector[],
683                       int errors[]);
684
685#if defined(__cplusplus)
686}
687#endif
688
689#endif
Note: See TracBrowser for help on using the browser.