LLVM OpenMP* Runtime Library
kmp_version.cpp
1 /*
2  * kmp_version.cpp
3  */
4 
5 //===----------------------------------------------------------------------===//
6 //
7 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8 // See https://llvm.org/LICENSE.txt for license information.
9 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "kmp.h"
14 #include "kmp_io.h"
15 #include "kmp_version.h"
16 
17 // Replace with snapshot date YYYYMMDD for promotion build.
18 #define KMP_VERSION_BUILD 20140926
19 
20 // Helper macros to convert value of macro to string literal.
21 #define _stringer(x) #x
22 #define stringer(x) _stringer(x)
23 
24 // Detect compiler.
25 #if KMP_COMPILER_ICC
26 #if __INTEL_COMPILER == 1010
27 #define KMP_COMPILER "Intel(R) C++ Compiler 10.1"
28 #elif __INTEL_COMPILER == 1100
29 #define KMP_COMPILER "Intel(R) C++ Compiler 11.0"
30 #elif __INTEL_COMPILER == 1110
31 #define KMP_COMPILER "Intel(R) C++ Compiler 11.1"
32 #elif __INTEL_COMPILER == 1200
33 #define KMP_COMPILER "Intel(R) C++ Compiler 12.0"
34 #elif __INTEL_COMPILER == 1210
35 #define KMP_COMPILER "Intel(R) C++ Compiler 12.1"
36 #elif __INTEL_COMPILER == 1300
37 #define KMP_COMPILER "Intel(R) C++ Compiler 13.0"
38 #elif __INTEL_COMPILER == 1310
39 #define KMP_COMPILER "Intel(R) C++ Compiler 13.1"
40 #elif __INTEL_COMPILER == 1400
41 #define KMP_COMPILER "Intel(R) C++ Compiler 14.0"
42 #elif __INTEL_COMPILER == 1410
43 #define KMP_COMPILER "Intel(R) C++ Compiler 14.1"
44 #elif __INTEL_COMPILER == 1500
45 #define KMP_COMPILER "Intel(R) C++ Compiler 15.0"
46 #elif __INTEL_COMPILER == 1600
47 #define KMP_COMPILER "Intel(R) C++ Compiler 16.0"
48 #elif __INTEL_COMPILER == 1700
49 #define KMP_COMPILER "Intel(R) C++ Compiler 17.0"
50 #elif __INTEL_COMPILER == 1800
51 #define KMP_COMPILER "Intel(R) C++ Compiler 18.0"
52 #elif __INTEL_COMPILER == 1900
53 #define KMP_COMPILER "Intel(R) C++ Compiler 19.0"
54 #elif __INTEL_COMPILER >= 9900
55 #define KMP_COMPILER "Intel(R) C++ Compiler mainline"
56 #endif
57 #elif KMP_COMPILER_CLANG
58 #define KMP_COMPILER \
59  "Clang " stringer(__clang_major__) "." stringer(__clang_minor__)
60 #elif KMP_COMPILER_GCC
61 #define KMP_COMPILER "GCC " stringer(__GNUC__) "." stringer(__GNUC_MINOR__)
62 #elif KMP_COMPILER_MSVC
63 #define KMP_COMPILER "MSVC " stringer(_MSC_FULL_VER)
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).
78 #if KMP_DYNAMIC_LIB
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 ")"
86 #define KMP_COPYRIGHT ""
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 =
92 #if OMP_50_ENABLED
93  201611;
94 #elif OMP_45_ENABLED
95  201511;
96 #elif OMP_40_ENABLED
97  201307;
98 #else
99  201107;
100 #endif
101 
102 /* Do NOT change the format of this string! Intel(R) Thread Profiler checks for
103  a specific format some changes in the recognition routine there need to be
104  made before this is changed. */
105 char const __kmp_copyright[] = KMP_VERSION_PREFIX KMP_LIBRARY
106  " ver. " stringer(KMP_VERSION_MAJOR) "." stringer(
107  KMP_VERSION_MINOR) "." stringer(KMP_VERSION_BUILD) " " KMP_COPYRIGHT;
108 
109 char const __kmp_version_copyright[] = KMP_VERSION_PREFIX KMP_COPYRIGHT;
110 char const __kmp_version_lib_ver[] =
111  KMP_VERSION_PREFIX "version: " stringer(KMP_VERSION_MAJOR) "." stringer(
112  KMP_VERSION_MINOR) "." stringer(KMP_VERSION_BUILD);
113 char const __kmp_version_lib_type[] =
114  KMP_VERSION_PREFIX "library type: " KMP_LIB_TYPE;
115 char const __kmp_version_link_type[] =
116  KMP_VERSION_PREFIX "link type: " KMP_LINK_TYPE;
117 char const __kmp_version_build_time[] = KMP_VERSION_PREFIX "build time: "
118  "no_timestamp";
119 #if KMP_MIC2
120 char const __kmp_version_target_env[] =
121  KMP_VERSION_PREFIX "target environment: MIC2";
122 #endif
123 char const __kmp_version_build_compiler[] =
124  KMP_VERSION_PREFIX "build compiler: " KMP_COMPILER;
125 
126 // Called at serial initialization time.
127 static int __kmp_version_1_printed = FALSE;
128 
129 void __kmp_print_version_1(void) {
130  if (__kmp_version_1_printed) {
131  return;
132  }
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.
139  __kmp_str_buf_print(&buffer, "%s\n",
140  &__kmp_version_lib_ver[KMP_VERSION_MAGIC_LEN]);
141  __kmp_str_buf_print(&buffer, "%s\n",
142  &__kmp_version_lib_type[KMP_VERSION_MAGIC_LEN]);
143  __kmp_str_buf_print(&buffer, "%s\n",
144  &__kmp_version_link_type[KMP_VERSION_MAGIC_LEN]);
145  __kmp_str_buf_print(&buffer, "%s\n",
146  &__kmp_version_build_time[KMP_VERSION_MAGIC_LEN]);
147 #if KMP_MIC
148  __kmp_str_buf_print(&buffer, "%s\n",
149  &__kmp_version_target_env[KMP_VERSION_MAGIC_LEN]);
150 #endif
151  __kmp_str_buf_print(&buffer, "%s\n",
152  &__kmp_version_build_compiler[KMP_VERSION_MAGIC_LEN]);
153 #if defined(KMP_GOMP_COMPAT)
154  __kmp_str_buf_print(&buffer, "%s\n",
155  &__kmp_version_alt_comp[KMP_VERSION_MAGIC_LEN]);
156 #endif /* defined(KMP_GOMP_COMPAT) */
157  __kmp_str_buf_print(&buffer, "%s\n",
158  &__kmp_version_omp_api[KMP_VERSION_MAGIC_LEN]);
159  __kmp_str_buf_print(&buffer, "%sdynamic error checking: %s\n",
160  KMP_VERSION_PREF_STR,
161  (__kmp_env_consistency_check ? "yes" : "no"));
162 #ifdef KMP_DEBUG
163  for (int i = bs_plain_barrier; i < bs_last_barrier; ++i) {
164  __kmp_str_buf_print(
165  &buffer, "%s%s barrier branch bits: gather=%u, release=%u\n",
166  KMP_VERSION_PREF_STR, __kmp_barrier_type_name[i],
167  __kmp_barrier_gather_branch_bits[i],
168  __kmp_barrier_release_branch_bits[i]); // __kmp_str_buf_print
169  }
170  for (int i = bs_plain_barrier; i < bs_last_barrier; ++i) {
171  __kmp_str_buf_print(
172  &buffer, "%s%s barrier pattern: gather=%s, release=%s\n",
173  KMP_VERSION_PREF_STR, __kmp_barrier_type_name[i],
174  __kmp_barrier_pattern_name[__kmp_barrier_gather_pattern[i]],
175  __kmp_barrier_pattern_name
176  [__kmp_barrier_release_pattern[i]]); // __kmp_str_buf_print
177  }
178  __kmp_str_buf_print(&buffer, "%s\n",
179  &__kmp_version_lock[KMP_VERSION_MAGIC_LEN]);
180 #endif
181  __kmp_str_buf_print(
182  &buffer, "%sthread affinity support: %s\n", KMP_VERSION_PREF_STR,
183 #if KMP_AFFINITY_SUPPORTED
184  (KMP_AFFINITY_CAPABLE()
185  ? (__kmp_affinity_type == affinity_none ? "not used" : "yes")
186  : "no")
187 #else
188  "no"
189 #endif
190  );
191  __kmp_printf("%s", buffer.str);
192  __kmp_str_buf_free(&buffer);
193  K_DIAG(1, ("KMP_VERSION is true\n"));
194 #endif // KMP_STUB
195 } // __kmp_print_version_1
196 
197 // Called at parallel initialization time.
198 static int __kmp_version_2_printed = FALSE;
199 
200 void __kmp_print_version_2(void) {
201  if (__kmp_version_2_printed) {
202  return;
203  }
204  __kmp_version_2_printed = TRUE;
205 } // __kmp_print_version_2
206 
207 // end of file //