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 #===============================================================================
17 # Manage different library options
18 #===============================================================================
20 if(options_cmake_included)
23 set(options_cmake_included true)
30 "allows Intel(R) MKL-DNN be verbose whenever MKLDNN_VERBOSE
31 environment variable set to 1" ON) # enabled by default
33 option(MKLDNN_ENABLE_CONCURRENT_EXEC
34 "disables sharing a common scratchpad between primitives.
35 This option must be turned on if there is a possibility of concurrent
36 execution of primitives that were created in the same thread.
37 CAUTION: enabling this option increases memory consumption"
38 OFF) # disabled by default
40 # =============================
41 # Building properties and scope
42 # =============================
44 set(MKLDNN_LIBRARY_TYPE "SHARED" CACHE STRING
45 "specifies whether Intel(R) MKL-DNN library should be SHARED or STATIC")
46 option(WITH_EXAMPLE "builds examples" ON)
47 option(WITH_TEST "builds tests" ON)
49 set(MKLDNN_THREADING "OMP" CACHE STRING
50 "specifies threading type; supports OMP (default), OMP:COMP, OMP:INTEL, or TBB.
52 When OpenMP is used a user can choose what runtime to use:
53 - native OpenMP runtime that comes with the compiler (OMP:COMP), or
54 - Intel OpenMP runtime that is compatible with all the compilers that
55 Intel MKL-DNN supports (OMP:INTEL). This option requires Intel MKL
56 be installed or Intel MKL-ML library be downloaded. This option doesn't
57 work with MSVC (w/o Intel Compiler).
58 The default option is OMP, which gives a preference to OMP:INTEL, but if
59 neither Intel MKL is installed nor Intel MKL-ML is available then fallback
62 To use Intel(R) Threading Building Blocks (Intel(R) TBB) one should also
63 set TBBROOT (either environment variable or CMake option) to the library
66 set(MKLDNN_USE_MKL "DEF" CACHE STRING
67 "specifies what Intel MKL library to use.
68 Supports DEF (default), NONE, ML, FULL, FULL:STATIC.
70 By default (DEF) cmakes tries to find Intel MKL-ML library, then full
71 Intel MKL library, or just builds Intel MKL-DNN w/o any binary dependency.
73 To build Intel MKL-DNN w/o any dependencies on Intel MKL / Intel MKL-ML
74 use NONE. Note that building system would not be able to use Intel OpenMP
75 runtime that comes with Intel MKL or Intel MKL-ML, and would be available
76 only if Intel Compiler is used.
78 To force Intel MKL-DNN to use Intel MKL-ML use ML. Depending on the
79 threading the build system would choose between libmklml_intel or
82 To force Intel MKL-DNN to use the full Intel MKL pass FULL or FULL:STATIC
83 to cmake. The former option would make Intel MKL-DNN link against
84 Intel MKL RT (libmkl_rt). The latter one would link against static
85 Intel MKL. Use static linking to reduce the size of the resulting library
86 (including its dependencies).
87 Caution: Intel MKL RT allows setting the threading layer using environment
88 variable MKL_THREADING_LAYER. By default Intel MKL would use
89 OpenMP. If Intel MKL-DNN is built with TBB it is recommended to
90 set MKL_THREADING_LAYER to `tbb` or `sequential`, to avoid
91 conflict between OpenMP and TBB thread pools.")
97 set(ARCH_OPT_FLAGS "HostOpts" CACHE STRING
98 "specifies compiler optimization flags (see below for more information).
99 If empty default optimization level would be applied which depends on the
102 - For Intel(R) C++ Compilers the default option is `-xHOST` which instructs
103 the compiler to generate the code for the architecture where building is
104 happening. This option would not allow to run the library on older
107 - For GNU* Compiler Collection version 5 and newer the default options are
108 `-march=native -mtune=native` which behaves similarly to the description
111 - For all other cases there are no special optimizations flags.
113 If the library is to be built for generic architecture (e.g. built by a
114 Linux distributive maintainer) one may want to specify ARCH_OPT_FLAGS=\"\"
115 to not use any host specific instructions")
117 # ======================
118 # Profiling capabilities
119 # ======================
121 set(VTUNEROOT "" CACHE STRING
122 "path to Intel(R) VTune(tm) Amplifier.
123 Required to register Intel(R) MKL-DNN kernels that are generated at
124 runtime, otherwise the profile would not be able to track the kernels and
125 would report `outside any known module`.")
131 option(BENCHDNN_USE_RDPMC
132 "enables rdpms counter to report precise cpu frequency in benchdnn.
133 CAUTION: may not work on all cpus (hence disabled by default)"
134 OFF) # disabled by default
140 set(MKLDNN_USE_CLANG_SANITIZER "" CACHE STRING
141 "instructs build system to use a Clang sanitizer. Possible values:
142 Address: enables MemorySanitizer
143 Memory: enables MemorySanitizer
144 MemoryWithOrigin: enables MemorySanitizer with origin tracking
145 Undefined: enables UndefinedBehaviourSanitizer
146 This feature is experimental and is only available on Linux.")
148 option(MKLDNN_PRODUCT_BUILD_MODE
149 "Enables/disables product build mode. For example,
150 setting MKLDNN_PRODUCT_BUILD_MODE=OFF makes warnings non-fatal"