Debian Codegraph @

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