Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / src / cpu / gemm / os_blas.hpp
1 /*******************************************************************************
2 * Copyright 2017-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 #ifndef OS_BLAS_HPP
18 #define OS_BLAS_HPP
19
20 /** \file
21  * Common stuff respecting USE_MKL and USE_CBLAS compile flags
22  *
23  *  USE_MKL  USE_CBLAS effect
24  *  -------  --------- ------
25  *  yes      yes       normal compile: jit *may* be preferred over Intel(R) MKL CBLAS
26  *  yes      no        jit calls OK; assert if cblas is ever called
27  *  no       yes       system-dependent CBLAS
28  *  no       no        gemm convolution (or other blas) N/A; create stubs
29  */
30
31 #if defined(USE_MKL)
32
33 #include "mkl_version.h"
34
35 #define USE_MKL_PACKED_GEMM 0
36 #define USE_MKL_IGEMM \
37     (INTEL_MKL_VERSION >= 20180000 && __INTEL_MKL_BUILD_DATE >= 20170628)
38
39 #include "mkl_cblas.h"
40 #if !defined(USE_CBLAS)
41 #define cblas_sgemm(...) assert(!"CBLAS is unavailable")
42 #endif
43
44 #else /* defined(USE_MKL) */
45
46 #define USE_MKL_PACKED_GEMM 0
47 #define USE_MKL_IGEMM 0
48
49 #if defined(_SX)
50 /* TODO: _SX should also define USE_CBLAS in case the later is available */
51 extern "C" {
52 #include "cblas.h" // CHECK: does SX also have a fortran API sgemm?
53 }
54
55 #elif defined(USE_CBLAS)
56 #include "cblas.h" // Maybe a system/cmake cblas works for you?
57 #else
58 /* put the stubs to make a code compilable but not workable */
59 #define cblas_sgemm(...) assert(!"CBLAS is unavailable")
60 #endif /* defined(_SX) */
61
62 #endif /* defined(USE_MKL) */
63
64 namespace mkldnn {
65 namespace impl {
66 namespace cpu {
67
68 #if defined(USE_MKL) && defined(USE_CBLAS)
69 typedef MKL_INT cblas_int;
70
71 #elif defined(USE_CBLAS)
72 typedef int cblas_int;
73
74 #if defined(_SX)
75 /* this cblas.h is peculiar... */
76 typedef CBLAS_ORDER CBLAS_LAYOUT;
77 #endif
78 #endif
79
80 }
81 }
82 }
83
84 #endif /* OS_BLAS_HPP */
85
86 // vim: et ts=4 sw=4 cindent cino^=l0,\:0,N-s