1 /* $Id: oligoindex_hr.h 218167 2019-01-17 06:23:27Z twu $ */ 2 #ifndef OLIGOINDEX_HR_INCLUDED 3 #define OLIGOINDEX_HR_INCLUDED 4 5 #include "bool.h" 6 #include "types.h" 7 #include "univcoord.h" 8 9 #include "mode.h" 10 #include "genomicpos.h" 11 #include "list.h" 12 #include "diagpool.h" 13 14 15 #if 0 16 /* Old code, no longer used */ 17 #define OVERABUNDANCE_CHECK 50 18 #define OVERABUNDANCE_PCT 0.97 19 #define OVERABUNDANCE_MIN 200 20 #endif 21 22 /* Attempted to use int, so we could use i32gather_epi32. However, SIMD is much faster on bytes than on ints */ 23 typedef unsigned char Count_T; 24 typedef unsigned char Inquery_T; 25 #define INQUERY_FALSE 0x00 26 #define INQUERY_TRUE 0xFF 27 #define INCR_COUNT(counts) counts += 1; 28 29 #if defined(HAVE_AVX512) 30 #define SIMD_NELTS 64 /* 64 bytes in 256 bits */ 31 #elif defined(HAVE_AVX2) 32 #define SIMD_NELTS 32 /* 32 bytes in 256 bits */ 33 #elif defined(HAVE_SSE2) 34 #define SIMD_NELTS 16 /* 16 bytes in 128 bits */ 35 #endif 36 37 38 /* These need to be here, because the struct is here */ 39 #ifdef HAVE_SSE2 40 #include <emmintrin.h> 41 #endif 42 #ifdef HAVE_SSSE3 43 #include <tmmintrin.h> 44 #endif 45 #ifdef HAVE_SSE4_1 46 #include <smmintrin.h> 47 #endif 48 #ifdef HAVE_AVX2 49 #include <immintrin.h> 50 #endif 51 #ifdef HAVE_AVX512 52 #include <immintrin.h> 53 #endif 54 55 56 #define T Oligoindex_T 57 typedef struct T *T; 58 struct T { 59 60 int indexsize; 61 Shortoligomer_T mask; 62 63 int diag_lookback; 64 int suffnconsecutive; 65 66 /* bool query_evaluated_p; */ 67 68 Oligospace_T oligospace; 69 #if defined(HAVE_AVX512) 70 __m512i *inquery_allocated; 71 __m512i *counts_allocated; 72 #elif defined(HAVE_AVX2) 73 __m256i *inquery_allocated; 74 __m256i *counts_allocated; 75 #elif defined(HAVE_SSE2) 76 __m128i *inquery_allocated; 77 __m128i *counts_allocated; 78 #endif 79 Inquery_T *inquery; 80 Count_T *counts; 81 82 Chrpos_T *table; 83 UINT4 *positions; 84 /* UINT4 *pointers; */ 85 /* UINT4 *pointers_allocated; */ 86 }; 87 88 89 90 typedef struct Oligoindex_array_T *Oligoindex_array_T; 91 92 extern void 93 Oligoindex_hr_setup (Genomecomp_T *ref_blocks_in, Mode_T mode_in); 94 95 extern int 96 Oligoindex_indexsize (T this); 97 98 extern int 99 Oligoindex_array_length (Oligoindex_array_T oligoindices); 100 extern T 101 Oligoindex_array_elt (Oligoindex_array_T oligoindices, int source); 102 103 extern Oligoindex_array_T 104 Oligoindex_array_new_major (int max_querylength, int max_genomiclength); 105 106 extern Oligoindex_array_T 107 Oligoindex_array_new_minor (int max_querylength, int max_genomiclength); 108 109 extern Chrpos_T * 110 Oligoindex_allocate_positions (UINT4 *__restrict__ positions, 111 Inquery_T *__restrict__ inquery, Count_T *counts, int oligospace); 112 113 114 extern double 115 Oligoindex_set_inquery (int *badoligos, int *repoligos, int *trimoligos, int *trim_start, int *trim_end, 116 T this, char *queryuc_ptr, int querystart, int queryend, bool trimp); 117 extern void 118 Oligoindex_hr_tally (T this, Univcoord_T mappingstart, Univcoord_T mappingend, bool plusp, 119 char *queryuc_ptr, int querystart, int queryend, Chrpos_T chrpos, int genestrand); 120 extern void 121 Oligoindex_untally (T this); 122 extern void 123 Oligoindex_clear_inquery (T this, char *queryuc_ptr, int querystart, int queryend); 124 extern void 125 Oligoindex_array_free(Oligoindex_array_T *old); 126 127 extern List_T 128 Oligoindex_get_mappings (List_T diagonals, bool *coveredp, Chrpos_T **mappings, int *npositions, 129 int *totalpositions, bool *oned_matrix_p, int *maxnconsecutive, 130 Oligoindex_array_T array, T this, char *queryuc_ptr, 131 int querystart, int queryend, int querylength, 132 Chrpos_T chrstart, Chrpos_T chrend, 133 Univcoord_T chroffset, Univcoord_T chrhigh, bool plusp, 134 Diagpool_T diagpool); 135 136 #undef T 137 #endif 138 139