Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 1 | /* |
Jonathan Peyton | de4749b | 2016-12-14 23:01:24 +0000 | [diff] [blame] | 2 | * kmp_version.cpp |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 3 | */ |
| 4 | |
| 5 | |
| 6 | //===----------------------------------------------------------------------===// |
| 7 | // |
| 8 | // The LLVM Compiler Infrastructure |
| 9 | // |
| 10 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 11 | // Source Licenses. See LICENSE.txt for details. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | |
| 16 | #include "kmp.h" |
| 17 | #include "kmp_io.h" |
| 18 | #include "kmp_version.h" |
| 19 | |
| 20 | // Replace with snapshot date YYYYMMDD for promotion build. |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 21 | #define KMP_VERSION_BUILD 20140926 |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 22 | |
| 23 | // Helper macros to convert value of macro to string literal. |
| 24 | #define _stringer( x ) #x |
| 25 | #define stringer( x ) _stringer( x ) |
| 26 | |
| 27 | // Detect compiler. |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 28 | #if KMP_COMPILER_ICC |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 29 | #if __INTEL_COMPILER == 1010 |
| 30 | #define KMP_COMPILER "Intel C++ Compiler 10.1" |
| 31 | #elif __INTEL_COMPILER == 1100 |
| 32 | #define KMP_COMPILER "Intel C++ Compiler 11.0" |
| 33 | #elif __INTEL_COMPILER == 1110 |
| 34 | #define KMP_COMPILER "Intel C++ Compiler 11.1" |
| 35 | #elif __INTEL_COMPILER == 1200 |
| 36 | #define KMP_COMPILER "Intel C++ Compiler 12.0" |
| 37 | #elif __INTEL_COMPILER == 1210 |
| 38 | #define KMP_COMPILER "Intel C++ Compiler 12.1" |
| 39 | #elif __INTEL_COMPILER == 1300 |
| 40 | #define KMP_COMPILER "Intel C++ Compiler 13.0" |
| 41 | #elif __INTEL_COMPILER == 1310 |
| 42 | #define KMP_COMPILER "Intel C++ Compiler 13.1" |
| 43 | #elif __INTEL_COMPILER == 1400 |
| 44 | #define KMP_COMPILER "Intel C++ Compiler 14.0" |
| 45 | #elif __INTEL_COMPILER == 1410 |
| 46 | #define KMP_COMPILER "Intel C++ Compiler 14.1" |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 47 | #elif __INTEL_COMPILER == 1500 |
| 48 | #define KMP_COMPILER "Intel C++ Compiler 15.0" |
Jonathan Peyton | 3bb3e09 | 2015-08-12 19:48:31 +0000 | [diff] [blame] | 49 | #elif __INTEL_COMPILER == 1600 |
| 50 | #define KMP_COMPILER "Intel C++ Compiler 16.0" |
Andrey Churbanov | 50ecf5d | 2016-07-08 15:23:35 +0000 | [diff] [blame] | 51 | #elif __INTEL_COMPILER == 1700 |
| 52 | #define KMP_COMPILER "Intel C++ Compiler 17.0" |
| 53 | #elif __INTEL_COMPILER == 9998 |
| 54 | #define KMP_COMPILER "Intel C++ Compiler mainline" |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 55 | #elif __INTEL_COMPILER == 9999 |
| 56 | #define KMP_COMPILER "Intel C++ Compiler mainline" |
| 57 | #endif |
Jim Cownie | 181b4bb | 2013-12-23 17:28:57 +0000 | [diff] [blame] | 58 | #elif KMP_COMPILER_CLANG |
| 59 | #define KMP_COMPILER "Clang " stringer( __clang_major__ ) "." stringer( __clang_minor__ ) |
| 60 | #elif KMP_COMPILER_GCC |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 61 | #define KMP_COMPILER "GCC " stringer( __GNUC__ ) "." stringer( __GNUC_MINOR__ ) |
Jim Cownie | 3b81ce6 | 2014-08-05 09:32:28 +0000 | [diff] [blame] | 62 | #elif KMP_COMPILER_MSVC |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 63 | #define KMP_COMPILER "MSVC " stringer( _MSC_FULL_VER ) |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 64 | #endif |
| 65 | #ifndef KMP_COMPILER |
| 66 | #warning "Unknown compiler" |
| 67 | #define KMP_COMPILER "unknown compiler" |
| 68 | #endif |
| 69 | |
| 70 | // Detect librray type (perf, stub). |
| 71 | #ifdef KMP_STUB |
| 72 | #define KMP_LIB_TYPE "stub" |
| 73 | #else |
| 74 | #define KMP_LIB_TYPE "performance" |
| 75 | #endif // KMP_LIB_TYPE |
| 76 | |
| 77 | // Detect link type (static, dynamic). |
Jonathan Peyton | 9901699 | 2015-05-26 17:32:53 +0000 | [diff] [blame] | 78 | #ifdef KMP_DYNAMIC_LIB |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 79 | #define KMP_LINK_TYPE "dynamic" |
| 80 | #else |
| 81 | #define KMP_LINK_TYPE "static" |
| 82 | #endif // KMP_LINK_TYPE |
| 83 | |
| 84 | // Finally, define strings. |
| 85 | #define KMP_LIBRARY KMP_LIB_TYPE " library (" KMP_LINK_TYPE ")" |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 86 | #define KMP_COPYRIGHT "" |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 87 | |
| 88 | int const __kmp_version_major = KMP_VERSION_MAJOR; |
| 89 | int const __kmp_version_minor = KMP_VERSION_MINOR; |
| 90 | int const __kmp_version_build = KMP_VERSION_BUILD; |
| 91 | int const __kmp_openmp_version = |
Jonathan Peyton | e844a54 | 2017-03-06 22:07:40 +0000 | [diff] [blame] | 92 | #if OMP_50_ENABLED |
| 93 | 201611; |
| 94 | #elif OMP_45_ENABLED |
Jonathan Peyton | 74f3ffc | 2016-09-30 15:50:14 +0000 | [diff] [blame] | 95 | 201511; |
| 96 | #elif OMP_40_ENABLED |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 97 | 201307; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 98 | #else |
Jim Cownie | 4cc4bb4 | 2014-10-07 16:25:50 +0000 | [diff] [blame] | 99 | 201107; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 100 | #endif |
| 101 | |
| 102 | /* Do NOT change the format of this string! Intel(R) Thread Profiler checks for a |
| 103 | specific format some changes in the recognition routine there need to |
| 104 | be made before this is changed. |
| 105 | */ |
| 106 | char const __kmp_copyright[] = |
| 107 | KMP_VERSION_PREFIX KMP_LIBRARY |
| 108 | " ver. " stringer( KMP_VERSION_MAJOR ) "." stringer( KMP_VERSION_MINOR ) |
| 109 | "." stringer( KMP_VERSION_BUILD ) " " |
| 110 | KMP_COPYRIGHT; |
| 111 | |
| 112 | char const __kmp_version_copyright[] = KMP_VERSION_PREFIX KMP_COPYRIGHT; |
| 113 | char const __kmp_version_lib_ver[] = KMP_VERSION_PREFIX "version: " stringer( KMP_VERSION_MAJOR ) "." stringer( KMP_VERSION_MINOR ) "." stringer( KMP_VERSION_BUILD ); |
| 114 | char const __kmp_version_lib_type[] = KMP_VERSION_PREFIX "library type: " KMP_LIB_TYPE; |
| 115 | char const __kmp_version_link_type[] = KMP_VERSION_PREFIX "link type: " KMP_LINK_TYPE; |
Hans Wennborg | 59162da | 2016-01-14 23:18:20 +0000 | [diff] [blame] | 116 | char const __kmp_version_build_time[] = KMP_VERSION_PREFIX "build time: " "no_timestamp"; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 117 | #if KMP_MIC2 |
| 118 | char const __kmp_version_target_env[] = KMP_VERSION_PREFIX "target environment: MIC2"; |
| 119 | #endif |
| 120 | char const __kmp_version_build_compiler[] = KMP_VERSION_PREFIX "build compiler: " KMP_COMPILER; |
| 121 | |
| 122 | // |
| 123 | // Called at serial initialization time. |
| 124 | // |
| 125 | static int __kmp_version_1_printed = FALSE; |
| 126 | |
| 127 | void |
| 128 | __kmp_print_version_1( void ) |
| 129 | { |
| 130 | if ( __kmp_version_1_printed ) { |
| 131 | return; |
| 132 | }; // if |
| 133 | __kmp_version_1_printed = TRUE; |
| 134 | |
| 135 | #ifndef KMP_STUB |
| 136 | kmp_str_buf_t buffer; |
| 137 | __kmp_str_buf_init( & buffer ); |
| 138 | // Print version strings skipping initial magic. |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 139 | __kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_lib_ver[ KMP_VERSION_MAGIC_LEN ] ); |
| 140 | __kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_lib_type[ KMP_VERSION_MAGIC_LEN ] ); |
| 141 | __kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_link_type[ KMP_VERSION_MAGIC_LEN ] ); |
| 142 | __kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_build_time[ KMP_VERSION_MAGIC_LEN ] ); |
| 143 | #if KMP_MIC |
| 144 | __kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_target_env[ KMP_VERSION_MAGIC_LEN ] ); |
| 145 | #endif |
| 146 | __kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_build_compiler[ KMP_VERSION_MAGIC_LEN ] ); |
| 147 | #if defined(KMP_GOMP_COMPAT) |
| 148 | __kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_alt_comp[ KMP_VERSION_MAGIC_LEN ] ); |
| 149 | #endif /* defined(KMP_GOMP_COMPAT) */ |
| 150 | __kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_omp_api[ KMP_VERSION_MAGIC_LEN ] ); |
| 151 | __kmp_str_buf_print( & buffer, "%sdynamic error checking: %s\n", KMP_VERSION_PREF_STR, ( __kmp_env_consistency_check ? "yes" : "no" ) ); |
| 152 | #ifdef KMP_DEBUG |
| 153 | for ( int i = bs_plain_barrier; i < bs_last_barrier; ++ i ) { |
| 154 | __kmp_str_buf_print( |
| 155 | & buffer, |
| 156 | "%s%s barrier branch bits: gather=%u, release=%u\n", |
| 157 | KMP_VERSION_PREF_STR, |
| 158 | __kmp_barrier_type_name[ i ], |
| 159 | __kmp_barrier_gather_branch_bits[ i ], |
| 160 | __kmp_barrier_release_branch_bits[ i ] |
| 161 | ); // __kmp_str_buf_print |
| 162 | }; // for i |
| 163 | for ( int i = bs_plain_barrier; i < bs_last_barrier; ++ i ) { |
| 164 | __kmp_str_buf_print( |
| 165 | & buffer, |
| 166 | "%s%s barrier pattern: gather=%s, release=%s\n", |
| 167 | KMP_VERSION_PREF_STR, |
| 168 | __kmp_barrier_type_name[ i ], |
| 169 | __kmp_barrier_pattern_name[ __kmp_barrier_gather_pattern[ i ] ], |
| 170 | __kmp_barrier_pattern_name[ __kmp_barrier_release_pattern[ i ] ] |
| 171 | ); // __kmp_str_buf_print |
| 172 | }; // for i |
| 173 | __kmp_str_buf_print( & buffer, "%s\n", & __kmp_version_lock[ KMP_VERSION_MAGIC_LEN ] ); |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 174 | #endif |
| 175 | __kmp_str_buf_print( |
| 176 | & buffer, |
| 177 | "%sthread affinity support: %s\n", |
| 178 | KMP_VERSION_PREF_STR, |
Alp Toker | 763b939 | 2014-02-28 09:42:41 +0000 | [diff] [blame] | 179 | #if KMP_AFFINITY_SUPPORTED |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 180 | ( |
| 181 | KMP_AFFINITY_CAPABLE() |
| 182 | ? |
| 183 | ( |
| 184 | __kmp_affinity_type == affinity_none |
| 185 | ? |
| 186 | "not used" |
| 187 | : |
| 188 | "yes" |
| 189 | ) |
| 190 | : |
| 191 | "no" |
| 192 | ) |
| 193 | #else |
| 194 | "no" |
| 195 | #endif |
| 196 | ); |
| 197 | __kmp_printf( "%s", buffer.str ); |
| 198 | __kmp_str_buf_free( & buffer ); |
| 199 | K_DIAG( 1, ( "KMP_VERSION is true\n" ) ); |
| 200 | #endif // KMP_STUB |
| 201 | } // __kmp_print_version_1 |
| 202 | |
| 203 | // |
| 204 | // Called at parallel initialization time. |
| 205 | // |
| 206 | static int __kmp_version_2_printed = FALSE; |
| 207 | |
| 208 | void |
| 209 | __kmp_print_version_2( void ) { |
| 210 | if ( __kmp_version_2_printed ) { |
| 211 | return; |
| 212 | }; // if |
| 213 | __kmp_version_2_printed = TRUE; |
Jim Cownie | 5e8470a | 2013-09-27 10:38:44 +0000 | [diff] [blame] | 214 | } // __kmp_print_version_2 |
| 215 | |
| 216 | // end of file // |