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 #ifndef GEMM_UTILS_HPP
18 #define GEMM_UTILS_HPP
24 namespace gemm_utils {
25 // Alias for any dimension related variable.
26 typedef ptrdiff_t dim_t;
28 template <typename T, bool isTransA, bool isTransB>
29 struct gemm_traits {};
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;
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;
50 using unroll_factor = gemm_traits<T, false, false>;
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);
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);
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,
65 void partition_unit_diff(
66 int ithr, int nthr, int n, int *t_offset, int *t_block);