Add a section of how to link IE with CMake project (#99)
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / src / cpu / gemm / f32 / gemm_utils_f32.hpp
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 #ifndef GEMM_UTILS_HPP
18 #define GEMM_UTILS_HPP
19
20 namespace mkldnn {
21 namespace impl {
22 namespace cpu {
23
24 namespace gemm_utils {
25 // Alias for any dimension related variable.
26 typedef ptrdiff_t dim_t;
27
28 template <typename T, bool isTransA, bool isTransB>
29 struct gemm_traits {};
30
31 template <bool isTransA, bool isTransB>
32 struct gemm_traits<double, isTransA, isTransB> {
33     static constexpr int m = 8;
34     static constexpr int n = 6;
35     static constexpr int BM = 4032;
36     static constexpr int BN = isTransA ? 96 : 192;
37     static constexpr int BK = isTransB ? 96 : 512;
38 };
39
40 template <bool isTransA, bool isTransB>
41 struct gemm_traits<float, isTransA, isTransB> {
42     static constexpr int m = 16;
43     static constexpr int n = 6;
44     static constexpr int BM = 4032;
45     static constexpr int BN = isTransA ? 96 : 48;
46     static constexpr int BK = isTransB ? 96 : 256;
47 };
48
49 template <typename T>
50 using unroll_factor = gemm_traits<T, false, false>;
51
52 template <typename data_t>
53 void sum_two_matrices(int m, int n,
54         data_t * __restrict p_src, dim_t ld_src,
55         data_t * __restrict p_dst, dim_t ld_dst);
56
57 void calc_nthr_nocopy_avx512_common(int m,
58         int n, int k, int nthrs, int *nthrs_m, int *nthrs_n, int *nthrs_k,
59         int *BM, int *BN, int *BK);
60
61 void calc_nthr_nocopy_avx(int m, int n, int k,
62         int nthrs, int *nthrs_m, int *nthrs_n, int *nthrs_k, int *BM, int *BN,
63         int *BK);
64
65 void partition_unit_diff(
66         int ithr, int nthr, int n, int *t_offset, int *t_block);
67 };
68
69 }
70 }
71 }
72 #endif