Debian Codegraph @

src/sw_trace_diag_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 <stdlib.h>
11
12
13
14 #include "parasail.h"
15 #include "parasail/memory.h"
16 #include "parasail/internal_neon.h"
17
18
19
20 static inline void arr_store_si128(
21 int8_t *array,
22 simde__m128i vWH,
23 int32_t i,
24 int32_t s1Len,
25 int32_t j,
26 int32_t s2Len)
27 {
28 if (0 <= i+0 && i+0 < s1Len && 0 <= j-0 && j-0 < s2Len) {
29 array[1LL*(i+0)*s2Len + (j-0)] = (int8_t)simde_mm_extract_epi8(vWH, 15);
30 }
31 if (0 <= i+1 && i+1 < s1Len && 0 <= j-1 && j-1 < s2Len) {
32 array[1LL*(i+1)*s2Len + (j-1)] = (int8_t)simde_mm_extract_epi8(vWH, 14);
33 }
34 if (0 <= i+2 && i+2 < s1Len && 0 <= j-2 && j-2 < s2Len) {
35 array[1LL*(i+2)*s2Len + (j-2)] = (int8_t)simde_mm_extract_epi8(vWH, 13);
36 }
37 if (0 <= i+3 && i+3 < s1Len && 0 <= j-3 && j-3 < s2Len) {
38 array[1LL*(i+3)*s2Len + (j-3)] = (int8_t)simde_mm_extract_epi8(vWH, 12);
39 }
40 if (0 <= i+4 && i+4 < s1Len && 0 <= j-4 && j-4 < s2Len) {
41 array[1LL*(i+4)*s2Len + (j-4)] = (int8_t)simde_mm_extract_epi8(vWH, 11);
42 }
43 if (0 <= i+5 && i+5 < s1Len && 0 <= j-5 && j-5 < s2Len) {
44 array[1LL*(i+5)*s2Len + (j-5)] = (int8_t)simde_mm_extract_epi8(vWH, 10);
45 }
46 if (0 <= i+6 && i+6 < s1Len && 0 <= j-6 && j-6 < s2Len) {
47 array[1LL*(i+6)*s2Len + (j-6)] = (int8_t)simde_mm_extract_epi8(vWH, 9);
48 }
49 if (0 <= i+7 && i+7 < s1Len && 0 <= j-7 && j-7 < s2Len) {
50 array[1LL*(i+7)*s2Len + (j-7)] = (int8_t)simde_mm_extract_epi8(vWH, 8);
51 }
52 if (0 <= i+8 && i+8 < s1Len && 0 <= j-8 && j-8 < s2Len) {
53 array[1LL*(i+8)*s2Len + (j-8)] = (int8_t)simde_mm_extract_epi8(vWH, 7);
54 }
55 if (0 <= i+9 && i+9 < s1Len && 0 <= j-9 && j-9 < s2Len) {
56 array[1LL*(i+9)*s2Len + (j-9)] = (int8_t)simde_mm_extract_epi8(vWH, 6);
57 }
58 if (0 <= i+10 && i+10 < s1Len && 0 <= j-10 && j-10 < s2Len) {
59 array[1LL*(i+10)*s2Len + (j-10)] = (int8_t)simde_mm_extract_epi8(vWH, 5);
60 }
61 if (0 <= i+11 && i+11 < s1Len && 0 <= j-11 && j-11 < s2Len) {
62 array[1LL*(i+11)*s2Len + (j-11)] = (int8_t)simde_mm_extract_epi8(vWH, 4);
63 }
64 if (0 <= i+12 && i+12 < s1Len && 0 <= j-12 && j-12 < s2Len) {
65 array[1LL*(i+12)*s2Len + (j-12)] = (int8_t)simde_mm_extract_epi8(vWH, 3);
66 }
67 if (0 <= i+13 && i+13 < s1Len && 0 <= j-13 && j-13 < s2Len) {
68 array[1LL*(i+13)*s2Len + (j-13)] = (int8_t)simde_mm_extract_epi8(vWH, 2);
69 }
70 if (0 <= i+14 && i+14 < s1Len && 0 <= j-14 && j-14 < s2Len) {
71 array[1LL*(i+14)*s2Len + (j-14)] = (int8_t)simde_mm_extract_epi8(vWH, 1);
72 }
73 if (0 <= i+15 && i+15 < s1Len && 0 <= j-15 && j-15 < s2Len) {
74 array[1LL*(i+15)*s2Len + (j-15)] = (int8_t)simde_mm_extract_epi8(vWH, 0);
75 }
76 }
77
78 #define FNAME parasail_sw_trace_diag_neon_128_8
79
80 parasail_result_t* FNAME(
81 const char * const restrict _s1, const int _s1Len,
82 const char * const restrict _s2, const int s2Len,
83 const int open, const int gap, const parasail_matrix_t *matrix)
84 {
85 /* declare local variables */
86 int32_t N = 0;
87 int32_t PAD = 0;
88 int32_t PAD2 = 0;
89 int32_t s1Len_PAD = 0;
90 int32_t s2Len_PAD = 0;
91 int8_t * restrict s1 = NULL;
92 int8_t * restrict s2B = NULL;
93 int8_t * restrict _H_pr = NULL;
94 int8_t * restrict _F_pr = NULL;
95 int8_t * restrict s2 = NULL;
96 int8_t * restrict H_pr = NULL;
97 int8_t * restrict F_pr = NULL;
98 parasail_result_t *result = NULL;
99 int32_t i = 0;
100 int32_t j = 0;
101 int32_t s1Len = 0;
102 int32_t end_query = 0;
103 int32_t end_ref = 0;
104 int8_t NEG_LIMIT = 0;
105 int8_t POS_LIMIT = 0;
106 int8_t score = 0;
107 simde__m128i vNegLimit;
108 simde__m128i vPosLimit;
109 simde__m128i vSaturationCheckMin;
110 simde__m128i vSaturationCheckMax;
111 simde__m128i vNegInf;
112 simde__m128i vNegInf0;
113 simde__m128i vOpen;
114 simde__m128i vGap;
115 simde__m128i vZero;
116 simde__m128i vOne16;
117 simde__m128i vNegOne16;
118 simde__m128i vN16;
119 simde__m128i vILo16;
120 simde__m128i vIHi16;
121 simde__m128i vJresetLo16;
122 simde__m128i vJresetHi16;
123 simde__m128i vMaxH;
124 simde__m128i vEndILo;
125 simde__m128i vEndIHi;
126 simde__m128i vEndJLo;
127 simde__m128i vEndJHi;
128 simde__m128i vILimit16;
129 simde__m128i vJLimit16;
130 simde__m128i vTDiag;
131 simde__m128i vTIns;
132 simde__m128i vTDel;
133 simde__m128i vTZero;
134 simde__m128i vTDiagE;
135 simde__m128i vTInsE;
136 simde__m128i vTDiagF;
137 simde__m128i vTDelF;
138
139 /* validate inputs */
140 PARASAIL_CHECK_NULL(_s2);
141 PARASAIL_CHECK_GT0(s2Len);
142 PARASAIL_CHECK_GE0(open);
143 PARASAIL_CHECK_GE0(gap);
144 PARASAIL_CHECK_NULL(matrix);
145 if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
146 PARASAIL_CHECK_NULL(_s1);
147 PARASAIL_CHECK_GT0(_s1Len);
148 }
149
150 /* initialize stack variables */
151 N = 16; /* number of values in vector */
152 PAD = N-1;
153 PAD2 = PAD*2;
154 s1Len = matrix->type == PARASAIL_MATRIX_TYPE_SQUARE ? _s1Len : matrix->length;
155 s1Len_PAD = s1Len+PAD;
156 s2Len_PAD = s2Len+PAD;
157 i = 0;
158 j = 0;
159 end_query = 0;
160 end_ref = 0;
161 NEG_LIMIT = (-open < matrix->min ? INT8_MIN + open : INT8_MIN - matrix->min) + 1;
162 POS_LIMIT = INT8_MAX - matrix->max - 1;
163 score = NEG_LIMIT;
164 vNegLimit = simde_mm_set1_epi8(NEG_LIMIT);
165 vPosLimit = simde_mm_set1_epi8(POS_LIMIT);
166 vSaturationCheckMin = vPosLimit;
167 vSaturationCheckMax = vNegLimit;
168 vNegInf = simde_mm_set1_epi8(NEG_LIMIT);
169 vNegInf0 = simde_mm_srli_si128(vNegInf, 1); /* shift in a 0 */
170 vOpen = simde_mm_set1_epi8(open);
171 vGap = simde_mm_set1_epi8(gap);
172 vZero = simde_mm_set1_epi8(0);
173 vOne16 = simde_mm_set1_epi16(1);
174 vNegOne16 = simde_mm_set1_epi16(-1);
175 vN16 = simde_mm_set1_epi16(N);
176 vILo16 = simde_mm_set_epi16(8,9,10,11,12,13,14,15);
177 vIHi16 = simde_mm_set_epi16(0,1,2,3,4,5,6,7);
178 vJresetLo16 = simde_mm_set_epi16(-8,-9,-10,-11,-12,-13,-14,-15);
179 vJresetHi16 = simde_mm_set_epi16(0,-1,-2,-3,-4,-5,-6,-7);
180 vMaxH = vNegInf;
181 vEndILo = vNegInf;
182 vEndIHi = vNegInf;
183 vEndJLo = vNegInf;
184 vEndJHi = vNegInf;
185 vILimit16 = simde_mm_set1_epi16(s1Len);
186 vJLimit16 = simde_mm_set1_epi16(s2Len);
187 vTDiag = simde_mm_set1_epi8(PARASAIL_DIAG);
188 vTIns = simde_mm_set1_epi8(PARASAIL_INS);
189 vTDel = simde_mm_set1_epi8(PARASAIL_DEL);
190 vTZero = simde_mm_set1_epi8(PARASAIL_ZERO);
191 vTDiagE = simde_mm_set1_epi8(PARASAIL_DIAG_E);
192 vTInsE = simde_mm_set1_epi8(PARASAIL_INS_E);
193 vTDiagF = simde_mm_set1_epi8(PARASAIL_DIAG_F);
194 vTDelF = simde_mm_set1_epi8(PARASAIL_DEL_F);
195
196 /* initialize result */
197 result = parasail_result_new_trace(s1Len, s2Len, 16, sizeof(int8_t));
198 if (!result) return NULL;
199
200 /* set known flags */
201 result->flag |= PARASAIL_FLAG_SW | PARASAIL_FLAG_DIAG
202 | PARASAIL_FLAG_TRACE
203 | PARASAIL_FLAG_BITS_8 | PARASAIL_FLAG_LANES_16;
204
205 /* initialize heap variables */
206 s2B= parasail_memalign_int8_t(16, s2Len+PAD2);
207 _H_pr = parasail_memalign_int8_t(16, s2Len+PAD2);
208 _F_pr = parasail_memalign_int8_t(16, s2Len+PAD2);
209 s2 = s2B+PAD; /* will allow later for negative indices */
210 H_pr = _H_pr+PAD;
211 F_pr = _F_pr+PAD;
212
213 /* validate heap variables */
214 if (!s2B) return NULL;
215 if (!_H_pr) return NULL;
216 if (!_F_pr) return NULL;
217
218 /* convert _s1 from char to int in range 0-23 */
219 if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
220 s1 = parasail_memalign_int8_t(16, s1Len+PAD);
221 if (!s1) return NULL;
222 for (i=0; i<s1Len; ++i) {
223 s1[i] = matrix->mapper[(unsigned char)_s1[i]];
224 }
225 /* pad back of s1 with dummy values */
226 for (i=s1Len; i<s1Len_PAD; ++i) {
227 s1[i] = 0; /* point to first matrix row because we don't care */
228 }
229 }
230
231 /* convert _s2 from char to int in range 0-23 */
232 for (j=0; j<s2Len; ++j) {
233 s2[j] = matrix->mapper[(unsigned char)_s2[j]];
234 }
235 /* pad front of s2 with dummy values */
236 for (j=-PAD; j<0; ++j) {
237 s2[j] = 0; /* point to first matrix row because we don't care */
238 }
239 /* pad back of s2 with dummy values */
240 for (j=s2Len; j<s2Len_PAD; ++j) {
241 s2[j] = 0; /* point to first matrix row because we don't care */
242 }
243
244 /* set initial values for stored row */
245 for (j=0; j<s2Len; ++j) {
246 H_pr[j] = 0;
247 F_pr[j] = NEG_LIMIT;
248 }
249 /* pad front of stored row values */
250 for (j=-PAD; j<0; ++j) {
251 H_pr[j] = NEG_LIMIT;
252 F_pr[j] = NEG_LIMIT;
253 }
254 /* pad back of stored row values */
255 for (j=s2Len; j<s2Len+PAD; ++j) {
256 H_pr[j] = NEG_LIMIT;
257 F_pr[j] = NEG_LIMIT;
258 }
259
260 /* iterate over query sequence */
261 for (i=0; i<s1Len; i+=N) {
262 simde__m128i vNH = vNegInf0;
263 simde__m128i vWH = vNegInf0;
264 simde__m128i vE = vNegInf;
265 simde__m128i vE_opn = vNegInf;
266 simde__m128i vE_ext = vNegInf;
267 simde__m128i vF = vNegInf;
268 simde__m128i vF_opn = vNegInf;
269 simde__m128i vF_ext = vNegInf;
270 simde__m128i vJLo16 = vJresetLo16;
271 simde__m128i vJHi16 = vJresetHi16;
272 const int * const restrict matrow0 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+0] : ((i+0 >= s1Len) ? s1Len-1 : i+0))];
273 const int * const restrict matrow1 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+1] : ((i+1 >= s1Len) ? s1Len-1 : i+1))];
274 const int * const restrict matrow2 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+2] : ((i+2 >= s1Len) ? s1Len-1 : i+2))];
275 const int * const restrict matrow3 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+3] : ((i+3 >= s1Len) ? s1Len-1 : i+3))];
276 const int * const restrict matrow4 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+4] : ((i+4 >= s1Len) ? s1Len-1 : i+4))];
277 const int * const restrict matrow5 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+5] : ((i+5 >= s1Len) ? s1Len-1 : i+5))];
278 const int * const restrict matrow6 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+6] : ((i+6 >= s1Len) ? s1Len-1 : i+6))];
279 const int * const restrict matrow7 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+7] : ((i+7 >= s1Len) ? s1Len-1 : i+7))];
280 const int * const restrict matrow8 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+8] : ((i+8 >= s1Len) ? s1Len-1 : i+8))];
281 const int * const restrict matrow9 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+9] : ((i+9 >= s1Len) ? s1Len-1 : i+9))];
282 const int * const restrict matrow10 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+10] : ((i+10 >= s1Len) ? s1Len-1 : i+10))];
283 const int * const restrict matrow11 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+11] : ((i+11 >= s1Len) ? s1Len-1 : i+11))];
284 const int * const restrict matrow12 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+12] : ((i+12 >= s1Len) ? s1Len-1 : i+12))];
285 const int * const restrict matrow13 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+13] : ((i+13 >= s1Len) ? s1Len-1 : i+13))];
286 const int * const restrict matrow14 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+14] : ((i+14 >= s1Len) ? s1Len-1 : i+14))];
287 const int * const restrict matrow15 = &matrix->matrix[matrix->size * ((matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) ? s1[i+15] : ((i+15 >= s1Len) ? s1Len-1 : i+15))];
288 simde__m128i vIltLimit = simde_mm_packs_epi16(
289 simde_mm_cmplt_epi16(vILo16, vILimit16),
290 simde_mm_cmplt_epi16(vIHi16, vILimit16));
291 /* iterate over database sequence */
292 for (j=0; j<s2Len+PAD; ++j) {
293 simde__m128i vMat;
294 simde__m128i vNWH = vNH;
295 vNH = simde_mm_srli_si128(vWH, 1);
296 vNH = simde_mm_insert_epi8(vNH, H_pr[j], 15);
297 vF = simde_mm_srli_si128(vF, 1);
298 vF = simde_mm_insert_epi8(vF, F_pr[j], 15);
299 vF_opn = simde_mm_subs_epi8(vNH, vOpen);
300 vF_ext = simde_mm_subs_epi8(vF, vGap);
301 vF = simde_mm_max_epi8(vF_opn, vF_ext);
302 vE_opn = simde_mm_subs_epi8(vWH, vOpen);
303 vE_ext = simde_mm_subs_epi8(vE, vGap);
304 vE = simde_mm_max_epi8(vE_opn, vE_ext);
305 vMat = simde_mm_set_epi8(
306 matrow0[s2[j-0]],
307 matrow1[s2[j-1]],
308 matrow2[s2[j-2]],
309 matrow3[s2[j-3]],
310 matrow4[s2[j-4]],
311 matrow5[s2[j-5]],
312 matrow6[s2[j-6]],
313 matrow7[s2[j-7]],
314 matrow8[s2[j-8]],
315 matrow9[s2[j-9]],
316 matrow10[s2[j-10]],
317 matrow11[s2[j-11]],
318 matrow12[s2[j-12]],
319 matrow13[s2[j-13]],
320 matrow14[s2[j-14]],
321 matrow15[s2[j-15]]
322 );
323 vNWH = simde_mm_adds_epi8(vNWH, vMat);
324 vNWH = simde_mm_max_epi8(vNWH, vZero);
325 vWH = simde_mm_max_epi8(vNWH, vE);
326 vWH = simde_mm_max_epi8(vWH, vF);
327 /* as minor diagonal vector passes across the j=-1 boundary,
328 * assign the appropriate boundary conditions */
329 {
330 simde__m128i cond = simde_mm_packs_epi16(
331 simde_mm_cmpeq_epi16(vJLo16,vNegOne16),
332 simde_mm_cmpeq_epi16(vJHi16,vNegOne16));
333 vWH = simde_mm_andnot_si128(cond, vWH);
334 vF = simde_mm_blendv_epi8(vF, vNegInf, cond);
335 vE = simde_mm_blendv_epi8(vE, vNegInf, cond);
336 }
337 /* cannot start checking sat until after J clears boundary */
338 if (j > PAD) {
339 vSaturationCheckMin = simde_mm_min_epi8(vSaturationCheckMin, vWH);
340 vSaturationCheckMax = simde_mm_max_epi8(vSaturationCheckMax, vWH);
341 }
342 /* trace table */
343 {
344 simde__m128i cond_zero = simde_mm_cmpeq_epi8(vWH, vZero);
345 simde__m128i case1 = simde_mm_cmpeq_epi8(vWH, vNWH);
346 simde__m128i case2 = simde_mm_cmpeq_epi8(vWH, vF);
347 simde__m128i vT = simde_mm_blendv_epi8(
348 simde_mm_blendv_epi8(vTIns, vTDel, case2),
349 simde_mm_blendv_epi8(vTDiag, vTZero, cond_zero),
350 case1);
351 simde__m128i condE = simde_mm_cmpgt_epi8(vE_opn, vE_ext);
352 simde__m128i condF = simde_mm_cmpgt_epi8(vF_opn, vF_ext);
353 simde__m128i vET = simde_mm_blendv_epi8(vTInsE, vTDiagE, condE);
354 simde__m128i vFT = simde_mm_blendv_epi8(vTDelF, vTDiagF, condF);
355 vT = simde_mm_or_si128(vT, vET);
356 vT = simde_mm_or_si128(vT, vFT);
357 arr_store_si128(result->trace->trace_table, vT, i, s1Len, j, s2Len);
358 }
359 H_pr[j-15] = (int8_t)simde_mm_extract_epi8(vWH,0);
360 F_pr[j-15] = (int8_t)simde_mm_extract_epi8(vF,0);
361 /* as minor diagonal vector passes across table, extract
362 * max values within the i,j bounds */
363 {
364 simde__m128i cond_valid_J = simde_mm_and_si128(
365 simde_mm_packs_epi16(
366 simde_mm_cmpgt_epi16(vJLo16, vNegOne16),
367 simde_mm_cmpgt_epi16(vJHi16, vNegOne16)),
368 simde_mm_packs_epi16(
369 simde_mm_cmplt_epi16(vJLo16, vJLimit16),
370 simde_mm_cmplt_epi16(vJHi16, vJLimit16)));
371 simde__m128i cond_valid_IJ = simde_mm_and_si128(cond_valid_J, vIltLimit);
372 simde__m128i cond_eq = simde_mm_cmpeq_epi8(vWH, vMaxH);
373 simde__m128i cond_max = simde_mm_cmpgt_epi8(vWH, vMaxH);
374 simde__m128i cond_all = simde_mm_and_si128(cond_max, cond_valid_IJ);
375 simde__m128i cond_Jlt = simde_mm_packs_epi16(
376 simde_mm_cmplt_epi16(vJLo16, vEndJLo),
377 simde_mm_cmplt_epi16(vJHi16, vEndJHi));
378 simde__m128i cond_lo = simde_mm_unpacklo_epi8(cond_all, cond_all);
379 simde__m128i cond_hi = simde_mm_unpackhi_epi8(cond_all, cond_all);
380 vMaxH = simde_mm_blendv_epi8(vMaxH, vWH, cond_all);
381 vEndILo = simde_mm_blendv_epi8(vEndILo, vILo16, cond_lo);
382 vEndIHi = simde_mm_blendv_epi8(vEndIHi, vIHi16, cond_hi);
383 vEndJLo = simde_mm_blendv_epi8(vEndJLo, vJLo16, cond_lo);
384 vEndJHi = simde_mm_blendv_epi8(vEndJHi, vJHi16, cond_hi);
385 cond_all = simde_mm_and_si128(cond_Jlt, cond_eq);
386 cond_all = simde_mm_and_si128(cond_all, cond_valid_IJ);
387 cond_lo = simde_mm_unpacklo_epi8(cond_all, cond_all);
388 cond_hi = simde_mm_unpackhi_epi8(cond_all, cond_all);
389 vEndILo = simde_mm_blendv_epi8(vEndILo, vILo16, cond_lo);
390 vEndIHi = simde_mm_blendv_epi8(vEndIHi, vIHi16, cond_hi);
391 vEndJLo = simde_mm_blendv_epi8(vEndJLo, vJLo16, cond_lo);
392 vEndJHi = simde_mm_blendv_epi8(vEndJHi, vJHi16, cond_hi);
393 }
394 vJLo16 = simde_mm_add_epi16(vJLo16, vOne16);
395 vJHi16 = simde_mm_add_epi16(vJHi16, vOne16);
396 }
397 vILo16 = simde_mm_add_epi16(vILo16, vN16);
398 vIHi16 = simde_mm_add_epi16(vIHi16, vN16);
399 }
400
401 /* alignment ending position */
402 {
403 int8_t *t = (int8_t*)&vMaxH;
404 int16_t *ilo = (int16_t*)&vEndILo;
405 int16_t *jlo = (int16_t*)&vEndJLo;
406 int16_t *ihi = (int16_t*)&vEndIHi;
407 int16_t *jhi = (int16_t*)&vEndJHi;
408 int32_t k;
409 for (k=0; k<N/2; ++k, ++t, ++ilo, ++jlo) {
410 if (*t > score) {
411 score = *t;
412 end_query = *ilo;
413 end_ref = *jlo;
414 }
415 else if (*t == score) {
416 if (*jlo < end_ref) {
417 end_query = *ilo;
418 end_ref = *jlo;
419 }
420 else if (*jlo == end_ref && *ilo < end_query) {
421 end_query = *ilo;
422 end_ref = *jlo;
423 }
424 }
425 }
426 for (k=N/2; k<N; ++k, ++t, ++ihi, ++jhi) {
427 if (*t > score) {
428 score = *t;
429 end_query = *ihi;
430 end_ref = *jhi;
431 }
432 else if (*t == score) {
433 if (*jhi < end_ref) {
434 end_query = *ihi;
435 end_ref = *jhi;
436 }
437 else if (*jhi == end_ref && *ihi < end_query) {
438 end_query = *ihi;
439 end_ref = *jhi;
440 }
441 }
442 }
443 }
444
445 if (simde_mm_movemask_epi8(simde_mm_or_si128(
446 simde_mm_cmplt_epi8(vSaturationCheckMin, vNegLimit),
447 simde_mm_cmpgt_epi8(vSaturationCheckMax, vPosLimit)))) {
448 result->flag |= PARASAIL_FLAG_SATURATED;
449 score = 0;
450 end_query = 0;
451 end_ref = 0;
452 }
453
454 result->score = score;
455 result->end_query = end_query;
456 result->end_ref = end_ref;
457
458 parasail_free(_F_pr);
459 parasail_free(_H_pr);
460 parasail_free(s2B);
461 if (matrix->type == PARASAIL_MATRIX_TYPE_SQUARE) {
462 parasail_free(s1);
463 }
464
465 return result;
466 }
467
468