1 /* -*- C -*- 2 * 3 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana 4 * University Research and Technology 5 * Corporation. All rights reserved. 6 * Copyright (c) 2004-2006 The University of Tennessee and The University 7 * of Tennessee Research Foundation. All rights 8 * reserved. 9 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 10 * University of Stuttgart. All rights reserved. 11 * Copyright (c) 2004-2005 The Regents of the University of California. 12 * All rights reserved. 13 * Copyright (c) 2007-2011 Cisco Systems, Inc. All rights reserved. 14 * Copyright (c) 2012-2013 Los Alamos National Security, Inc. All rights 15 * reserved. 16 * Copyright (c) 2014-2016 Research Organization for Information Science 17 * and Technology (RIST). All rights reserved. 18 * Copyright (c) 2014-2018 Intel, Inc. All rights reserved. 19 * $COPYRIGHT$ 20 * 21 * Additional copyrights may follow 22 * 23 * $HEADER$ 24 */ 25 /** 26 * @file 27 * 28 * Buffer management types. 29 */ 30 31 #ifndef OPAL_DSS_TYPES_H_ 32 #define OPAL_DSS_TYPES_H_ 33 34 #include "opal_config.h" 35 36 #ifdef HAVE_SYS_TIME_H 37 #include <sys/time.h> /* for struct timeval */ 38 #endif 39 40 #include "opal/class/opal_object.h" 41 #include "opal/class/opal_pointer_array.h" 42 #include "opal/class/opal_list.h" 43 44 typedef uint32_t opal_jobid_t; 45 typedef uint32_t opal_vpid_t; 46 typedef struct { 47 opal_jobid_t jobid; 48 opal_vpid_t vpid; 49 } opal_process_name_t; 50 #define OPAL_SIZEOF_PROCESS_NAME_T 8 51 52 BEGIN_C_DECLS 53 54 typedef uint8_t opal_data_type_t; /** data type indicators */ 55 #define OPAL_DATA_TYPE_T OPAL_UINT8 56 #define OPAL_DSS_ID_MAX UINT8_MAX 57 #define OPAL_DSS_ID_INVALID OPAL_DSS_ID_MAX 58 59 /* define a structure to hold generic byte objects */ 60 typedef struct { 61 int32_t size; 62 uint8_t *bytes; 63 } opal_byte_object_t; 64 65 /* Type defines for packing and unpacking */ 66 #define OPAL_UNDEF (opal_data_type_t) 0 /**< type hasn't been defined yet */ 67 #define OPAL_BYTE (opal_data_type_t) 1 /**< a byte of data */ 68 #define OPAL_BOOL (opal_data_type_t) 2 /**< boolean */ 69 #define OPAL_STRING (opal_data_type_t) 3 /**< a NULL terminated string */ 70 #define OPAL_SIZE (opal_data_type_t) 4 /**< the generic size_t */ 71 #define OPAL_PID (opal_data_type_t) 5 /**< process pid */ 72 /* all the integer flavors */ 73 #define OPAL_INT (opal_data_type_t) 6 /**< generic integer */ 74 #define OPAL_INT8 (opal_data_type_t) 7 /**< an 8-bit integer */ 75 #define OPAL_INT16 (opal_data_type_t) 8 /**< a 16-bit integer */ 76 #define OPAL_INT32 (opal_data_type_t) 9 /**< a 32-bit integer */ 77 #define OPAL_INT64 (opal_data_type_t) 10 /**< a 64-bit integer */ 78 /* all the unsigned integer flavors */ 79 #define OPAL_UINT (opal_data_type_t) 11 /**< generic unsigned integer */ 80 #define OPAL_UINT8 (opal_data_type_t) 12 /**< an 8-bit unsigned integer */ 81 #define OPAL_UINT16 (opal_data_type_t) 13 /**< a 16-bit unsigned integer */ 82 #define OPAL_UINT32 (opal_data_type_t) 14 /**< a 32-bit unsigned integer */ 83 #define OPAL_UINT64 (opal_data_type_t) 15 /**< a 64-bit unsigned integer */ 84 /* floating point types */ 85 #define OPAL_FLOAT (opal_data_type_t) 16 86 #define OPAL_DOUBLE (opal_data_type_t) 17 87 /* system types */ 88 #define OPAL_TIMEVAL (opal_data_type_t) 18 89 #define OPAL_TIME (opal_data_type_t) 19 90 /* OPAL types */ 91 #define OPAL_BYTE_OBJECT (opal_data_type_t) 20 /**< byte object structure */ 92 #define OPAL_DATA_TYPE (opal_data_type_t) 21 /**< data type */ 93 #define OPAL_NULL (opal_data_type_t) 22 /**< don't interpret data type */ 94 #define OPAL_PSTAT (opal_data_type_t) 23 /**< process statistics */ 95 #define OPAL_NODE_STAT (opal_data_type_t) 24 /**< node statistics */ 96 #define OPAL_HWLOC_TOPO (opal_data_type_t) 25 /**< hwloc topology */ 97 #define OPAL_VALUE (opal_data_type_t) 26 /**< opal value structure */ 98 #define OPAL_BUFFER (opal_data_type_t) 27 /**< pack the remaining contents of a buffer as an object */ 99 #define OPAL_PTR (opal_data_type_t) 28 /**< pointer to void* */ 100 #define OPAL_NAME (opal_data_type_t) 29 101 #define OPAL_JOBID (opal_data_type_t) 30 102 #define OPAL_VPID (opal_data_type_t) 31 103 #define OPAL_STATUS (opal_data_type_t) 32 104 #define OPAL_PERSIST (opal_data_type_t) 33 /**< corresponds to PMIx persistence type (uint8_t) */ 105 #define OPAL_SCOPE (opal_data_type_t) 34 /**< corresponds to PMIx scope type (uint8_t) */ 106 #define OPAL_DATA_RANGE (opal_data_type_t) 35 /**< corresponds to PMIx data range type (uint8_t) */ 107 #define OPAL_INFO_DIRECTIVES (opal_data_type_t) 36 /**< corresponds to PMIx info directives type (uint32_t) */ 108 #define OPAL_PROC_STATE (opal_data_type_t) 37 /**< corresponds to PMIx proc state type (uint8_t) */ 109 #define OPAL_PROC_INFO (opal_data_type_t) 38 /**< corresponds to PMIx proc_info type */ 110 #define OPAL_ENVAR (opal_data_type_t) 39 /**< corresponds to PMIx envar type */ 111 112 /* OPAL Dynamic */ 113 #define OPAL_DSS_ID_DYNAMIC (opal_data_type_t) 100 114 115 /* define the results values for comparisons so we can change them in only one place */ 116 #define OPAL_VALUE1_GREATER +1 117 #define OPAL_VALUE2_GREATER -1 118 #define OPAL_EQUAL 0 119 120 /* define some types so we can store the generic 121 * values and still *know* how to convert it for PMIx */ 122 typedef int opal_status_t; 123 typedef uint32_t opal_proc_state_t; 124 125 /* define an opal_proc_info_t for transferring info to/from PMIx */ 126 typedef struct { 127 opal_list_item_t super; 128 opal_process_name_t name; 129 char *hostname; 130 char *executable_name; 131 pid_t pid; 132 opal_status_t exit_code; 133 opal_proc_state_t state; 134 } opal_proc_info_t; 135 OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_proc_info_t); 136 137 /* defaine a struct for envar directives */ 138 typedef struct { 139 opal_list_item_t super; 140 char *envar; 141 char *value; 142 char separator; 143 } opal_envar_t; 144 OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_envar_t); 145 146 /* Data value object */ 147 typedef struct { 148 opal_list_item_t super; /* required for this to be on lists */ 149 char *key; /* key string */ 150 opal_data_type_t type; /* the type of value stored */ 151 union { 152 bool flag; 153 uint8_t byte; 154 char *string; 155 size_t size; 156 pid_t pid; 157 int integer; 158 int8_t int8; 159 int16_t int16; 160 int32_t int32; 161 int64_t int64; 162 unsigned int uint; 163 uint8_t uint8; 164 uint16_t uint16; 165 uint32_t uint32; 166 uint64_t uint64; 167 opal_byte_object_t bo; 168 float fval; 169 double dval; 170 struct timeval tv; 171 time_t time; 172 opal_status_t status; 173 opal_process_name_t name; 174 opal_proc_info_t pinfo; 175 void *ptr; // never packed or passed anywhere 176 opal_envar_t envar; 177 } data; 178 } opal_value_t; 179 OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_value_t); 180 181 /* Process statistics object */ 182 #define OPAL_PSTAT_MAX_STRING_LEN 32 183 typedef struct { 184 opal_list_item_t super; /* required for this to be on a list */ 185 /* process ident info */ 186 char node[OPAL_PSTAT_MAX_STRING_LEN]; 187 int32_t rank; 188 pid_t pid; 189 char cmd[OPAL_PSTAT_MAX_STRING_LEN]; 190 /* process stats */ 191 char state[2]; 192 struct timeval time; 193 float percent_cpu; 194 int32_t priority; 195 int16_t num_threads; 196 float pss; /* in MBytes */ 197 float vsize; /* in MBytes */ 198 float rss; /* in MBytes */ 199 float peak_vsize; /* in MBytes */ 200 int16_t processor; 201 /* time at which sample was taken */ 202 struct timeval sample_time; 203 } opal_pstats_t; 204 OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_pstats_t); 205 typedef struct { 206 opal_list_item_t super; 207 char *disk; 208 unsigned long num_reads_completed; 209 unsigned long num_reads_merged; 210 unsigned long num_sectors_read; 211 unsigned long milliseconds_reading; 212 unsigned long num_writes_completed; 213 unsigned long num_writes_merged; 214 unsigned long num_sectors_written; 215 unsigned long milliseconds_writing; 216 unsigned long num_ios_in_progress; 217 unsigned long milliseconds_io; 218 unsigned long weighted_milliseconds_io; 219 } opal_diskstats_t; 220 OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_diskstats_t); 221 typedef struct { 222 opal_list_item_t super; 223 char *net_interface; 224 unsigned long num_bytes_recvd; 225 unsigned long num_packets_recvd; 226 unsigned long num_recv_errs; 227 unsigned long num_bytes_sent; 228 unsigned long num_packets_sent; 229 unsigned long num_send_errs; 230 } opal_netstats_t; 231 OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_netstats_t); 232 typedef struct { 233 opal_object_t super; 234 /* node-level load averages */ 235 float la; 236 float la5; 237 float la15; 238 /* memory usage */ 239 float total_mem; /* in MBytes */ 240 float free_mem; /* in MBytes */ 241 float buffers; /* in MBytes */ 242 float cached; /* in MBytes */ 243 float swap_cached; /* in MBytes */ 244 float swap_total; /* in MBytes */ 245 float swap_free; /* in MBytes */ 246 float mapped; /* in MBytes */ 247 /* time at which sample was taken */ 248 struct timeval sample_time; 249 /* list of disk stats, one per disk */ 250 opal_list_t diskstats; 251 /* list of net stats, one per interface */ 252 opal_list_t netstats; 253 254 } opal_node_stats_t; 255 OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_node_stats_t); 256 257 /* structured-unstructured data flags */ 258 #define OPAL_DSS_STRUCTURED true 259 #define OPAL_DSS_UNSTRUCTURED false 260 261 /** 262 * buffer type 263 */ 264 enum opal_dss_buffer_type_t { 265 OPAL_DSS_BUFFER_NON_DESC = 0x00, 266 OPAL_DSS_BUFFER_FULLY_DESC = 0x01 267 }; 268 269 typedef enum opal_dss_buffer_type_t opal_dss_buffer_type_t; 270 271 #define OPAL_DSS_BUFFER_TYPE_HTON(h); 272 #define OPAL_DSS_BUFFER_TYPE_NTOH(h); 273 274 /** 275 * Structure for holding a buffer to be used with the RML or OOB 276 * subsystems. 277 */ 278 struct opal_buffer_t { 279 /** First member must be the object's parent */ 280 opal_object_t parent; 281 /** type of buffer */ 282 opal_dss_buffer_type_t type; 283 /** Start of my memory */ 284 char *base_ptr; 285 /** Where the next data will be packed to (within the allocated 286 memory starting at base_ptr) */ 287 char *pack_ptr; 288 /** Where the next data will be unpacked from (within the 289 allocated memory starting as base_ptr) */ 290 char *unpack_ptr; 291 292 /** Number of bytes allocated (starting at base_ptr) */ 293 size_t bytes_allocated; 294 /** Number of bytes used by the buffer (i.e., amount of data -- 295 including overhead -- packed in the buffer) */ 296 size_t bytes_used; 297 }; 298 /** 299 * Convenience typedef 300 */ 301 typedef struct opal_buffer_t opal_buffer_t; 302 303 /** formalize the declaration */ 304 OPAL_DECLSPEC OBJ_CLASS_DECLARATION (opal_buffer_t); 305 306 END_C_DECLS 307 308 #endif /* OPAL_DSS_TYPES_H */ 309