Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / cmake / options.cmake
1 #===============================================================================
2 # Copyright 2018 Intel Corporation
3 #
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
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
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 #===============================================================================
16
17 # Manage different library options
18 #===============================================================================
19
20 if(options_cmake_included)
21     return()
22 endif()
23 set(options_cmake_included true)
24
25 # ========
26 # Features
27 # ========
28
29 option(MKLDNN_VERBOSE
30     "allows Intel(R) MKL-DNN be verbose whenever MKLDNN_VERBOSE
31     environment variable set to 1" ON) # enabled by default
32
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
39
40 # =============================
41 # Building properties and scope
42 # =============================
43
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)
48
49 set(MKLDNN_THREADING "OMP" CACHE STRING
50     "specifies threading type; supports OMP (default), OMP:COMP, OMP:INTEL, or TBB.
51
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
60     to OMP:COMP.
61
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
64     location")
65
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.
69
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.
72
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.
77
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
80     libmklml_gnu.
81
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.")
92
93 # =============
94 # Optimizations
95 # =============
96
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
100     compiler being used.
101
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
105       architectures.
106
107     - For GNU* Compiler Collection version 5 and newer the default options are
108       `-march=native -mtune=native` which behaves similarly to the description
109       above.
110
111     - For all other cases there are no special optimizations flags.
112
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")
116
117 # ======================
118 # Profiling capabilities
119 # ======================
120
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`.")
126
127 # =============
128 # Miscellaneous
129 # =============
130
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
135
136 # =============
137 # Developer flags
138 # =============
139
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.")
147
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"
151     ON)