]> git.proxmox.com Git - ceph.git/blob - ceph/src/erasure-code/isa/isa-l/erasure_code/ec_highlevel_func.c
bump version to 12.0.3-pve3
[ceph.git] / ceph / src / erasure-code / isa / isa-l / erasure_code / ec_highlevel_func.c
1 /**********************************************************************
2 Copyright(c) 2011-2015 Intel Corporation All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13 * Neither the name of Intel Corporation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 **********************************************************************/
29 #include <limits.h>
30 #include "erasure_code.h"
31 #include "types.h"
32
33 void ec_init_tables(int k, int rows, unsigned char *a, unsigned char *g_tbls)
34 {
35 int i, j;
36
37 for (i = 0; i < rows; i++) {
38 for (j = 0; j < k; j++) {
39 gf_vect_mul_init(*a++, g_tbls);
40 g_tbls += 32;
41 }
42 }
43 }
44
45 void ec_encode_data_sse(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
46 unsigned char **coding)
47 {
48
49 if (len < 16) {
50 ec_encode_data_base(len, k, rows, g_tbls, data, coding);
51 return;
52 }
53
54 while (rows >= 4) {
55 gf_4vect_dot_prod_sse(len, k, g_tbls, data, coding);
56 g_tbls += 4 * k * 32;
57 coding += 4;
58 rows -= 4;
59 }
60 switch (rows) {
61 case 3:
62 gf_3vect_dot_prod_sse(len, k, g_tbls, data, coding);
63 break;
64 case 2:
65 gf_2vect_dot_prod_sse(len, k, g_tbls, data, coding);
66 break;
67 case 1:
68 gf_vect_dot_prod_sse(len, k, g_tbls, data, *coding);
69 break;
70 case 0:
71 break;
72 }
73
74 }
75
76 void ec_encode_data_avx(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
77 unsigned char **coding)
78 {
79 if (len < 16) {
80 ec_encode_data_base(len, k, rows, g_tbls, data, coding);
81 return;
82 }
83
84 while (rows >= 4) {
85 gf_4vect_dot_prod_avx(len, k, g_tbls, data, coding);
86 g_tbls += 4 * k * 32;
87 coding += 4;
88 rows -= 4;
89 }
90 switch (rows) {
91 case 3:
92 gf_3vect_dot_prod_avx(len, k, g_tbls, data, coding);
93 break;
94 case 2:
95 gf_2vect_dot_prod_avx(len, k, g_tbls, data, coding);
96 break;
97 case 1:
98 gf_vect_dot_prod_avx(len, k, g_tbls, data, *coding);
99 break;
100 case 0:
101 break;
102 }
103
104 }
105
106 void ec_encode_data_avx2(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
107 unsigned char **coding)
108 {
109
110 if (len < 32) {
111 ec_encode_data_base(len, k, rows, g_tbls, data, coding);
112 return;
113 }
114
115 while (rows >= 4) {
116 gf_4vect_dot_prod_avx2(len, k, g_tbls, data, coding);
117 g_tbls += 4 * k * 32;
118 coding += 4;
119 rows -= 4;
120 }
121 switch (rows) {
122 case 3:
123 gf_3vect_dot_prod_avx2(len, k, g_tbls, data, coding);
124 break;
125 case 2:
126 gf_2vect_dot_prod_avx2(len, k, g_tbls, data, coding);
127 break;
128 case 1:
129 gf_vect_dot_prod_avx2(len, k, g_tbls, data, *coding);
130 break;
131 case 0:
132 break;
133 }
134
135 }
136
137 #if __WORDSIZE == 64 || _WIN64 || __x86_64__
138
139 void ec_encode_data_update_sse(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
140 unsigned char *data, unsigned char **coding)
141 {
142 if (len < 16) {
143 ec_encode_data_update_base(len, k, rows, vec_i, g_tbls, data, coding);
144 return;
145 }
146
147 while (rows > 6) {
148 gf_6vect_mad_sse(len, k, vec_i, g_tbls, data, coding);
149 g_tbls += 6 * k * 32;
150 coding += 6;
151 rows -= 6;
152 }
153 switch (rows) {
154 case 6:
155 gf_6vect_mad_sse(len, k, vec_i, g_tbls, data, coding);
156 break;
157 case 5:
158 gf_5vect_mad_sse(len, k, vec_i, g_tbls, data, coding);
159 break;
160 case 4:
161 gf_4vect_mad_sse(len, k, vec_i, g_tbls, data, coding);
162 break;
163 case 3:
164 gf_3vect_mad_sse(len, k, vec_i, g_tbls, data, coding);
165 break;
166 case 2:
167 gf_2vect_mad_sse(len, k, vec_i, g_tbls, data, coding);
168 break;
169 case 1:
170 gf_vect_mad_sse(len, k, vec_i, g_tbls, data, *coding);
171 break;
172 case 0:
173 break;
174 }
175
176 }
177
178 void ec_encode_data_update_avx(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
179 unsigned char *data, unsigned char **coding)
180 {
181 if (len < 16) {
182 ec_encode_data_update_base(len, k, rows, vec_i, g_tbls, data, coding);
183 return;
184 }
185 while (rows > 6) {
186 gf_6vect_mad_avx(len, k, vec_i, g_tbls, data, coding);
187 g_tbls += 6 * k * 32;
188 coding += 6;
189 rows -= 6;
190 }
191 switch (rows) {
192 case 6:
193 gf_6vect_mad_avx(len, k, vec_i, g_tbls, data, coding);
194 break;
195 case 5:
196 gf_5vect_mad_avx(len, k, vec_i, g_tbls, data, coding);
197 break;
198 case 4:
199 gf_4vect_mad_avx(len, k, vec_i, g_tbls, data, coding);
200 break;
201 case 3:
202 gf_3vect_mad_avx(len, k, vec_i, g_tbls, data, coding);
203 break;
204 case 2:
205 gf_2vect_mad_avx(len, k, vec_i, g_tbls, data, coding);
206 break;
207 case 1:
208 gf_vect_mad_avx(len, k, vec_i, g_tbls, data, *coding);
209 break;
210 case 0:
211 break;
212 }
213
214 }
215
216 void ec_encode_data_update_avx2(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
217 unsigned char *data, unsigned char **coding)
218 {
219 if (len < 32) {
220 ec_encode_data_update_base(len, k, rows, vec_i, g_tbls, data, coding);
221 return;
222 }
223 while (rows > 6) {
224 gf_6vect_mad_avx2(len, k, vec_i, g_tbls, data, coding);
225 g_tbls += 6 * k * 32;
226 coding += 6;
227 rows -= 6;
228 }
229 switch (rows) {
230 case 6:
231 gf_6vect_mad_avx2(len, k, vec_i, g_tbls, data, coding);
232 break;
233 case 5:
234 gf_5vect_mad_avx2(len, k, vec_i, g_tbls, data, coding);
235 break;
236 case 4:
237 gf_4vect_mad_avx2(len, k, vec_i, g_tbls, data, coding);
238 break;
239 case 3:
240 gf_3vect_mad_avx2(len, k, vec_i, g_tbls, data, coding);
241 break;
242 case 2:
243 gf_2vect_mad_avx2(len, k, vec_i, g_tbls, data, coding);
244 break;
245 case 1:
246 gf_vect_mad_avx2(len, k, vec_i, g_tbls, data, *coding);
247 break;
248 case 0:
249 break;
250 }
251
252 }
253
254 #endif //__WORDSIZE == 64 || _WIN64 || __x86_64__
255
256 struct slver {
257 UINT16 snum;
258 UINT8 ver;
259 UINT8 core;
260 };
261
262 // Version info
263 struct slver ec_init_tables_slver_00010068;
264 struct slver ec_init_tables_slver = { 0x0068, 0x01, 0x00 };
265
266 struct slver ec_encode_data_sse_slver_00020069;
267 struct slver ec_encode_data_sse_slver = { 0x0069, 0x02, 0x00 };