Debian Codegraph @

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