| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#ifndef P7_IMPL_NEON_INCLUDED |
| 7 |
#define P7_IMPL_NEON_INCLUDED |
| 8 |
|
| 9 |
#include <p7_config.h> |
| 10 |
|
| 11 |
#include "esl_alphabet.h" |
| 12 |
#include "esl_neon.h" |
| 13 |
#include "esl_random.h" |
| 14 |
|
| 15 |
#include <arm_neon.h> |
| 16 |
#include "hmmer.h" |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#define p7O_NQB(M) ( ESL_MAX(2, ((((M)-1) / 16) + 1))) |
| 22 |
#define p7O_NQW(M) ( ESL_MAX(2, ((((M)-1) / 8) + 1))) |
| 23 |
#define p7O_NQF(M) ( ESL_MAX(2, ((((M)-1) / 4) + 1))) |
| 24 |
|
| 25 |
#define p7O_EXTRA_SB 17 |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
#define p7O_NXSTATES 4 |
| 66 |
#define p7O_NXTRANS 2 |
| 67 |
#define p7O_NTRANS 8 |
| 68 |
enum p7o_xstates_e { p7O_E = 0, p7O_N = 1, p7O_J = 2, p7O_C = 3 }; |
| 69 |
enum p7o_xtransitions_e { p7O_MOVE = 0, p7O_LOOP = 1 }; |
| 70 |
enum p7o_tsc_e { p7O_BM = 0, p7O_MM = 1, p7O_IM = 2, p7O_DM = 3, p7O_MD = 4, p7O_MI = 5, p7O_II = 6, p7O_DD = 7 }; |
| 71 |
|
| 72 |
typedef struct p7_oprofile_s { |
| 73 |
|
| 74 |
uint8x16_t **rbv; |
| 75 |
uint8x16_t **sbv; |
| 76 |
uint8_t tbm_b; |
| 77 |
uint8_t tec_b; |
| 78 |
uint8_t tjb_b; |
| 79 |
float scale_b; |
| 80 |
uint8_t base_b; |
| 81 |
uint8_t bias_b; |
| 82 |
|
| 83 |
|
| 84 |
int16x8_t **rwv; |
| 85 |
int16x8_t *twv; |
| 86 |
int16_t xw[p7O_NXSTATES][p7O_NXTRANS]; |
| 87 |
float scale_w; |
| 88 |
int16_t base_w; |
| 89 |
int16_t ddbound_w; |
| 90 |
float ncj_roundoff; |
| 91 |
|
| 92 |
|
| 93 |
float32x4_t **rfv; |
| 94 |
float32x4_t *tfv; |
| 95 |
float xf[p7O_NXSTATES][p7O_NXTRANS]; |
| 96 |
|
| 97 |
|
| 98 |
uint8x16_t *rbv_mem; |
| 99 |
uint8x16_t *sbv_mem; |
| 100 |
int16x8_t *rwv_mem; |
| 101 |
int16x8_t *twv_mem; |
| 102 |
float32x4_t *tfv_mem; |
| 103 |
float32x4_t *rfv_mem; |
| 104 |
|
| 105 |
|
| 106 |
off_t offs[p7_NOFFSETS]; |
| 107 |
|
| 108 |
|
| 109 |
off_t roff; |
| 110 |
off_t eoff; |
| 111 |
|
| 112 |
|
| 113 |
char *name; |
| 114 |
char *acc; |
| 115 |
char *desc; |
| 116 |
char *rf; |
| 117 |
char *mm; |
| 118 |
char *cs; |
| 119 |
char *consensus; |
| 120 |
float evparam[p7_NEVPARAM]; |
| 121 |
float cutoff[p7_NCUTOFFS]; |
| 122 |
float compo[p7_MAXABET]; |
| 123 |
const ESL_ALPHABET *abc; |
| 124 |
|
| 125 |
|
| 126 |
int L; |
| 127 |
int M; |
| 128 |
int max_length; |
| 129 |
int allocM; |
| 130 |
int allocQ4; |
| 131 |
int allocQ8; |
| 132 |
int allocQ16; |
| 133 |
int mode; |
| 134 |
float nj; |
| 135 |
|
| 136 |
int clone; |
| 137 |
|
| 138 |
|
| 139 |
} P7_OPROFILE; |
| 140 |
|
| 141 |
typedef struct { |
| 142 |
int count; |
| 143 |
int listSize; |
| 144 |
P7_OPROFILE **list; |
| 145 |
} P7_OM_BLOCK; |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
static inline float |
| 150 |
p7_oprofile_FGetEmission(const P7_OPROFILE *om, int k, int x) |
| 151 |
{ |
| 152 |
union { float32x4_t v; float p[4]; } u; |
| 153 |
int Q = p7O_NQF(om->M); |
| 154 |
int q = ((k-1) % Q); |
| 155 |
int r = (k-1)/Q; |
| 156 |
u.v = om->rfv[x][q]; |
| 157 |
return u.p[r]; |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
enum p7x_scells_e { p7X_M = 0, p7X_D = 1, p7X_I = 2 }; |
| 165 |
#define p7X_NSCELLS 3 |
| 166 |
|
| 167 |
|
| 168 |
enum p7x_xcells_e { p7X_E = 0, p7X_N = 1, p7X_J = 2, p7X_B = 3, p7X_C = 4, p7X_SCALE = 5 }; |
| 169 |
#define p7X_NXCELLS 6 |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
typedef struct p7_omx_s { |
| 181 |
int M; |
| 182 |
int L; |
| 183 |
|
| 184 |
|
| 185 |
float32x4_t **dpf; |
| 186 |
int16x8_t **dpw; |
| 187 |
uint8x16_t **dpb; |
| 188 |
void *dp_mem; |
| 189 |
int allocR; |
| 190 |
int validR; |
| 191 |
int allocQ4; |
| 192 |
int allocQ8; |
| 193 |
int allocQ16; |
| 194 |
int64_t ncells; |
| 195 |
|
| 196 |
|
| 197 |
float *xmx; |
| 198 |
void *x_mem; |
| 199 |
int allocXR; |
| 200 |
float totscale; |
| 201 |
int has_own_scales; |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
int debugging; |
| 207 |
FILE *dfp; |
| 208 |
} P7_OMX; |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
#define MMXo(q) (dp[(q) * p7X_NSCELLS + p7X_M]) |
| 214 |
#define DMXo(q) (dp[(q) * p7X_NSCELLS + p7X_D]) |
| 215 |
#define IMXo(q) (dp[(q) * p7X_NSCELLS + p7X_I]) |
| 216 |
#define XMXo(i,s) (xmx[(i) * p7X_NXCELLS + s]) |
| 217 |
|
| 218 |
|
| 219 |
#define MMO(dp,q) ((dp)[(q) * p7X_NSCELLS + p7X_M]) |
| 220 |
#define DMO(dp,q) ((dp)[(q) * p7X_NSCELLS + p7X_D]) |
| 221 |
#define IMO(dp,q) ((dp)[(q) * p7X_NSCELLS + p7X_I]) |
| 222 |
|
| 223 |
static inline float |
| 224 |
p7_omx_FGetMDI(const P7_OMX *ox, int s, int i, int k) |
| 225 |
{ |
| 226 |
union { float32x4_t v; float p[4]; } u; |
| 227 |
int Q = p7O_NQF(ox->M); |
| 228 |
int q = p7X_NSCELLS * ((k-1) % Q) + s; |
| 229 |
int r = (k-1)/Q; |
| 230 |
u.v = ox->dpf[i][q]; |
| 231 |
return u.p[r]; |
| 232 |
} |
| 233 |
|
| 234 |
static inline void |
| 235 |
p7_omx_FSetMDI(const P7_OMX *ox, int s, int i, int k, float val) |
| 236 |
{ |
| 237 |
union { float32x4_t v; float p[4]; } u; |
| 238 |
int Q = p7O_NQF(ox->M); |
| 239 |
int q = p7X_NSCELLS * ((k-1) % Q) + s; |
| 240 |
int r = (k-1)/Q; |
| 241 |
|
| 242 |
u.v = ox->dpf[i][q]; |
| 243 |
u.p[r] = val; |
| 244 |
ox->dpf[i][q] = u.v; |
| 245 |
} |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
extern P7_OMX *p7_omx_Create(int allocM, int allocL, int allocXL); |
| 256 |
extern int p7_omx_GrowTo(P7_OMX *ox, int allocM, int allocL, int allocXL); |
| 257 |
extern int p7_omx_FDeconvert(P7_OMX *ox, P7_GMX *gx); |
| 258 |
extern int p7_omx_Reuse (P7_OMX *ox); |
| 259 |
extern void p7_omx_Destroy(P7_OMX *ox); |
| 260 |
|
| 261 |
extern int p7_omx_SetDumpMode(FILE *fp, P7_OMX *ox, int truefalse); |
| 262 |
extern int p7_omx_DumpMFRow(P7_OMX *ox, int rowi, uint8_t xE, uint8_t xN, uint8_t xJ, uint8_t xB, uint8_t xC); |
| 263 |
extern int p7_omx_DumpVFRow(P7_OMX *ox, int rowi, int16_t xE, int16_t xN, int16_t xJ, int16_t xB, int16_t xC); |
| 264 |
extern int p7_omx_DumpFBRow(P7_OMX *ox, int logify, int rowi, int width, int precision, float xE, float xN, float xJ, float xB, float xC); |
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
extern P7_OPROFILE *p7_oprofile_Create(int M, const ESL_ALPHABET *abc); |
| 270 |
extern int p7_oprofile_IsLocal(const P7_OPROFILE *om); |
| 271 |
extern void p7_oprofile_Destroy(P7_OPROFILE *om); |
| 272 |
extern size_t p7_oprofile_Sizeof(P7_OPROFILE *om); |
| 273 |
extern P7_OPROFILE *p7_oprofile_Copy(P7_OPROFILE *om); |
| 274 |
extern P7_OPROFILE *p7_oprofile_Clone(const P7_OPROFILE *om); |
| 275 |
extern int p7_oprofile_UpdateFwdEmissionScores(P7_OPROFILE *om, P7_BG *bg, float *fwd_emissions, float *sc_arr); |
| 276 |
extern int p7_oprofile_UpdateVitEmissionScores(P7_OPROFILE *om, P7_BG *bg, float *fwd_emissions, float *sc_arr); |
| 277 |
extern int p7_oprofile_UpdateMSVEmissionScores(P7_OPROFILE *om, P7_BG *bg, float *fwd_emissions, float *sc_arr); |
| 278 |
|
| 279 |
|
| 280 |
extern int p7_oprofile_Convert(const P7_PROFILE *gm, P7_OPROFILE *om); |
| 281 |
extern int p7_oprofile_ReconfigLength (P7_OPROFILE *om, int L); |
| 282 |
extern int p7_oprofile_ReconfigMSVLength (P7_OPROFILE *om, int L); |
| 283 |
extern int p7_oprofile_ReconfigRestLength(P7_OPROFILE *om, int L); |
| 284 |
extern int p7_oprofile_ReconfigMultihit (P7_OPROFILE *om, int L); |
| 285 |
extern int p7_oprofile_ReconfigUnihit (P7_OPROFILE *om, int L); |
| 286 |
|
| 287 |
extern int p7_oprofile_Dump(FILE *fp, const P7_OPROFILE *om); |
| 288 |
extern int p7_oprofile_Sample(ESL_RANDOMNESS *r, const ESL_ALPHABET *abc, const P7_BG *bg, int M, int L, |
| 289 |
P7_HMM **opt_hmm, P7_PROFILE **opt_gm, P7_OPROFILE **ret_om); |
| 290 |
extern int p7_oprofile_Compare(const P7_OPROFILE *om1, const P7_OPROFILE *om2, float tol, char *errmsg); |
| 291 |
extern int p7_profile_SameAsMF(const P7_OPROFILE *om, P7_PROFILE *gm); |
| 292 |
extern int p7_profile_SameAsVF(const P7_OPROFILE *om, P7_PROFILE *gm); |
| 293 |
|
| 294 |
extern int p7_oprofile_GetFwdTransitionArray(const P7_OPROFILE *om, int type, float *arr ); |
| 295 |
extern int p7_oprofile_GetSSVEmissionScoreArray(const P7_OPROFILE *om, uint8_t *arr ); |
| 296 |
extern int p7_oprofile_GetFwdEmissionScoreArray(const P7_OPROFILE *om, float *arr ); |
| 297 |
extern int p7_oprofile_GetFwdEmissionArray(const P7_OPROFILE *om, P7_BG *bg, float *arr ); |
| 298 |
|
| 299 |
|
| 300 |
extern int p7_Decoding (const P7_OPROFILE *om, const P7_OMX *oxf, P7_OMX *oxb, P7_OMX *pp); |
| 301 |
extern int p7_DomainDecoding(const P7_OPROFILE *om, const P7_OMX *oxf, const P7_OMX *oxb, P7_DOMAINDEF *ddef); |
| 302 |
|
| 303 |
|
| 304 |
extern int p7_Forward (const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, P7_OMX *fwd, float *opt_sc); |
| 305 |
extern int p7_ForwardParser (const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, P7_OMX *fwd, float *opt_sc); |
| 306 |
extern int p7_Backward (const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, const P7_OMX *fwd, P7_OMX *bck, float *opt_sc); |
| 307 |
extern int p7_BackwardParser(const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, const P7_OMX *fwd, P7_OMX *bck, float *opt_sc); |
| 308 |
|
| 309 |
|
| 310 |
extern int p7_oprofile_Write(FILE *ffp, FILE *pfp, P7_OPROFILE *om); |
| 311 |
extern int p7_oprofile_ReadMSV (P7_HMMFILE *hfp, ESL_ALPHABET **byp_abc, P7_OPROFILE **ret_om); |
| 312 |
extern int p7_oprofile_ReadInfoMSV(P7_HMMFILE *hfp, ESL_ALPHABET **byp_abc, P7_OPROFILE **ret_om); |
| 313 |
extern int p7_oprofile_ReadBlockMSV(P7_HMMFILE *hfp, ESL_ALPHABET **byp_abc, P7_OM_BLOCK *hmmBlock); |
| 314 |
extern int p7_oprofile_ReadRest(P7_HMMFILE *hfp, P7_OPROFILE *om); |
| 315 |
extern int p7_oprofile_Position(P7_HMMFILE *hfp, off_t offset); |
| 316 |
|
| 317 |
extern P7_OM_BLOCK *p7_oprofile_CreateBlock(int size); |
| 318 |
extern void p7_oprofile_DestroyBlock(P7_OM_BLOCK *block); |
| 319 |
|
| 320 |
|
| 321 |
extern int p7_SSVFilter (const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, float *ret_sc); |
| 322 |
|
| 323 |
|
| 324 |
extern int p7_MSVFilter (const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, P7_OMX *ox, float *ret_sc); |
| 325 |
extern int p7_SSVFilter_longtarget(const ESL_DSQ *dsq, int L, P7_OPROFILE *om, P7_OMX *ox, const P7_SCOREDATA *msvdata, P7_BG *bg, double P, P7_HMM_WINDOWLIST *windowlist); |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
extern int p7_Null2_ByExpectation(const P7_OPROFILE *om, const P7_OMX *pp, float *null2); |
| 330 |
extern int p7_Null2_ByTrace (const P7_OPROFILE *om, const P7_TRACE *tr, int zstart, int zend, P7_OMX *wrk, float *null2); |
| 331 |
|
| 332 |
|
| 333 |
extern int p7_OptimalAccuracy(const P7_OPROFILE *om, const P7_OMX *pp, P7_OMX *ox, float *ret_e); |
| 334 |
extern int p7_OATrace (const P7_OPROFILE *om, const P7_OMX *pp, const P7_OMX *ox, P7_TRACE *tr); |
| 335 |
|
| 336 |
|
| 337 |
extern int p7_StochasticTrace(ESL_RANDOMNESS *rng, const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, const P7_OMX *ox, P7_TRACE *tr); |
| 338 |
|
| 339 |
|
| 340 |
extern int p7_ViterbiFilter(const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, P7_OMX *ox, float *ret_sc); |
| 341 |
extern int p7_ViterbiFilter_longtarget(const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, P7_OMX *ox, |
| 342 |
float filtersc, double P, P7_HMM_WINDOWLIST *windowlist); |
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
extern int p7_ViterbiScore (const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, P7_OMX *ox, float *ret_sc); |
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
static inline void |
| 353 |
impl_Init(void) |
| 354 |
{ |
| 355 |
#ifdef HAVE_FLUSH_ZERO_MODE |
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); |
| 361 |
#endif |
| 362 |
|
| 363 |
#ifdef _PMMINTRIN_H_INCLUDED |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); |
| 371 |
#endif |
| 372 |
} |
| 373 |
#endif |