Debian Codegraph @

kernels/power10/3/bli_i8gemm_power10_mma.c

raw symbols SCIP
1 /*
2
3 BLIS
4 An object-based framework for developing high-performance BLAS-like
5 libraries.
6
7 Copyright (C) 2014, The University of Texas at Austin
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are
11 met:
12 - Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14 - Redistributions in binary form must reproduce the above copyright
15 notice, this list of conditions and the following disclaimer in the
16 documentation and/or other materials provided with the distribution.
17 - Neither the name(s) of the copyright holder(s) nor the names of its
18 contributors may be used to endorse or promote products derived
19 from this software without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 */
34
35 #ifdef BLIS_SANDBOX_POWER10
36
37 #include "vector_int_macros.h"
38
39 #define I8_ACCUMULATE \
40 __builtin_mma_xvi8ger4pp (&acc0, ca[0], rb[0]); \
41 __builtin_mma_xvi8ger4pp (&acc1, ca[0], rb[1]); \
42 __builtin_mma_xvi8ger4pp (&acc2, ca[0], rb[2]); \
43 __builtin_mma_xvi8ger4pp (&acc3, ca[0], rb[3]); \
44 __builtin_mma_xvi8ger4pp (&acc4, ca[1], rb[0]); \
45 __builtin_mma_xvi8ger4pp (&acc5, ca[1], rb[1]); \
46 __builtin_mma_xvi8ger4pp (&acc6, ca[1], rb[2]); \
47 __builtin_mma_xvi8ger4pp (&acc7, ca[1], rb[3]);
48
49 #define I8_INCREMENT \
50 A0+=32; \
51 B0+=64;
52
53 #define I8_AB_PRODUCT \
54 LOAD_VECTORS \
55 I8_INCREMENT \
56 I8_ACCUMULATE
57
58 void bli_i8gemm_power10_mma_8x16
59 (
60 dim_t m,
61 dim_t n,
62 dim_t k,
63 //const int32_t* alpha,
64 //const int8_t* a,
65 //const int8_t* b,
66 //const int32_t* beta,
67 // int32_t* c, inc_t rs_c0, inc_t cs_c0,
68 const void* alpha,
69 const void* a,
70 const void* b,
71 const void* beta,
72 void* c, inc_t rs_c0, inc_t cs_c0,
73 const auxinfo_t* data,
74 const cntx_t* cntx
75 )
76 {
77 uint64_t k_iter = (k-1) / 4;
78 uint64_t k_left = (k-1) % 4;
79
80 uint64_t rs_c = rs_c0;
81 //uint64_t cs_c = cs_c0;
82
83 const int8_t* restrict A0 = a;
84 const int8_t* restrict B0 = b;
85 int* restrict C0 = c;
86
87 int alpha_ = *((int32_t*)alpha),
88 beta_ = *((int32_t*)beta);
89
90 iv4sf_t result[4];
91 iv4sf_t *rowC;
92
93 // accumulators that will hold the matrix product
94 __vector_quad acc0, acc1, acc2, acc3,
95 acc4, acc5, acc6, acc7;
96
97 vec_t *ca = (vec_t *) A0;
98 vec_t *rb = (vec_t *) B0;
99
100 __builtin_mma_xvi8ger4 (&acc0, ca[0], rb[0]);
101 __builtin_mma_xvi8ger4 (&acc1, ca[0], rb[1]);
102 __builtin_mma_xvi8ger4 (&acc2, ca[0], rb[2]);
103 __builtin_mma_xvi8ger4 (&acc3, ca[0], rb[3]);
104 __builtin_mma_xvi8ger4 (&acc4, ca[1], rb[0]);
105 __builtin_mma_xvi8ger4 (&acc5, ca[1], rb[1]);
106 __builtin_mma_xvi8ger4 (&acc6, ca[1], rb[2]);
107 __builtin_mma_xvi8ger4 (&acc7, ca[1], rb[3]);
108
109 I8_INCREMENT
110
111 // k loop (unrolled by 4)
112 for (int k = 0; k<k_iter; k++)
113 {
114 I8_AB_PRODUCT
115 I8_AB_PRODUCT
116 I8_AB_PRODUCT
117 I8_AB_PRODUCT
118 }
119
120 // edge loop
121 for (int k = 0; k<k_left; k++)
122 {
123 I8_AB_PRODUCT
124 }
125
126 // handle beta cases
127 if (beta_ != 0.0)
128 {
129 SAVE_ACC(iv4sf_t, &acc0, rs_c, 0 );
130 SAVE_ACC(iv4sf_t, &acc1, rs_c, 4 );
131 SAVE_ACC(iv4sf_t, &acc2, rs_c, 8 );
132 SAVE_ACC(iv4sf_t, &acc3, rs_c, 12 );
133 SAVE_ACC(iv4sf_t, &acc4, rs_c, 4*rs_c);
134 SAVE_ACC(iv4sf_t, &acc5, rs_c, 4+4*rs_c);
135 SAVE_ACC(iv4sf_t, &acc6, rs_c, 8+4*rs_c);
136 SAVE_ACC(iv4sf_t, &acc7, rs_c, 12+4*rs_c);
137 }
138 else
139 {
140 SAVE_ACC_bz(iv4sf_t, &acc0, rs_c, 0 );
141 SAVE_ACC_bz(iv4sf_t, &acc1, rs_c, 4 );
142 SAVE_ACC_bz(iv4sf_t, &acc2, rs_c, 8 );
143 SAVE_ACC_bz(iv4sf_t, &acc3, rs_c, 12 );
144 SAVE_ACC_bz(iv4sf_t, &acc4, rs_c, 4*rs_c);
145 SAVE_ACC_bz(iv4sf_t, &acc5, rs_c, 4+4*rs_c);
146 SAVE_ACC_bz(iv4sf_t, &acc6, rs_c, 8+4*rs_c);
147 SAVE_ACC_bz(iv4sf_t, &acc7, rs_c, 12+4*rs_c);
148 }
149 }
150 #endif // BLIS_SANDBOX_POWER10