OpenMPI  0.1.1
name_fns.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2008 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) 2010 Oracle and/or its affiliates. All rights reserved.
13  * $COPYRIGHT$
14  *
15  * Additional copyrights may follow
16  *
17  * $HEADER$
18  */
19 
20 /** @file:
21  *
22  * Populates global structure with system-specific information.
23  *
24  * Notes: add limits.h, compute size of integer and other types via sizeof(type)*CHAR_BIT
25  *
26  */
27 
28 #ifndef _ORTE_NAME_FNS_H_
29 #define _ORTE_NAME_FNS_H_
30 
31 #include "orte_config.h"
32 
33 #ifdef HAVE_STDINT_h
34 #include <stdint.h>
35 #endif
36 
37 #include "orte/types.h"
38 
39 #include "opal/class/opal_list.h"
40 
41 BEGIN_C_DECLS
42 
43 typedef uint8_t orte_ns_cmp_bitmask_t; /**< Bit mask for comparing process names */
44 #define ORTE_NS_CMP_NONE 0x00
45 #define ORTE_NS_CMP_JOBID 0x02
46 #define ORTE_NS_CMP_VPID 0x04
47 #define ORTE_NS_CMP_EPOCH 0x08
48 #define ORTE_NS_CMP_ALL 0x0f
49 #define ORTE_NS_CMP_WILD 0x10
50 
51 /* useful define to print name args in output messages */
52 ORTE_DECLSPEC char* orte_util_print_name_args(const orte_process_name_t *name);
53 #define ORTE_NAME_PRINT(n) \
54  orte_util_print_name_args(n)
55 
56 ORTE_DECLSPEC char* orte_util_print_jobids(const orte_jobid_t job);
57 #define ORTE_JOBID_PRINT(n) \
58  orte_util_print_jobids(n)
59 
60 ORTE_DECLSPEC char* orte_util_print_vpids(const orte_vpid_t vpid);
61 #define ORTE_VPID_PRINT(n) \
62  orte_util_print_vpids(n)
63 
64 #if ORTE_ENABLE_EPOCH
65 ORTE_DECLSPEC char* orte_util_print_epoch(const orte_epoch_t epoch);
66 #define ORTE_EPOCH_PRINT(n) \
67  orte_util_print_epoch(n)
68 #else
69 #define ORTE_EPOCH_PRINT(n) ""
70 #endif
71 
72 ORTE_DECLSPEC char* orte_util_print_job_family(const orte_jobid_t job);
73 #define ORTE_JOB_FAMILY_PRINT(n) \
74  orte_util_print_job_family(n)
75 
76 ORTE_DECLSPEC char* orte_util_print_local_jobid(const orte_jobid_t job);
77 #define ORTE_LOCAL_JOBID_PRINT(n) \
78  orte_util_print_local_jobid(n)
79 
80 ORTE_DECLSPEC char *orte_pretty_print_timing(int64_t secs, int64_t usecs);
81 
82 /* a macro for identifying the job family - i.e., for
83  * extracting the mpirun-specific id field of the jobid
84  */
85 #define ORTE_JOB_FAMILY(n) \
86  (((n) >> 16) & 0x0000ffff)
87 
88 /* a macro for discovering the HNP name of a proc given its jobid */
89 #define ORTE_HNP_NAME_FROM_JOB(n, job) \
90  do { \
91  (n)->jobid = (job) & 0xffff0000; \
92  (n)->vpid = 0; \
93  } while(0);
94 
95 /* a macro for extracting the local jobid from the jobid - i.e.,
96  * the non-mpirun-specific id field of the jobid
97  */
98 #define ORTE_LOCAL_JOBID(n) \
99  ( (n) & 0x0000ffff)
100 
101 #define ORTE_CONSTRUCT_JOB_FAMILY(n) \
102  ( ((n) << 16) & 0xffff0000)
103 
104 #define ORTE_CONSTRUCT_LOCAL_JOBID(local, job) \
105  ( ((local) & 0xffff0000) | ((job) & 0x0000ffff) )
106 
107 /* a macro for identifying that a proc is a daemon */
108 #define ORTE_JOBID_IS_DAEMON(n) \
109  !((n) & 0x0000ffff)
110 
111 /* Macro for getting the epoch out of the process name */
112 #if ORTE_ENABLE_EPOCH
113 #define ORTE_EPOCH_GET(n) \
114  ((n)->epoch)
115 #else
116 #define ORTE_EPOCH_GET(n) 0
117 #endif
118 
119 /* Macro for setting the epoch in the process name */
120 #if ORTE_ENABLE_EPOCH
121 #define ORTE_EPOCH_SET(n,m) \
122  ( (n) = (m) )
123 #else
124 #define ORTE_EPOCH_SET(n,m) \
125  do { \
126  } while(0);
127 #endif
128 
129 /* List of names for general use */
131  opal_list_item_t item; /**< Allows this item to be placed on a list */
132  orte_process_name_t name; /**< Name of a process */
133 };
134 typedef struct orte_namelist_t orte_namelist_t;
135 
137 
138 ORTE_DECLSPEC int orte_util_convert_jobid_to_string(char **jobid_string, const orte_jobid_t jobid);
139 ORTE_DECLSPEC int orte_util_convert_string_to_jobid(orte_jobid_t *jobid, const char* jobidstring);
140 ORTE_DECLSPEC int orte_util_convert_vpid_to_string(char **vpid_string, const orte_vpid_t vpid);
141 ORTE_DECLSPEC int orte_util_convert_string_to_vpid(orte_vpid_t *vpid, const char* vpidstring);
142 #if ORTE_ENABLE_EPOCH
143 ORTE_DECLSPEC int orte_util_convert_epoch_to_string(char **epoch_string, const orte_epoch_t epoch);
144 ORTE_DECLSPEC int orte_util_convert_string_to_epoch(orte_vpid_t *epoch, const char* epochstring);
145 #endif
147  const char* name_string);
148 ORTE_DECLSPEC int orte_util_convert_process_name_to_string(char** name_string,
149  const orte_process_name_t *name);
150 #if ORTE_ENABLE_EPOCH
151 ORTE_DECLSPEC int orte_util_create_process_name(orte_process_name_t **name,
152  orte_jobid_t job,
153  orte_vpid_t vpid,
154  orte_epoch_t epoch);
155 #else
156 ORTE_DECLSPEC int orte_util_create_process_name(orte_process_name_t **name,
157  orte_jobid_t job,
158  orte_vpid_t vpid);
159 #endif
160 ORTE_DECLSPEC int orte_util_compare_name_fields(orte_ns_cmp_bitmask_t fields,
161  const orte_process_name_t* name1,
162  const orte_process_name_t* name2);
163 /** This funtion returns a guaranteed unique hash value for the passed process name */
164 ORTE_DECLSPEC uint64_t orte_util_hash_name(const orte_process_name_t * name);
165 ORTE_DECLSPEC int orte_util_convert_string_to_sysinfo(char **cpu_type, char **cpu_model,
166  const char* sysinfo_string);
167 ORTE_DECLSPEC int orte_util_convert_sysinfo_to_string(char** sysinfo_string,
168  const char *cpu_model, const char *cpu_type);
169 
170 END_C_DECLS
171 #endif
uint32_t orte_jobid_t
Set the allowed range for ids in each space.
Definition: types.h:76
Definition: types.h:146
orte_process_name_t name
Name of a process.
Definition: name_fns.h:132
opal_list_item_t item
Allows this item to be placed on a list.
Definition: name_fns.h:131
BEGIN_C_DECLS typedef uint8_t orte_ns_cmp_bitmask_t
Bit mask for comparing process names.
Definition: name_fns.h:43
The opal_list_t interface is used to provide a generic doubly-linked list container for Open MPI...
Definition: opal_list.h:98
ORTE_DECLSPEC int orte_util_convert_string_to_jobid(orte_jobid_t *jobid, const char *jobidstring)
Definition: name_fns.c:343
ORTE_DECLSPEC int orte_util_convert_string_to_process_name(orte_process_name_t *name, const char *name_string)
Definition: name_fns.c:465
ORTE_DECLSPEC uint64_t orte_util_hash_name(const orte_process_name_t *name)
This funtion returns a guaranteed unique hash value for the passed process name.
Definition: name_fns.c:705
ORTE_DECLSPEC int orte_util_convert_string_to_vpid(orte_vpid_t *vpid, const char *vpidstring)
Definition: name_fns.c:391
ORTE_DECLSPEC int orte_util_convert_string_to_sysinfo(char **cpu_type, char **cpu_model, const char *sysinfo_string)
Definition: name_fns.c:718
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236
Definition: name_fns.h:130