Debian Codegraph @

src/nw_stats_striped_neon_128_8.c

raw symbols SCIP
1 /**
2 * @file
3 *
4 * @author [email protected]
5 *
6 * Copyright (c) 2015 Battelle Memorial Institute.
7 */
8 #include "config.h"
9
10 #include <stdint.h>
11 #include <stdlib.h>
12
13
14
15 #include "parasail.h"
16 #include "parasail/memory.h"
17 #include "parasail/internal_neon.h"
18
19 #define SWAP(A,B) { simde__m128i* tmp = A; A = B; B = tmp; }
20
21
22
23 #ifdef PARASAIL_TABLE
24 static inline void arr_store_si128(
25 int *array,
26 simde__m128i vH,
27 int32_t t,
28 int32_t seglen,
29 int32_t d,
30 int32_t dlen)
31 {
32 array[1LL*( 0*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 0);
33 array[1LL*( 1*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 1);
34 array[1LL*( 2*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 2);
35 array[1LL*( 3*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 3);
36 array[1LL*( 4*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 4);
37 array[1LL*( 5*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 5);
38 array[1LL*( 6*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 6);
39 array[1LL*( 7*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 7);
40 array[1LL*( 8*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 8);
41 array[1LL*( 9*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 9);
42 array[1LL*(10*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 10);
43 array[1LL*(11*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 11);
44 array[1LL*(12*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 12);
45 array[1LL*(13*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 13);
46 array[1LL*(14*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 14);
47 array[1LL*(15*seglen+t)*dlen + d] = (int8_t)simde_mm_extract_epi8(vH, 15);
48 }
49 #endif
50
51 #ifdef PARASAIL_ROWCOL
52 static inline void arr_store_col(
53 int *col,
54 simde__m128i vH,
55 int32_t t,
56 int32_t seglen)
57 {
58 col[ 0*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 0);
59 col[ 1*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 1);
60 col[ 2*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 2);
61 col[ 3*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 3);
62 col[ 4*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 4);
63 col[ 5*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 5);
64 col[ 6*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 6);
65 col[ 7*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 7);
66 col[ 8*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 8);
67 col[ 9*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 9);
68 col[10*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 10);
69 col[11*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 11);
70 col[12*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 12);
71 col[13*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 13);
72 col[14*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 14);
73 col[15*seglen+t] = (int8_t)simde_mm_extract_epi8(vH, 15);
74 }
75 #endif
76
77 #ifdef PARASAIL_TABLE
78 #define FNAME parasail_nw_stats_table_striped_neon_128_8
79 #define PNAME parasail_nw_stats_table_striped_profile_neon_128_8
80 #else
81 #ifdef PARASAIL_ROWCOL
82 #define FNAME parasail_nw_stats_rowcol_striped_neon_128_8
83 #define PNAME parasail_nw_stats_rowcol_striped_profile_neon_128_8
84 #else
85 #define FNAME parasail_nw_stats_striped_neon_128_8
86 #define PNAME parasail_nw_stats_striped_profile_neon_128_8
87 #endif
88 #endif
89
90 parasail_result_t* FNAME(
91 const char * const restrict s1, const int s1Len,
92 const char * const restrict s2, const int s2Len,
93 const int open, const int gap, const parasail_matrix_t *matrix)
94 {
95 /* declare local variables */
96 parasail_profile_t *profile = NULL;
97 parasail_result_t *result = NULL;
98
99 /* validate inputs */
100 PARASAIL_CHECK_NULL(s2);
101 PARASAIL_CHECK_GT0(s2Len);
102 PARASAIL_CHECK_GE0(open);
103 PARASAIL_CHECK_GE0(gap);
104 PARASAIL_CHECK_NULL(matrix);
105 if (matrix->type == PARASAIL_MATRIX_TYPE_PSSM) {
106 PARASAIL_CHECK_NULL_PSSM_STATS(s1);
107 }
108 else {
109 PARASAIL_CHECK_NULL(s1);
110 PARASAIL_CHECK_GT0(s1Len);
111 }
112
113 /* initialize local variables */
114 profile = parasail_profile_create_stats_neon_128_8(s1, s1Len, matrix);
115 if (!profile) return NULL;
116 result = PNAME(profile, s2, s2Len, open, gap);
117
118 parasail_profile_free(profile);
119
120 return result;
121 }
122
123 parasail_result_t* PNAME(
124 const parasail_profile_t * const restrict profile,
125 const char * const restrict s2, const int s2Len,
126 const int open, const int gap)
127 {
128 /* declare local variables */
129 int32_t i = 0;
130 int32_t j = 0;
131 int32_t k = 0;
132 int32_t s1Len = 0;
133 int32_t end_query = 0;
134 int32_t end_ref = 0;
135 const parasail_matrix_t *matrix = NULL;
136 int32_t segWidth = 0;
137 int32_t segLen = 0;
138 int32_t offset = 0;
139 int32_t position = 0;
140 simde__m128i* restrict vProfile = NULL;
141 simde__m128i* restrict vProfileM = NULL;
142 simde__m128i* restrict vProfileS = NULL;
143 simde__m128i* restrict pvHStore = NULL;
144 simde__m128i* restrict pvHLoad = NULL;
145 simde__m128i* restrict pvHMStore = NULL;
146 simde__m128i* restrict pvHMLoad = NULL;
147 simde__m128i* restrict pvHSStore = NULL;
148 simde__m128i* restrict pvHSLoad = NULL;
149 simde__m128i* restrict pvHLStore = NULL;
150 simde__m128i* restrict pvHLLoad = NULL;
151 simde__m128i* restrict pvE = NULL;
152 simde__m128i* restrict pvEM = NULL;
153 simde__m128i* restrict pvES = NULL;
154 simde__m128i* restrict pvEL = NULL;
155 int8_t* restrict boundary = NULL;
156 simde__m128i vGapO;
157 simde__m128i vGapE;
158 int8_t NEG_LIMIT = 0;
159 int8_t POS_LIMIT = 0;
160 simde__m128i vZero;
161 simde__m128i vOne;
162 int8_t score = 0;
163 int8_t matches = 0;
164 int8_t similar = 0;
165 int8_t length = 0;
166 simde__m128i vNegLimit;
167 simde__m128i vPosLimit;
168 simde__m128i vSaturationCheckMin;
169 simde__m128i vSaturationCheckMax;
170 parasail_result_t *result = NULL;
171
172 /* validate inputs */
173 PARASAIL_CHECK_NULL(profile);
174 PARASAIL_CHECK_NULL(profile->profile8.score);
175 PARASAIL_CHECK_NULL(profile->matrix);
176 PARASAIL_CHECK_GT0(profile->s1Len);
177 PARASAIL_CHECK_NULL(s2);
178 PARASAIL_CHECK_GT0(s2Len);
179 PARASAIL_CHECK_GE0(open);
180 PARASAIL_CHECK_GE0(gap);
181
182 /* initialize stack variables */
183 i = 0;
184 j = 0;
185 k = 0;
186 s1Len = profile->s1Len;
187 end_query = s1Len-1;
188 end_ref = s2Len-1;
189 matrix = profile->matrix;
190 segWidth = 16; /* number of values in vector unit */
191 segLen = (s1Len + segWidth - 1) / segWidth;
192 offset = (s1Len - 1) % segLen;
193 position = (segWidth - 1) - (s1Len - 1) / segLen;
194 vProfile = (simde__m128i*)profile->profile8.score;
195 vProfileM = (simde__m128i*)profile->profile8.matches;
196 vProfileS = (simde__m128i*)profile->profile8.similar;
197 vGapO = simde_mm_set1_epi8(open);
198 vGapE = simde_mm_set1_epi8(gap);
199 NEG_LIMIT = (-open < matrix->min ? INT8_MIN + open : INT8_MIN - matrix->min) + 1;
200 POS_LIMIT = INT8_MAX - matrix->max - 1;
201 vZero = simde_mm_setzero_si128();
202 vOne = simde_mm_set1_epi8(1);
203 score = NEG_LIMIT;
204 matches = 0;
205 similar = 0;
206 length = 0;
207 vNegLimit = simde_mm_set1_epi8(NEG_LIMIT);
208 vPosLimit = simde_mm_set1_epi8(POS_LIMIT);
209 vSaturationCheckMin = vPosLimit;
210 vSaturationCheckMax = vNegLimit;
211
212 /* initialize result */
213 #ifdef PARASAIL_TABLE
214 result = parasail_result_new_table3(segLen*segWidth, s2Len);
215 #else
216 #ifdef PARASAIL_ROWCOL
217 result = parasail_result_new_rowcol3(segLen*segWidth, s2Len);
218 #else
219 result = parasail_result_new_stats();
220 #endif
221 #endif
222 if (!result) return NULL;
223
224 /* set known flags */
225 result->flag |= PARASAIL_FLAG_NW | PARASAIL_FLAG_STRIPED
226 | PARASAIL_FLAG_STATS
227 | PARASAIL_FLAG_BITS_8 | PARASAIL_FLAG_LANES_16;
228 #ifdef PARASAIL_TABLE
229 result->flag |= PARASAIL_FLAG_TABLE;
230 #endif
231 #ifdef PARASAIL_ROWCOL
232 result->flag |= PARASAIL_FLAG_ROWCOL;
233 #endif
234
235 /* initialize heap variables */
236 pvHStore = parasail_memalign_simde__m128i(16, segLen);
237 pvHLoad = parasail_memalign_simde__m128i(16, segLen);
238 pvHMStore = parasail_memalign_simde__m128i(16, segLen);
239 pvHMLoad = parasail_memalign_simde__m128i(16, segLen);
240 pvHSStore = parasail_memalign_simde__m128i(16, segLen);
241 pvHSLoad = parasail_memalign_simde__m128i(16, segLen);
242 pvHLStore = parasail_memalign_simde__m128i(16, segLen);
243 pvHLLoad = parasail_memalign_simde__m128i(16, segLen);
244 pvE = parasail_memalign_simde__m128i(16, segLen);
245 pvEM = parasail_memalign_simde__m128i(16, segLen);
246 pvES = parasail_memalign_simde__m128i(16, segLen);
247 pvEL = parasail_memalign_simde__m128i(16, segLen);
248 boundary = parasail_memalign_int8_t(16, s2Len+1);
249
250 /* validate heap variables */
251 if (!pvHStore) return NULL;
252 if (!pvHLoad) return NULL;
253 if (!pvHMStore) return NULL;
254 if (!pvHMLoad) return NULL;
255 if (!pvHSStore) return NULL;
256 if (!pvHSLoad) return NULL;
257 if (!pvHLStore) return NULL;
258 if (!pvHLLoad) return NULL;
259 if (!pvE) return NULL;
260 if (!pvEM) return NULL;
261 if (!pvES) return NULL;
262 if (!pvEL) return NULL;
263 if (!boundary) return NULL;
264
265 parasail_memset_simde__m128i(pvHMStore, vZero, segLen);
266 parasail_memset_simde__m128i(pvHSStore, vZero, segLen);
267 parasail_memset_simde__m128i(pvHLStore, vZero, segLen);
268 parasail_memset_simde__m128i(pvEM, vZero, segLen);
269 parasail_memset_simde__m128i(pvES, vZero, segLen);
270 parasail_memset_simde__m128i(pvEL, vOne, segLen);
271
272 /* initialize H and E */
273 {
274 int32_t index = 0;
275 for (i=0; i<segLen; ++i) {
276 int32_t segNum = 0;
277 simde__m128i h;
278 simde__m128i e;
279 for (segNum=0; segNum<segWidth; ++segNum) {
280 int64_t tmp = -open-gap*(segNum*segLen+i);
281 h.i8[segNum] = tmp < INT8_MIN ? INT8_MIN : tmp;
282 tmp = tmp - open;
283 e.i8[segNum] = tmp < INT8_MIN ? INT8_MIN : tmp;
284 }
285 simde_mm_store_si128(&pvHStore[index], h);
286 simde_mm_store_si128(&pvE[index], e);
287 ++index;
288 }
289 }
290
291 /* initialize uppder boundary */
292 {
293 boundary[0] = 0;
294 for (i=1; i<=s2Len; ++i) {
295 int64_t tmp = -open-gap*(i-1);
296 boundary[i] = tmp < INT8_MIN ? INT8_MIN : tmp;
297 }
298 }
299
300 /* outer loop over database sequence */
301 for (j=0; j<s2Len; ++j) {
302 simde__m128i vEF_opn;
303 simde__m128i vE;
304 simde__m128i vE_ext;
305 simde__m128i vEM;
306 simde__m128i vES;
307 simde__m128i vEL;
308 simde__m128i vF;
309 simde__m128i vF_ext;
310 simde__m128i vFM;
311 simde__m128i vFS;
312 simde__m128i vFL;
313 simde__m128i vH;
314 simde__m128i vH_dag;
315 simde__m128i vHM;
316 simde__m128i vHS;
317 simde__m128i vHL;
318 const simde__m128i* vP = NULL;
319 const simde__m128i* vPM = NULL;
320 const simde__m128i* vPS = NULL;
321
322 /* Initialize F value to neg inf. Any errors to vH values will
323 * be corrected in the Lazy_F loop. */
324 vF = vNegLimit;
325 vFM = vZero;
326 vFS = vZero;
327 vFL = vOne;
328
329 /* load final segment of pvHStore and shift left by 1 bytes */
330 vH = simde_mm_load_si128(&pvHStore[segLen - 1]);
331 vHM = simde_mm_load_si128(&pvHMStore[segLen - 1]);
332 vHS = simde_mm_load_si128(&pvHSStore[segLen - 1]);
333 vHL = simde_mm_load_si128(&pvHLStore[segLen - 1]);
334 vH = simde_mm_slli_si128(vH, 1);
335 vHM = simde_mm_slli_si128(vHM, 1);
336 vHS = simde_mm_slli_si128(vHS, 1);
337 vHL = simde_mm_slli_si128(vHL, 1);
338
339 /* insert upper boundary condition */
340 vH = simde_mm_insert_epi8(vH, boundary[j], 0);
341
342 /* Correct part of the vProfile */
343 vP = vProfile + matrix->mapper[(unsigned char)s2[j]] * segLen;
344 vPM = vProfileM + matrix->mapper[(unsigned char)s2[j]] * segLen;
345 vPS = vProfileS + matrix->mapper[(unsigned char)s2[j]] * segLen;
346
347 /* Swap the 2 H buffers. */
348 SWAP(pvHLoad, pvHStore)
349 SWAP(pvHMLoad, pvHMStore)
350 SWAP(pvHSLoad, pvHSStore)
351 SWAP(pvHLLoad, pvHLStore)
352
353 /* inner loop to process the query sequence */
354 for (i=0; i<segLen; ++i) {
355 simde__m128i case1;
356 simde__m128i case2;
357
358 vE = simde_mm_load_si128(pvE+ i);
359 vEM = simde_mm_load_si128(pvEM+ i);
360 vES = simde_mm_load_si128(pvES+ i);
361 vEL = simde_mm_load_si128(pvEL+ i);
362
363 /* Get max from vH, vE and vF. */
364 vH_dag = simde_mm_adds_epi8(vH, simde_mm_load_si128(vP + i));
365 vH = simde_mm_max_epi8(vH_dag, vE);
366 vH = simde_mm_max_epi8(vH, vF);
367 /* Save vH values. */
368 simde_mm_store_si128(pvHStore + i, vH);
369
370 case1 = simde_mm_cmpeq_epi8(vH, vH_dag);
371 case2 = simde_mm_cmpeq_epi8(vH, vF);
372
373 /* calculate vM */
374 vHM = simde_mm_blendv_epi8(
375 simde_mm_blendv_epi8(vEM, vFM, case2),
376 simde_mm_adds_epi8(vHM, simde_mm_load_si128(vPM + i)),
377 case1);
378 simde_mm_store_si128(pvHMStore + i, vHM);
379
380 /* calculate vS */
381 vHS = simde_mm_blendv_epi8(
382 simde_mm_blendv_epi8(vES, vFS, case2),
383 simde_mm_adds_epi8(vHS, simde_mm_load_si128(vPS + i)),
384 case1);
385 simde_mm_store_si128(pvHSStore + i, vHS);
386
387 /* calculate vL */
388 vHL = simde_mm_blendv_epi8(
389 simde_mm_blendv_epi8(vEL, vFL, case2),
390 simde_mm_adds_epi8(vHL, vOne),
391 case1);
392 simde_mm_store_si128(pvHLStore + i, vHL);
393
394 vSaturationCheckMin = simde_mm_min_epi8(vSaturationCheckMin, vH);
395 vSaturationCheckMax = simde_mm_max_epi8(vSaturationCheckMax, vH);
396 vSaturationCheckMax = simde_mm_max_epi8(vSaturationCheckMax, vHM);
397 vSaturationCheckMax = simde_mm_max_epi8(vSaturationCheckMax, vHS);
398 vSaturationCheckMax = simde_mm_max_epi8(vSaturationCheckMax, vHL);
399 #ifdef PARASAIL_TABLE
400 arr_store_si128(result->stats->tables->matches_table, vHM, i, segLen, j, s2Len);
401 arr_store_si128(result->stats->tables->similar_table, vHS, i, segLen, j, s2Len);
402 arr_store_si128(result->stats->tables->length_table, vHL, i, segLen, j, s2Len);
403 arr_store_si128(result->stats->tables->score_table, vH, i, segLen, j, s2Len);
404 #endif
405 vEF_opn = simde_mm_subs_epi8(vH, vGapO);
406
407 /* Update vE value. */
408 vE_ext = simde_mm_subs_epi8(vE, vGapE);
409 vE = simde_mm_max_epi8(vEF_opn, vE_ext);
410 case1 = simde_mm_cmpgt_epi8(vEF_opn, vE_ext);
411 vEM = simde_mm_blendv_epi8(vEM, vHM, case1);
412 vES = simde_mm_blendv_epi8(vES, vHS, case1);
413 vEL = simde_mm_blendv_epi8(
414 simde_mm_adds_epi8(vEL, vOne),
415 simde_mm_adds_epi8(vHL, vOne),
416 case1);
417 simde_mm_store_si128(pvE + i, vE);
418 simde_mm_store_si128(pvEM + i, vEM);
419 simde_mm_store_si128(pvES + i, vES);
420 simde_mm_store_si128(pvEL + i, vEL);
421
422 /* Update vF value. */
423 vF_ext = simde_mm_subs_epi8(vF, vGapE);
424 vF = simde_mm_max_epi8(vEF_opn, vF_ext);
425 case1 = simde_mm_cmpgt_epi8(vEF_opn, vF_ext);
426 vFM = simde_mm_blendv_epi8(vFM, vHM, case1);
427 vFS = simde_mm_blendv_epi8(vFS, vHS, case1);
428 vFL = simde_mm_blendv_epi8(
429 simde_mm_adds_epi8(vFL, vOne),
430 simde_mm_adds_epi8(vHL, vOne),
431 case1);
432
433 /* Load the next vH. */
434 vH = simde_mm_load_si128(pvHLoad + i);
435 vHM = simde_mm_load_si128(pvHMLoad + i);
436 vHS = simde_mm_load_si128(pvHSLoad + i);
437 vHL = simde_mm_load_si128(pvHLLoad + i);
438 }
439
440 /* Lazy_F loop: has been revised to disallow adjecent insertion and
441 * then deletion, so don't update E(i, i), learn from SWPS3 */
442 for (k=0; k<segWidth; ++k) {
443 simde__m128i vHp = simde_mm_load_si128(&pvHLoad[segLen - 1]);
444 int64_t tmp = boundary[j+1]-open;
445 int8_t tmp2 = tmp < INT8_MIN ? INT8_MIN : tmp;
446 vHp = simde_mm_slli_si128(vHp, 1);
447 vF = simde_mm_slli_si128(vF, 1);
448 vFM = simde_mm_slli_si128(vFM, 1);
449 vFS = simde_mm_slli_si128(vFS, 1);
450 vFL = simde_mm_slli_si128(vFL, 1);
451 vHp = simde_mm_insert_epi8(vHp, boundary[j], 0);
452 vF = simde_mm_insert_epi8(vF, tmp2, 0);
453 vFL = simde_mm_insert_epi8(vFL, 1, 0);
454 for (i=0; i<segLen; ++i) {
455 simde__m128i case1;
456 simde__m128i case2;
457 simde__m128i cond;
458
459 vHp = simde_mm_adds_epi8(vHp, simde_mm_load_si128(vP + i));
460 vH = simde_mm_load_si128(pvHStore + i);
461 vH = simde_mm_max_epi8(vH,vF);
462 simde_mm_store_si128(pvHStore + i, vH);
463 case1 = simde_mm_cmpeq_epi8(vH, vHp);
464 case2 = simde_mm_cmpeq_epi8(vH, vF);
465 cond = simde_mm_andnot_si128(case1, case2);
466
467 /* calculate vM */
468 vHM = simde_mm_load_si128(pvHMStore + i);
469 vHM = simde_mm_blendv_epi8(vHM, vFM, cond);
470 simde_mm_store_si128(pvHMStore + i, vHM);
471
472 /* calculate vS */
473 vHS = simde_mm_load_si128(pvHSStore + i);
474 vHS = simde_mm_blendv_epi8(vHS, vFS, cond);
475 simde_mm_store_si128(pvHSStore + i, vHS);
476
477 /* calculate vL */
478 vHL = simde_mm_load_si128(pvHLStore + i);
479 vHL = simde_mm_blendv_epi8(vHL, vFL, cond);
480 simde_mm_store_si128(pvHLStore + i, vHL);
481
482 vSaturationCheckMin = simde_mm_min_epi8(vSaturationCheckMin, vH);
483 vSaturationCheckMax = simde_mm_max_epi8(vSaturationCheckMax, vH);
484 vSaturationCheckMax = simde_mm_max_epi8(vSaturationCheckMax, vHM);
485 vSaturationCheckMax = simde_mm_max_epi8(vSaturationCheckMax, vHS);
486 vSaturationCheckMax = simde_mm_max_epi8(vSaturationCheckMax, vHL);
487 #ifdef PARASAIL_TABLE
488 arr_store_si128(result->stats->tables->matches_table, vHM, i, segLen, j, s2Len);
489 arr_store_si128(result->stats->tables->similar_table, vHS, i, segLen, j, s2Len);
490 arr_store_si128(result->stats->tables->length_table, vHL, i, segLen, j, s2Len);
491 arr_store_si128(result->stats->tables->score_table, vH, i, segLen, j, s2Len);
492 #endif
493 /* Update vF value. */
494 vEF_opn = simde_mm_subs_epi8(vH, vGapO);
495 vF_ext = simde_mm_subs_epi8(vF, vGapE);
496 if (! simde_mm_movemask_epi8(
497 simde_mm_or_si128(
498 simde_mm_cmpgt_epi8(vF_ext, vEF_opn),
499 simde_mm_cmpeq_epi8(vF_ext, vEF_opn))))
500 goto end;
501 /*vF = simde_mm_max_epi8(vEF_opn, vF_ext);*/
502 vF = vF_ext;
503 cond = simde_mm_cmpgt_epi8(vEF_opn, vF_ext);
504 vFM = simde_mm_blendv_epi8(vFM, vHM, cond);
505 vFS = simde_mm_blendv_epi8(vFS, vHS, cond);
506 vFL = simde_mm_blendv_epi8(
507 simde_mm_adds_epi8(vFL, vOne),
508 simde_mm_adds_epi8(vHL, vOne),
509 cond);
510 vHp = simde_mm_load_si128(pvHLoad + i);
511 }
512 }
513 end:
514 {
515 }
516
517 #ifdef PARASAIL_ROWCOL
518 /* extract last value from the column */
519 {
520 vH = simde_mm_load_si128(pvHStore + offset);
521 vHM = simde_mm_load_si128(pvHMStore + offset);
522 vHS = simde_mm_load_si128(pvHSStore + offset);
523 vHL = simde_mm_load_si128(pvHLStore + offset);
524 for (k=0; k<position; ++k) {
525 vH = simde_mm_slli_si128 (vH, 1);
526 vHM = simde_mm_slli_si128 (vHM, 1);
527 vHS = simde_mm_slli_si128 (vHS, 1);
528 vHL = simde_mm_slli_si128 (vHL, 1);
529 }
530 result->stats->rowcols->score_row[j] = (int8_t) simde_mm_extract_epi8 (vH, 15);
531 result->stats->rowcols->matches_row[j] = (int8_t) simde_mm_extract_epi8 (vHM, 15);
532 result->stats->rowcols->similar_row[j] = (int8_t) simde_mm_extract_epi8 (vHS, 15);
533 result->stats->rowcols->length_row[j] = (int8_t) simde_mm_extract_epi8 (vHL, 15);
534 }
535 #endif
536 }
537
538 #ifdef PARASAIL_ROWCOL
539 for (i=0; i<segLen; ++i) {
540 simde__m128i vH = simde_mm_load_si128(pvHStore+i);
541 simde__m128i vHM = simde_mm_load_si128(pvHMStore+i);
542 simde__m128i vHS = simde_mm_load_si128(pvHSStore+i);
543 simde__m128i vHL = simde_mm_load_si128(pvHLStore+i);
544 arr_store_col(result->stats->rowcols->score_col, vH, i, segLen);
545 arr_store_col(result->stats->rowcols->matches_col, vHM, i, segLen);
546 arr_store_col(result->stats->rowcols->similar_col, vHS, i, segLen);
547 arr_store_col(result->stats->rowcols->length_col, vHL, i, segLen);
548 }
549 #endif
550
551 /* extract last value from the last column */
552 {
553 simde__m128i vH = simde_mm_load_si128(pvHStore + offset);
554 simde__m128i vHM = simde_mm_load_si128(pvHMStore + offset);
555 simde__m128i vHS = simde_mm_load_si128(pvHSStore + offset);
556 simde__m128i vHL = simde_mm_load_si128(pvHLStore + offset);
557 for (k=0; k<position; ++k) {
558 vH = simde_mm_slli_si128 (vH, 1);
559 vHM = simde_mm_slli_si128 (vHM, 1);
560 vHS = simde_mm_slli_si128 (vHS, 1);
561 vHL = simde_mm_slli_si128 (vHL, 1);
562 }
563 score = (int8_t) simde_mm_extract_epi8 (vH, 15);
564 matches = (int8_t) simde_mm_extract_epi8 (vHM, 15);
565 similar = (int8_t) simde_mm_extract_epi8 (vHS, 15);
566 length = (int8_t) simde_mm_extract_epi8 (vHL, 15);
567 }
568
569 if (simde_mm_movemask_epi8(simde_mm_or_si128(
570 simde_mm_cmplt_epi8(vSaturationCheckMin, vNegLimit),
571 simde_mm_cmpgt_epi8(vSaturationCheckMax, vPosLimit)))) {
572 result->flag |= PARASAIL_FLAG_SATURATED;
573 score = 0;
574 matches = 0;
575 similar = 0;
576 length = 0;
577 end_query = 0;
578 end_ref = 0;
579 }
580
581 result->score = score;
582 result->end_query = end_query;
583 result->end_ref = end_ref;
584 result->stats->matches = matches;
585 result->stats->similar = similar;
586 result->stats->length = length;
587
588 parasail_free(boundary);
589 parasail_free(pvEL);
590 parasail_free(pvES);
591 parasail_free(pvEM);
592 parasail_free(pvE);
593 parasail_free(pvHLLoad);
594 parasail_free(pvHLStore);
595 parasail_free(pvHSLoad);
596 parasail_free(pvHSStore);
597 parasail_free(pvHMLoad);
598 parasail_free(pvHMStore);
599 parasail_free(pvHLoad);
600 parasail_free(pvHStore);
601
602 return result;
603 }
604
605