1 /*******************************************************************************
2 * Copyright 2018 Intel Corporation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
23 #include "mkldnn_version.h"
24 #include "c_types_map.hpp"
25 #include "verbose.hpp"
26 #include "cpu_isa_traits.hpp"
28 /* MKL-DNN CPU ISA info */
29 #define ISA_ANY "No instruction set specific optimizations"
30 #define SSE42 "Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2)"
31 #define AVX "Intel(R) Advanced Vector Extensions (Intel(R) AVX)"
32 #define AVX2 "Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2)"
33 #define AVX512_COMMON "Intel(R) Advanced Vector Extensions 512 (Intel(R) " \
35 #define AVX512_CORE "Intel(R) Advanced Vector Extensions 512 (Intel(R) " \
36 "AVX-512) with AVX512BW, AVX512VL, and AVX512DQ extensions"
37 #define AVX512_CORE_VNNI "Intel(R) AVX512-Deep Learning Boost (Intel(R) " \
39 #define AVX512_MIC "Intel(R) Advanced Vector Extensions 512 (Intel(R) " \
40 "AVX-512) with AVX512CD, AVX512ER, and AVX512PF extensions"
41 #define AVX512_MIC_4OPS "Intel(R) Advanced Vector Extensions 512 (Intel(R) " \
42 "AVX-512) with AVX512_4FMAPS and AVX512_4VNNIW extensions"
47 static verbose_t verbose;
48 static bool initialized;
49 static bool version_printed = false;
51 const verbose_t *mkldnn_verbose() {
52 #if !defined(DISABLE_VERBOSE)
56 if (mkldnn_getenv(val, "MKLDNN_VERBOSE", len) == 1)
57 verbose.level = atoi(val);
60 if (!version_printed && verbose.level > 0) {
61 printf("mkldnn_verbose,info,"
62 "Intel(R) MKL-DNN v%d.%d.%d (Git Hash %s),%s\n",
63 mkldnn_version()->major, mkldnn_version()->minor,
64 mkldnn_version()->patch, mkldnn_version()->hash,
66 version_printed = true;
76 static LARGE_INTEGER frequency;
77 if (frequency.QuadPart == 0)
78 QueryPerformanceFrequency(&frequency);
80 QueryPerformanceCounter(&now);
81 return 1e+3 * now.QuadPart / frequency.QuadPart;
84 gettimeofday(&time, NULL);
85 return 1e+3 * time.tv_sec + 1e-3 * time.tv_usec;
89 const char *get_isa_info() {
90 using namespace mkldnn::impl::cpu;
91 if (mayiuse(avx512_mic_4ops)) return AVX512_MIC_4OPS;
92 if (mayiuse(avx512_mic)) return AVX512_MIC;
93 if (mayiuse(avx512_core_vnni)) return AVX512_CORE_VNNI;
94 if (mayiuse(avx512_core)) return AVX512_CORE;
95 if (mayiuse(avx512_common)) return AVX512_COMMON;
96 if (mayiuse(avx2)) return AVX2;
97 if (mayiuse(avx)) return AVX;
98 if (mayiuse(sse42)) return SSE42;
105 mkldnn_status_t mkldnn_set_verbose(int level) {
106 using namespace mkldnn::impl::status;
107 if (level < 0 || level > 2) return invalid_arguments;
108 mkldnn::impl::verbose.level = level;
109 mkldnn::impl::initialized = true;
113 const mkldnn_version_t *mkldnn_version() {
114 static mkldnn_version_t ver = {
115 MKLDNN_VERSION_MAJOR,
116 MKLDNN_VERSION_MINOR,
117 MKLDNN_VERSION_PATCH,
118 MKLDNN_VERSION_HASH};