xref: /freebsd/contrib/llvm-project/openmp/runtime/src/kmp_version.cpp (revision 924226fba12cc9a228c73b956e1b7fa24c60b055)
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 == 1910
55 #define KMP_COMPILER "Intel(R) C++ Compiler 19.1"
56 #elif __INTEL_COMPILER >= 9900
57 #define KMP_COMPILER "Intel(R) C++ Compiler mainline"
58 #endif
59 #elif KMP_COMPILER_CLANG
60 #define KMP_COMPILER                                                           \
61   "Clang " stringer(__clang_major__) "." stringer(__clang_minor__)
62 #elif KMP_COMPILER_GCC
63 #define KMP_COMPILER "GCC " stringer(__GNUC__) "." stringer(__GNUC_MINOR__)
64 #elif KMP_COMPILER_MSVC
65 #define KMP_COMPILER "MSVC " stringer(_MSC_FULL_VER)
66 #endif
67 #ifndef KMP_COMPILER
68 #warning "Unknown compiler"
69 #define KMP_COMPILER "unknown compiler"
70 #endif
71 
72 // Detect librray type (perf, stub).
73 #ifdef KMP_STUB
74 #define KMP_LIB_TYPE "stub"
75 #else
76 #define KMP_LIB_TYPE "performance"
77 #endif // KMP_LIB_TYPE
78 
79 // Detect link type (static, dynamic).
80 #if KMP_DYNAMIC_LIB
81 #define KMP_LINK_TYPE "dynamic"
82 #else
83 #define KMP_LINK_TYPE "static"
84 #endif // KMP_LINK_TYPE
85 
86 // Finally, define strings.
87 #define KMP_LIBRARY KMP_LIB_TYPE " library (" KMP_LINK_TYPE ")"
88 #define KMP_COPYRIGHT ""
89 
90 int const __kmp_version_major = KMP_VERSION_MAJOR;
91 int const __kmp_version_minor = KMP_VERSION_MINOR;
92 int const __kmp_version_build = KMP_VERSION_BUILD;
93 int const __kmp_openmp_version = 201611;
94 
95 /* Do NOT change the format of this string!  Intel(R) Thread Profiler checks for
96    a specific format some changes in the recognition routine there need to be
97    made before this is changed. */
98 char const __kmp_copyright[] = KMP_VERSION_PREFIX KMP_LIBRARY
99     " ver. " stringer(KMP_VERSION_MAJOR) "." stringer(
100         KMP_VERSION_MINOR) "." stringer(KMP_VERSION_BUILD) " " KMP_COPYRIGHT;
101 
102 char const __kmp_version_copyright[] = KMP_VERSION_PREFIX KMP_COPYRIGHT;
103 char const __kmp_version_lib_ver[] =
104     KMP_VERSION_PREFIX "version: " stringer(KMP_VERSION_MAJOR) "." stringer(
105         KMP_VERSION_MINOR) "." stringer(KMP_VERSION_BUILD);
106 char const __kmp_version_lib_type[] =
107     KMP_VERSION_PREFIX "library type: " KMP_LIB_TYPE;
108 char const __kmp_version_link_type[] =
109     KMP_VERSION_PREFIX "link type: " KMP_LINK_TYPE;
110 char const __kmp_version_build_time[] = KMP_VERSION_PREFIX "build time: "
111                                                            "no_timestamp";
112 #if KMP_MIC2
113 char const __kmp_version_target_env[] =
114     KMP_VERSION_PREFIX "target environment: MIC2";
115 #endif
116 char const __kmp_version_build_compiler[] =
117     KMP_VERSION_PREFIX "build compiler: " KMP_COMPILER;
118 
119 // Called at serial initialization time.
120 static int __kmp_version_1_printed = FALSE;
121 
122 void __kmp_print_version_1(void) {
123   if (__kmp_version_1_printed) {
124     return;
125   }
126   __kmp_version_1_printed = TRUE;
127 
128 #ifndef KMP_STUB
129   kmp_str_buf_t buffer;
130   __kmp_str_buf_init(&buffer);
131   // Print version strings skipping initial magic.
132   __kmp_str_buf_print(&buffer, "%s\n",
133                       &__kmp_version_lib_ver[KMP_VERSION_MAGIC_LEN]);
134   __kmp_str_buf_print(&buffer, "%s\n",
135                       &__kmp_version_lib_type[KMP_VERSION_MAGIC_LEN]);
136   __kmp_str_buf_print(&buffer, "%s\n",
137                       &__kmp_version_link_type[KMP_VERSION_MAGIC_LEN]);
138   __kmp_str_buf_print(&buffer, "%s\n",
139                       &__kmp_version_build_time[KMP_VERSION_MAGIC_LEN]);
140 #if KMP_MIC
141   __kmp_str_buf_print(&buffer, "%s\n",
142                       &__kmp_version_target_env[KMP_VERSION_MAGIC_LEN]);
143 #endif
144   __kmp_str_buf_print(&buffer, "%s\n",
145                       &__kmp_version_build_compiler[KMP_VERSION_MAGIC_LEN]);
146 #if defined(KMP_GOMP_COMPAT)
147   __kmp_str_buf_print(&buffer, "%s\n",
148                       &__kmp_version_alt_comp[KMP_VERSION_MAGIC_LEN]);
149 #endif /* defined(KMP_GOMP_COMPAT) */
150   __kmp_str_buf_print(&buffer, "%s\n",
151                       &__kmp_version_omp_api[KMP_VERSION_MAGIC_LEN]);
152   __kmp_str_buf_print(&buffer, "%sdynamic error checking: %s\n",
153                       KMP_VERSION_PREF_STR,
154                       (__kmp_env_consistency_check ? "yes" : "no"));
155 #ifdef KMP_DEBUG
156   for (int i = bs_plain_barrier; i < bs_last_barrier; ++i) {
157     __kmp_str_buf_print(
158         &buffer, "%s%s barrier branch bits: gather=%u, release=%u\n",
159         KMP_VERSION_PREF_STR, __kmp_barrier_type_name[i],
160         __kmp_barrier_gather_branch_bits[i],
161         __kmp_barrier_release_branch_bits[i]); // __kmp_str_buf_print
162   }
163   for (int i = bs_plain_barrier; i < bs_last_barrier; ++i) {
164     __kmp_str_buf_print(
165         &buffer, "%s%s barrier pattern: gather=%s, release=%s\n",
166         KMP_VERSION_PREF_STR, __kmp_barrier_type_name[i],
167         __kmp_barrier_pattern_name[__kmp_barrier_gather_pattern[i]],
168         __kmp_barrier_pattern_name
169             [__kmp_barrier_release_pattern[i]]); // __kmp_str_buf_print
170   }
171   __kmp_str_buf_print(&buffer, "%s\n",
172                       &__kmp_version_lock[KMP_VERSION_MAGIC_LEN]);
173 #endif
174   __kmp_str_buf_print(
175       &buffer, "%sthread affinity support: %s\n", KMP_VERSION_PREF_STR,
176 #if KMP_AFFINITY_SUPPORTED
177       (KMP_AFFINITY_CAPABLE()
178            ? (__kmp_affinity_type == affinity_none ? "not used" : "yes")
179            : "no")
180 #else
181       "no"
182 #endif
183   );
184   __kmp_printf("%s", buffer.str);
185   __kmp_str_buf_free(&buffer);
186   K_DIAG(1, ("KMP_VERSION is true\n"));
187 #endif // KMP_STUB
188 } // __kmp_print_version_1
189 
190 // Called at parallel initialization time.
191 static int __kmp_version_2_printed = FALSE;
192 
193 void __kmp_print_version_2(void) {
194   if (__kmp_version_2_printed) {
195     return;
196   }
197   __kmp_version_2_printed = TRUE;
198 } // __kmp_print_version_2
199 
200 // end of file //
201