-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalignment_simd.h
303 lines (248 loc) · 12.5 KB
/
alignment_simd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#ifndef _ALIGNMENT_SIMD_H_
#define _ALIGNMENT_SIMD_H_
/**
* AVX512BW/AVX2/SSE2/SSE/"not" : number of allowed indels relates to the SIMD filter and the possible size of the bandwidth alignment
*/
#ifdef __AVX512BW__
#define INDEL_DATA_VECTOR_SIZE (16)
#else
#ifdef __AVX2__
#define INDEL_DATA_VECTOR_SIZE (16)
#else
#ifdef __SSE2__
#define INDEL_DATA_VECTOR_SIZE (16)
#else
#ifdef __SSE__
#define INDEL_DATA_VECTOR_SIZE (8)
#else
/* No filter. Default to 7 indels (above this, the alignment algorithm would be much too slow). */
#define INDEL_DATA_VECTOR_SIZE (8)
#endif
#endif
#endif
#endif
/**
* AVX512BW/AVX2/SSE2/SSE check function : check if the CPU is OK for all that stuff ...
* @return true if the processor is avx512bw/avx2/sse2/sse compatible, false otherwise ...
*/
int alignment_avx512bw__compatible_proc(void);
int alignment_avx2__compatible_proc(void);
int alignment_sse2__compatible_proc(void);
int alignment_sse__compatible_proc(void);
/**
* All the functions provided here need "avx512"/"avx2"/"sse2"/"sse" inctructions
*/
/**
* AVX512BW/AVX2/SSE2/SSE alignment init function : fix the scoring system and the length of the reads (must be called once before aligning)
* @param match inits the match score vector (positive value only)
* @param mismatch inits the mismatch penalty vector (positive value only)
* @param gapopen inits the gap penalty vector (positive value only)
* @param gapextends inits the gap penalty vector (positive value only)
* @param threshold inits the scoring threshold (positive value only)
* @param length fixes the length of the reads that will be treated : this value can be changed with some functions below
* (but must not be changed too frequently).
*/
#ifdef __AVX512BW__
void alignment_avx512bw__init_tria(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
void alignment_avx512bw__init_hexa(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
void alignment_avx512bw__init_octa(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
void alignment_avx512bw__init_quad(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
#endif
#ifdef __AVX2__
void alignment_avx2__init_hexa(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
void alignment_avx2__init_octa(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
void alignment_avx2__init_quad(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
void alignment_avx2__init_pair(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
#endif
#ifdef __SSE2__
void alignment_sse2__init_octa(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
void alignment_sse2__init_quad(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
void alignment_sse2__init_pair(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
void alignment_sse2__init_mono(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
#endif
#ifdef __SSE__
void alignment_sse__init_quad(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
void alignment_sse__init_pair(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapextends,
const unsigned int threshold,
const unsigned int readlength);
void alignment_sse__init_mono(const unsigned int match,
const unsigned int mismatch,
const unsigned int gapopen,
const unsigned int gapoextends,
const unsigned int threshold,
const unsigned int readlength);
#endif
/**
* AVX512BW/AVX2/SSE2/SSE alignment align function : does a banded Smith-Waterman of the given read against two parts of the genome;
* allows at most 1/2, 3/4, 7/8 or 15/16 indels on each left/right (or right/left) side.
* @param genome is the compressed genome (first nucleotide are the two lower bits of the first byte)
* @param pos_genome gives the list of 32, 16, 8, 4, 2 or 1 positions (in term of nucleotides) to be aligned with the read
* (you must substract 1 (or 2), 3 (or 4), 7 (or 8), 15 (or 16) potential indels respectively according to the hit position)
* @param read is the compressed read (first nucleotide are the two lower bits of the first byte)
* @return 0 if none is aligned to reach the given threshold (what should happened most of the time),
* or a bitmask 1<<(x) | 1<<(y) if x or y align correctly.
*/
#ifdef __AVX512BW__
unsigned int alignment_avx512bw__align_tria(unsigned char * genome,
int * pos_genome,
unsigned char * read);
unsigned int alignment_avx512bw__align_hexa(unsigned char * genome,
int * pos_genome,
unsigned char * read);
unsigned int alignment_avx512bw__align_octa(unsigned char * genome,
int * pos_genome,
unsigned char * read);
unsigned int alignment_avx512bw__align_quad(unsigned char * genome,
int * pos_genome,
unsigned char * read);
#endif
#ifdef __AVX2__
unsigned int alignment_avx2__align_hexa(unsigned char * genome,
int * pos_genome,
unsigned char * read);
unsigned int alignment_avx2__align_octa(unsigned char * genome,
int * pos_genome,
unsigned char * read);
unsigned int alignment_avx2__align_quad(unsigned char * genome,
int * pos_genome,
unsigned char * read);
unsigned int alignment_avx2__align_pair(unsigned char * genome,
int * pos_genome,
unsigned char * read);
#endif
#ifdef __SSE2__
unsigned int alignment_sse2__align_octa(unsigned char * genome,
int * pos_genome,
unsigned char * read);
unsigned int alignment_sse2__align_quad(unsigned char * genome,
int * pos_genome,
unsigned char * read);
unsigned int alignment_sse2__align_pair(unsigned char * genome,
int * pos_genome,
unsigned char * read);
unsigned int alignment_sse2__align_mono(unsigned char * genome,
int * pos_genome,
unsigned char * read);
#endif
#ifdef __SSE__
unsigned int alignment_sse__align_quad(unsigned char * genome,
int * pos_genome,
unsigned char * read);
unsigned int alignment_sse__align_pair(unsigned char * genome,
int * pos_genome,
unsigned char * read);
unsigned int alignment_sse__align_mono(unsigned char * genome,
int * pos_genome,
unsigned char * read);
#endif
/**
* AVX512BW/AVX2/SSE2/SSE alignment init read function : modify the read length when needed (but must not be changed too frequently).
* @param readlength gives the read length (number of nucleotides inside the read)
*/
#ifdef __AVX512BW__
void alignment_avx512bw__setlength_tria(unsigned int readlength);
void alignment_avx512bw__setlength_hexa(unsigned int readlength);
void alignment_avx512bw__setlength_octa(unsigned int readlength);
void alignment_avx512bw__setlength_quad(unsigned int readlength);
#endif
#ifdef __AVX2__
void alignment_avx2__setlength_hexa(unsigned int readlength);
void alignment_avx2__setlength_octa(unsigned int readlength);
void alignment_avx2__setlength_quad(unsigned int readlength);
void alignment_avx2__setlength_pair(unsigned int readlength);
#endif
#ifdef __SSE2__
void alignment_sse2__setlength_octa(unsigned int readlength);
void alignment_sse2__setlength_quad(unsigned int readlength);
void alignment_sse2__setlength_pair(unsigned int readlength);
void alignment_sse2__setlength_mono(unsigned int readlength);
#endif
#ifdef __SSE__
void alignment_sse__setlength_quad(unsigned int readlength);
void alignment_sse__setlength_pair(unsigned int readlength);
void alignment_sse__setlength_mono(unsigned int readlength);
#endif
/**
* AVX512BW/AVX2/SSE2/SSE alignment clean function : free allocated memory
*/
#ifdef __AVX512BW__
void alignment_avx512bw__clean(void);
#endif
#ifdef __AVX2__
void alignment_avx2__clean(void);
#endif
#ifdef __SSE2__
void alignment_sse2__clean(void);
#endif
#ifdef __SSE__
void alignment_sse__clean(void);
#endif
#endif /* _ALIGNMENT_SIMD_H_ */