| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************/ | ||
| 2 | /* Copyright 2009-2024 Barcelona Supercomputing Center */ | ||
| 3 | /* */ | ||
| 4 | /* This file is part of the DLB library. */ | ||
| 5 | /* */ | ||
| 6 | /* DLB is free software: you can redistribute it and/or modify */ | ||
| 7 | /* it under the terms of the GNU Lesser General Public License as published by */ | ||
| 8 | /* the Free Software Foundation, either version 3 of the License, or */ | ||
| 9 | /* (at your option) any later version. */ | ||
| 10 | /* */ | ||
| 11 | /* DLB is distributed in the hope that it will be useful, */ | ||
| 12 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | ||
| 13 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | ||
| 14 | /* GNU Lesser General Public License for more details. */ | ||
| 15 | /* */ | ||
| 16 | /* You should have received a copy of the GNU Lesser General Public License */ | ||
| 17 | /* along with DLB. If not, see <https://www.gnu.org/licenses/>. */ | ||
| 18 | /*********************************************************************************/ | ||
| 19 | |||
| 20 | #ifndef TYPES_H | ||
| 21 | #define TYPES_H | ||
| 22 | |||
| 23 | #ifdef HAVE_CONFIG_H | ||
| 24 | #include <config.h> | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #include <inttypes.h> | ||
| 28 | #include <stdbool.h> | ||
| 29 | #include <stdint.h> | ||
| 30 | |||
| 31 | #if NCPUS_AT_CONFIGURE_TIME <= 255 | ||
| 32 | typedef uint8_t cpuid_t; | ||
| 33 | enum { DLB_CPUID_INVALID = UINT8_MAX }; | ||
| 34 | #define PRICPUID PRIu8 | ||
| 35 | #else | ||
| 36 | typedef uint16_t cpuid_t; | ||
| 37 | enum { DLB_CPUID_INVALID = UINT16_MAX }; | ||
| 38 | #define PRICPUID PRIu16 | ||
| 39 | #endif | ||
| 40 | |||
| 41 | typedef enum VerboseOptions { | ||
| 42 | VB_CLEAR = 0, | ||
| 43 | VB_API = 1 << 0, | ||
| 44 | VB_MICROLB = 1 << 1, | ||
| 45 | VB_SHMEM = 1 << 2, | ||
| 46 | VB_MPI_API = 1 << 3, | ||
| 47 | VB_MPI_INT = 1 << 4, | ||
| 48 | VB_STATS = 1 << 5, | ||
| 49 | VB_DROM = 1 << 6, | ||
| 50 | VB_ASYNC = 1 << 7, | ||
| 51 | VB_OMPT = 1 << 8, | ||
| 52 | VB_AFFINITY = 1 << 9, | ||
| 53 | VB_BARRIER = 1 << 10, | ||
| 54 | VB_TALP = 1 << 11, | ||
| 55 | VB_INSTR = 1 << 12, | ||
| 56 | VB_ALL = 0xFFFF, | ||
| 57 | VB_UNDEF = 0xF0000, | ||
| 58 | } verbose_opts_t; | ||
| 59 | |||
| 60 | typedef enum VerboseFormat { | ||
| 61 | VBF_CLEAR = 0, | ||
| 62 | VBF_NODE = 1 << 0, | ||
| 63 | VBF_MPINODE = 1 << 1, | ||
| 64 | VBF_MPIRANK = 1 << 2, | ||
| 65 | VBF_SPID = 1 << 3, | ||
| 66 | VBF_THREAD = 1 << 4, | ||
| 67 | VBF_TSTAMP = 1 << 5 | ||
| 68 | } verbose_fmt_t; | ||
| 69 | |||
| 70 | typedef enum InstrumentItems { | ||
| 71 | INST_NONE = 0, | ||
| 72 | INST_ALL = 0xFFFF, | ||
| 73 | INST_MPI = 1 << 0, | ||
| 74 | INST_LEWI = 1 << 1, | ||
| 75 | INST_DROM = 1 << 2, | ||
| 76 | INST_TALP = 1 << 3, | ||
| 77 | INST_BARR = 1 << 4, | ||
| 78 | INST_OMPT = 1 << 5, | ||
| 79 | INST_CPUS = 1 << 6, | ||
| 80 | INST_CBCK = 1 << 7 | ||
| 81 | } instrument_items_t; | ||
| 82 | |||
| 83 | typedef enum DebugOptions { | ||
| 84 | DBG_CLEAR = 0, | ||
| 85 | DBG_RETURNSTOLEN = 1 << 0, | ||
| 86 | DBG_WERROR = 1 << 1, | ||
| 87 | DBG_LPOSTMORTEM = 1 << 2, | ||
| 88 | DBG_WARNMPI = 1 << 3, | ||
| 89 | } debug_opts_t; | ||
| 90 | |||
| 91 | typedef enum LewiAffinity { | ||
| 92 | LEWI_AFFINITY_AUTO, | ||
| 93 | LEWI_AFFINITY_NONE, | ||
| 94 | LEWI_AFFINITY_MASK, | ||
| 95 | LEWI_AFFINITY_NEARBY_FIRST, | ||
| 96 | LEWI_AFFINITY_NEARBY_ONLY, | ||
| 97 | LEWI_AFFINITY_SPREAD_IFEMPTY, | ||
| 98 | } lewi_affinity_t; | ||
| 99 | |||
| 100 | typedef enum TalpSummaryType { | ||
| 101 | SUMMARY_NONE = 0, | ||
| 102 | SUMMARY_ALL = 0xFFF9, // SUMMARY_POP_RAW and SUMMARY_NODE excluded | ||
| 103 | SUMMARY_POP_METRICS = 1 << 0, | ||
| 104 | SUMMARY_POP_RAW = 1 << 1, // DEPRECATED | ||
| 105 | SUMMARY_NODE = 1 << 2, // DEPRECATED | ||
| 106 | SUMMARY_PROCESS = 1 << 3, | ||
| 107 | } talp_summary_t; | ||
| 108 | |||
| 109 | typedef enum TalpModel { | ||
| 110 | TALP_MODEL_HYBRID_V1, | ||
| 111 | TALP_MODEL_HYBRID_V2, | ||
| 112 | } talp_model_t; | ||
| 113 | |||
| 114 | typedef enum PolicyType { | ||
| 115 | POLICY_NONE, | ||
| 116 | POLICY_LEWI, | ||
| 117 | POLICY_LEWI_ASYNC, | ||
| 118 | POLICY_LEWI_MASK, | ||
| 119 | } policy_t; | ||
| 120 | |||
| 121 | typedef enum InteractionMode { | ||
| 122 | MODE_POLLING, | ||
| 123 | MODE_ASYNC | ||
| 124 | } interaction_mode_t; | ||
| 125 | |||
| 126 | typedef enum MPISet { | ||
| 127 | MPISET_NONE, | ||
| 128 | MPISET_ALL, | ||
| 129 | MPISET_BARRIER, | ||
| 130 | MPISET_COLLECTIVES | ||
| 131 | } mpi_set_t; | ||
| 132 | |||
| 133 | typedef enum OMPTOptions { | ||
| 134 | OMPTOOL_OPTS_NONE = 0, | ||
| 135 | /* OMPTOOL_OPTS_MPI = 1 << 0, DEPRECATED */ | ||
| 136 | OMPTOOL_OPTS_BORROW = 1 << 1, | ||
| 137 | OMPTOOL_OPTS_LEND = 1 << 2, | ||
| 138 | /* OMPTOOL_OPTS_AGGRESSIVE = 0xF DEPRECATED */ | ||
| 139 | } omptool_opts_t; | ||
| 140 | |||
| 141 | typedef enum OMPTMVersion { | ||
| 142 | OMPTM_NONE, | ||
| 143 | OMPTM_OMP5, | ||
| 144 | OMPTM_FREE_AGENTS, | ||
| 145 | OMPTM_ROLE_SHIFT | ||
| 146 | } omptm_version_t; | ||
| 147 | |||
| 148 | 8 | static inline int min_int(int a, int b) { return a < b ? a : b; } | |
| 149 | 16749 | static inline int max_int(int a, int b) { return a > b ? a : b; } | |
| 150 | 3 | static inline int64_t min_int64(int64_t a, int64_t b) { return a < b ? a : b; } | |
| 151 | 14 | static inline int64_t max_int64(int64_t a, int64_t b) { return a > b ? a : b; } | |
| 152 | 295 | static inline unsigned int min_uint(unsigned int a, unsigned int b) { return a < b ? a : b; } | |
| 153 | static inline double min_double(double a, double b) { return a < b ? a : b; } | ||
| 154 | static inline double max_double(double a, double b) { return a > b ? a : b; } | ||
| 155 | |||
| 156 | static inline double min_double_non_zero(double a, double b) { | ||
| 157 | if (a == 0.0 && b == 0.0) { | ||
| 158 | return 0.0; | ||
| 159 | } else if (a == 0.0) { | ||
| 160 | return b; | ||
| 161 | } else if (b == 0.0) { | ||
| 162 | return a; | ||
| 163 | } else { | ||
| 164 | return min_double(a, b); | ||
| 165 | } | ||
| 166 | } | ||
| 167 | |||
| 168 | int parse_bool(const char *str, bool *value); | ||
| 169 | bool equivalent_bool(const char *str1, const char *str2); | ||
| 170 | |||
| 171 | int parse_negated_bool(const char *str, bool *value); | ||
| 172 | bool equivalent_negated_bool(const char *str1, const char *str2); | ||
| 173 | |||
| 174 | int parse_int(const char *str, int *value); | ||
| 175 | bool equivalent_int(const char *str1, const char *str2); | ||
| 176 | |||
| 177 | /* verbose_opts_t */ | ||
| 178 | int parse_verbose_opts(const char *str, verbose_opts_t *value); | ||
| 179 | const char* verbose_opts_tostr(verbose_opts_t value); | ||
| 180 | const char* get_verbose_opts_choices(void); | ||
| 181 | bool equivalent_verbose_opts(const char *str1, const char *str2); | ||
| 182 | |||
| 183 | /* verbose_fmt_t */ | ||
| 184 | int parse_verbose_fmt(const char *str, verbose_fmt_t *value); | ||
| 185 | const char* verbose_fmt_tostr(verbose_fmt_t value); | ||
| 186 | const char* get_verbose_fmt_choices(void); | ||
| 187 | bool equivalent_verbose_fmt(const char *str1, const char *str2); | ||
| 188 | |||
| 189 | /* instrument_item_t */ | ||
| 190 | int parse_instrument_items(const char *str, instrument_items_t *value); | ||
| 191 | const char* instrument_items_tostr(instrument_items_t value); | ||
| 192 | const char* get_instrument_items_choices(void); | ||
| 193 | bool equivalent_instrument_items(const char *str1, const char *str2); | ||
| 194 | |||
| 195 | /* debug_opts_t */ | ||
| 196 | int parse_debug_opts(const char *str, debug_opts_t *value); | ||
| 197 | const char* debug_opts_tostr(debug_opts_t value); | ||
| 198 | const char* get_debug_opts_choices(void); | ||
| 199 | bool equivalent_debug_opts(const char *str1, const char *str2); | ||
| 200 | |||
| 201 | /* lewi_affinity_t */ | ||
| 202 | int parse_lewi_affinity(const char *str, lewi_affinity_t *value); | ||
| 203 | const char* lewi_affinity_tostr(lewi_affinity_t value); | ||
| 204 | const char* get_lewi_affinity_choices(void); | ||
| 205 | bool equivalent_lewi_affinity(const char *str1, const char *str2); | ||
| 206 | |||
| 207 | /* policy_t */ | ||
| 208 | int parse_policy(const char *str, policy_t *value); | ||
| 209 | const char* policy_tostr(policy_t policy); | ||
| 210 | const char* get_policy_choices(void); | ||
| 211 | bool equivalent_policy(const char *str1, const char *str2); | ||
| 212 | |||
| 213 | /* talp_summary_t */ | ||
| 214 | int parse_talp_summary(const char *str, talp_summary_t *value); | ||
| 215 | const char* talp_summary_tostr(talp_summary_t summary); | ||
| 216 | const char* get_talp_summary_choices(void); | ||
| 217 | bool equivalent_talp_summary(const char *str1, const char *str2); | ||
| 218 | |||
| 219 | /* talp_model_t */ | ||
| 220 | int parse_talp_model(const char *str, talp_model_t *value); | ||
| 221 | const char* talp_model_tostr(talp_model_t value); | ||
| 222 | const char* get_talp_model_choices(void); | ||
| 223 | bool equivalent_talp_model(const char *str1, const char *str2); | ||
| 224 | |||
| 225 | /* interaction_mode_t */ | ||
| 226 | int parse_mode(const char *str, interaction_mode_t *value); | ||
| 227 | const char* mode_tostr(interaction_mode_t value); | ||
| 228 | const char* get_mode_choices(void); | ||
| 229 | bool equivalent_mode(const char *str1, const char *str2); | ||
| 230 | |||
| 231 | /* mpi_set_t */ | ||
| 232 | int parse_mpiset(const char *str, mpi_set_t *value); | ||
| 233 | const char* mpiset_tostr(mpi_set_t value); | ||
| 234 | const char* get_mpiset_choices(void); | ||
| 235 | bool equivalent_mpiset(const char *str1, const char *str2); | ||
| 236 | |||
| 237 | /* omptool_opts_t */ | ||
| 238 | int parse_omptool_opts(const char *str, omptool_opts_t *value); | ||
| 239 | const char* omptool_opts_tostr(omptool_opts_t value); | ||
| 240 | const char* get_omptool_opts_choices(void); | ||
| 241 | bool equivalent_omptool_opts(const char *str1, const char *str2); | ||
| 242 | |||
| 243 | /* omptm_version_t */ | ||
| 244 | int parse_omptm_version(const char *str, omptm_version_t *value); | ||
| 245 | const char* omptm_version_tostr(omptm_version_t value); | ||
| 246 | const char* get_omptm_version_choices(void); | ||
| 247 | bool equivalent_omptm_version_opts(const char *str1, const char *str2); | ||
| 248 | |||
| 249 | #endif /* TYPES_H */ | ||
| 250 |