kmp_version.cpp 7.3 KB

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