/** * @file * * @author jeff.daily@pnnl.gov * * Copyright (c) 2015 Battelle Memorial Institute. */ #include "config.h" #include %(HEADER)s #include "parasail.h" #include "parasail/memory.h" #include "parasail/internal_%(ISA)s.h" #define NEG_INF %(NEG_INF)s %(FIXES)s #ifdef PARASAIL_TABLE static inline void arr_store_si%(BITS)s( int *array, %(VTYPE)s vWscore, %(INDEX)s i, %(INDEX)s s1Len, %(INDEX)s j, %(INDEX)s s2Len) { %(PRINTER)s } #endif #ifdef PARASAIL_ROWCOL static inline void arr_store_rowcol( int *row, int *col, %(VTYPE)s vWscore, %(INDEX)s i, %(INDEX)s s1Len, %(INDEX)s j, %(INDEX)s s2Len) { %(PRINTER_ROWCOL)s } #endif #ifdef PARASAIL_TABLE #define FNAME %(NAME_TABLE)s #else #ifdef PARASAIL_ROWCOL #define FNAME %(NAME_ROWCOL)s #else #define FNAME %(NAME)s #endif #endif parasail_result_t* FNAME( const char * const restrict _s1, const int s1Len, const char * const restrict _s2, const int s2Len, const int open, const int gap, const parasail_matrix_t *matrix) { const %(INDEX)s N = %(LANES)s; /* number of values in vector */ const %(INDEX)s PAD = N-1; const %(INDEX)s PAD2 = PAD*2; const %(INDEX)s s1Len_PAD = s1Len+PAD; const %(INDEX)s s2Len_PAD = s2Len+PAD; %(INT)s * const restrict s1 = parasail_memalign_%(INT)s(%(ALIGNMENT)s, s1Len+PAD); %(INT)s * const restrict s2B = parasail_memalign_%(INT)s(%(ALIGNMENT)s, s2Len+PAD2); %(INT)s * const restrict _tbl_pr = parasail_memalign_%(INT)s(%(ALIGNMENT)s, s2Len+PAD2); %(INT)s * const restrict _del_pr = parasail_memalign_%(INT)s(%(ALIGNMENT)s, s2Len+PAD2); %(INT)s * const restrict _mch_pr = parasail_memalign_%(INT)s(%(ALIGNMENT)s, s2Len+PAD2); %(INT)s * const restrict _sim_pr = parasail_memalign_%(INT)s(%(ALIGNMENT)s, s2Len+PAD2); %(INT)s * const restrict _len_pr = parasail_memalign_%(INT)s(%(ALIGNMENT)s, s2Len+PAD2); %(INT)s * const restrict s2 = s2B+PAD; /* will allow later for negative indices */ %(INT)s * const restrict tbl_pr = _tbl_pr+PAD; %(INT)s * const restrict del_pr = _del_pr+PAD; %(INT)s * const restrict mch_pr = _mch_pr+PAD; %(INT)s * const restrict sim_pr = _sim_pr+PAD; %(INT)s * const restrict len_pr = _len_pr+PAD; #ifdef PARASAIL_TABLE parasail_result_t *result = parasail_result_new_table3(s1Len, s2Len); #else #ifdef PARASAIL_ROWCOL parasail_result_t *result = parasail_result_new_rowcol3(s1Len, s2Len); #else parasail_result_t *result = parasail_result_new(); #endif #endif %(INDEX)s i = 0; %(INDEX)s j = 0; %(INDEX)s end_query = 0; %(INDEX)s end_ref = 0; %(INT)s score = NEG_INF; %(INT)s matches = NEG_INF; %(INT)s similar = NEG_INF; %(INT)s length = NEG_INF; %(STATS_SATURATION_CHECK_INIT)s %(VTYPE)s vNegInf = %(VSET1)s(NEG_INF); %(VTYPE)s vOpen = %(VSET1)s(open); %(VTYPE)s vGap = %(VSET1)s(gap); %(VTYPE)s vZero = %(VSET1)s(0); %(VTYPE)s vOne = %(VSET1)s(1); %(VTYPE)s vN = %(VSET1)s(N); %(VTYPE)s vGapN = %(VSET1)s(gap*N); %(VTYPE)s vNegOne = %(VSET1)s(-1); %(VTYPE)s vI = %(VSET)s(%(DIAG_I)s); %(VTYPE)s vJreset = %(VSET)s(%(DIAG_J)s); %(VTYPE)s vMaxScore = vNegInf; %(VTYPE)s vMaxMatch = vNegInf; %(VTYPE)s vMaxSimilar = vNegInf; %(VTYPE)s vMaxLength = vNegInf; %(VTYPE)s vILimit = %(VSET1)s(s1Len); %(VTYPE)s vILimit1 = %(VSUB)s(vILimit, vOne); %(VTYPE)s vJLimit = %(VSET1)s(s2Len); %(VTYPE)s vJLimit1 = %(VSUB)s(vJLimit, vOne); %(VTYPE)s vIBoundary = %(VSET)s( %(DIAG_IBoundary)s); /* convert _s1 from char to int in range 0-23 */ for (i=0; imapper[(unsigned char)_s1[i]]; } /* pad back of s1 with dummy values */ for (i=s1Len; imapper[(unsigned char)_s2[j]]; } /* pad front of s2 with dummy values */ for (j=-PAD; j<0; ++j) { s2[j] = 0; /* point to first matrix row because we don't care */ } /* pad back of s2 with dummy values */ for (j=s2Len; jscore_table, vWscore, i, s1Len, j, s2Len); arr_store_si%(BITS)s(result->matches_table, vWmatch, i, s1Len, j, s2Len); arr_store_si%(BITS)s(result->similar_table, vWsimilar, i, s1Len, j, s2Len); arr_store_si%(BITS)s(result->length_table, vWlength, i, s1Len, j, s2Len); #endif #ifdef PARASAIL_ROWCOL arr_store_rowcol(result->score_row, result->score_col, vWscore, i, s1Len, j, s2Len); arr_store_rowcol(result->matches_row, result->matches_col, vWmatch, i, s1Len, j, s2Len); arr_store_rowcol(result->similar_row, result->similar_col, vWsimilar, i, s1Len, j, s2Len); arr_store_rowcol(result->length_row, result->length_col, vWlength, i, s1Len, j, s2Len); #endif tbl_pr[j-%(LAST_POS)s] = (%(INT)s)%(VEXTRACT)s(vWscore,0); mch_pr[j-%(LAST_POS)s] = (%(INT)s)%(VEXTRACT)s(vWmatch,0); sim_pr[j-%(LAST_POS)s] = (%(INT)s)%(VEXTRACT)s(vWsimilar,0); len_pr[j-%(LAST_POS)s] = (%(INT)s)%(VEXTRACT)s(vWlength,0); del_pr[j-%(LAST_POS)s] = (%(INT)s)%(VEXTRACT)s(vDel,0); /* as minor diagonal vector passes across table, extract last table value at the i,j bound */ { %(VTYPE)s cond_valid_I = %(VCMPEQ)s(vI, vILimit1); %(VTYPE)s cond_valid_J = %(VCMPEQ)s(vJ, vJLimit1); %(VTYPE)s cond_all = %(VAND)s(cond_valid_I, cond_valid_J); vMaxScore = %(VBLEND)s(vMaxScore, vWscore, cond_all); vMaxMatch = %(VBLEND)s(vMaxMatch, vWmatch, cond_all); vMaxSimilar = %(VBLEND)s(vMaxSimilar, vWsimilar, cond_all); vMaxLength = %(VBLEND)s(vMaxLength, vWlength, cond_all); } vJ = %(VADD)s(vJ, vOne); } vI = %(VADD)s(vI, vN); vIBoundary = %(VSUB)s(vIBoundary, vGapN); } /* max in vMaxScore */ for (i=0; i score) { score = value; matches = (%(INT)s) %(VEXTRACT)s(vMaxMatch, %(LAST_POS)s); similar = (%(INT)s) %(VEXTRACT)s(vMaxSimilar, %(LAST_POS)s); length= (%(INT)s) %(VEXTRACT)s(vMaxLength, %(LAST_POS)s); } vMaxScore = %(VSHIFT)s(vMaxScore, %(BYTES)s); vMaxMatch = %(VSHIFT)s(vMaxMatch, %(BYTES)s); vMaxSimilar = %(VSHIFT)s(vMaxSimilar, %(BYTES)s); vMaxLength = %(VSHIFT)s(vMaxLength, %(BYTES)s); } %(STATS_SATURATION_CHECK_FINAL)s result->score = score; result->matches = matches; result->similar = similar; result->length = length; result->end_query = end_query; result->end_ref = end_ref; parasail_free(_len_pr); parasail_free(_sim_pr); parasail_free(_mch_pr); parasail_free(_del_pr); parasail_free(_tbl_pr); parasail_free(s2B); parasail_free(s1); return result; }