Skip to content

Commit 3a8c05f

Browse files
authored
Merge pull request #3 from criniguez/dev
Adding vectorized banded bpm implementation.
2 parents 6f18b83 + 74db1b4 commit 3a8c05f

File tree

14 files changed

+670
-56
lines changed

14 files changed

+670
-56
lines changed

.github/workflows/build_and_test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
- '**/LICENSE'
1010
pull_request:
1111
branches: [ main ]
12+
paths-ignore: # Skip the workflow if only documentation files are changed
13+
- '**/*.md'
14+
- '**/LICENSE'
1215
workflow_dispatch:
1316

1417
jobs:

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
2424

2525
# Ignore known non-concerning warnings
2626
add_compile_options("$<$<COMPILE_LANGUAGE:C>:-Wno-override-init>")
27+
add_compile_options(-Wno-error=cpp) # #warning are not errors
2728

2829
# Enable code coverage
2930
add_compile_options(--coverage)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ The `quicked_params_t` configuration struct has the following parameters:
230230
* **unsigned int** `hew_threshold[2]`: The error percentage threshold inside a window to be considered a high error window (HEW). This parameter is only used inside Quicked. Position [0] refers to the WindowEd(S) step and position [1] to the WindowEd(L) step.
231231
* **unsigned int** `hew_percentage[2]`: percentage of HEW in a particular WindowEd alignment to consider that the estimation is not fitted. This parameter is only used inside Quicked. Position [0] refers to the WindowEd(S) step and position [1] to the WindowEd(L) step.
232232
* **bool** `only_score`: If set to true, turn off the CIGAR generation for the WindowEd and BandEd methods.
233-
* **bool** `force_scalar`: If set to true, it forces the WindowEd implementation to use the scalar code.
233+
* **bool** `force_scalar`: If set to true, it forces WindowEd and BandEd implementation to use the scalar code.
234234

235235
> [!WARNING]
236236
> **Experimental Parameters**

examples/bindings/basic.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ int main(void) {
4242

4343
aligner.align(&pattern, &text); // Align the sequences!
4444

45-
aligner.getScore(); // Get the score
46-
aligner.getCigar(); // Get the CIGAR string
45+
score = aligner.getScore(); // Get the score
46+
cigar = aligner.getCigar(); // Get the CIGAR string
4747
} catch (quicked::QuickedException &e) {
4848
cerr << e.what() << endl;
4949
return 1;
@@ -53,4 +53,4 @@ int main(void) {
5353
cout << "Cigar: " << cigar << endl; // Print the CIGAR string
5454

5555
return 0;
56-
}
56+
}

examples/bindings/basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@
4040
except QuickedEception as e:
4141
print(e)
4242

43-
print(f"Score: {aligner.getScore()}") # Print the score
44-
print(f"Cigar: {aligner.getCigar()}") # Print the CIGAR string
43+
print(f"Score: {score}") # Print the score
44+
print(f"Cigar: {cigar}") # Print the CIGAR string
4545

examples/bindings/params.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ int main(void) {
4747

4848
aligner.align(&pattern, &text); // Align the sequences!
4949

50-
aligner.getScore(); // Get the score
51-
aligner.getCigar(); // Get the CIGAR string
50+
score = aligner.getScore(); // Get the score
51+
cigar = aligner.getCigar(); // Get the CIGAR string
5252
} catch (quicked::QuickedException &e) {
5353
cerr << e.what() << endl;
5454
return 1;
@@ -58,4 +58,4 @@ int main(void) {
5858
cout << "Cigar <Expecting NULL>: " << cigar << endl; // We didn't compute the CIGAR, so it's NULL
5959

6060
return 0;
61-
}
61+
}

quicked/include/bpm_banded.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ void banded_compute(
9090
const char* text,
9191
const int64_t text_length,
9292
const int64_t text_finish_pos,
93-
const bool only_score);
93+
const bool only_score,
94+
const bool force_scalar);
9495

9596
#endif /* BPM_BANDED_H_ */

quicked/include/bpm_commons.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,53 @@
100100
Pv = Mh | ~(Xv | Ph); \
101101
Mv = Ph & Xv
102102

103+
#define BPM_ADVANCE_BLOCK_SI256(Eq, mask, Pv, Mv, PHin, MHin, PHout, MHout) \
104+
__m256i Xv = _mm256_or_si256(Eq, Mv); /*Eq | Mv*/ \
105+
__m256i _Eq = _mm256_or_si256(Eq, MHin); /*Eq | MHin*/ \
106+
__m256i Xh = _mm256_and_si256(_Eq, Pv); /*(((_Eq & Pv) + Pv) ^ Pv) | _Eq*/ \
107+
Xh = _mm256_add_epi64(Xh, Pv); \
108+
Xh = _mm256_xor_si256(Xh, Pv); \
109+
Xh = _mm256_or_si256(Xh, _Eq); \
110+
__m256i Ph = _mm256_or_si256(Xh, Pv); /*Mv | ~(Xh | Pv)*/ \
111+
Ph = _mm256_or_si256(Mv, ~Ph); \
112+
__m256i Mh = _mm256_and_si256(Pv, Xh); /*Pv & Xh*/ \
113+
PHout = _mm256_and_si256(Ph, mask); /*(Ph & mask) != 0*/ \
114+
PHout = _mm256_cmpeq_epi64(PHout, _mm256_setzero_si256()); \
115+
PHout = _mm256_andnot_si256(PHout, _mm256_set1_epi64x(1)); \
116+
MHout = _mm256_and_si256(Mh, mask); /*(Mh & mask) != 0 */ \
117+
MHout = _mm256_cmpeq_epi64(MHout, _mm256_setzero_si256()); \
118+
MHout = _mm256_andnot_si256(MHout, _mm256_set1_epi64x(1)); \
119+
Ph = _mm256_slli_epi64(Ph, 1); /*Ph <<= 1*/ \
120+
Mh = _mm256_slli_epi64(Mh, 1); /*Mh <<= 1*/ \
121+
Ph = _mm256_or_si256(Ph, PHin); /*Ph |= PHin*/ \
122+
Mh = _mm256_or_si256(Mh, MHin); /*Mh |= MHin*/ \
123+
Pv = _mm256_or_si256(Xv, Ph); /*Mh | ~(Xv | Ph)*/ \
124+
Pv = _mm256_or_si256(Mh, ~Pv); \
125+
Mv = _mm256_and_si256(Ph, Xv); \
126+
127+
128+
#define BPM_ADVANCE_BLOCK_SI256_2(Eq2, mask2, Pv2, Mv2, PHin2, MHin2, PHout2, MHout2) \
129+
__m256i Xv2 = _mm256_or_si256(Eq2, Mv2); /*Eq | Mv*/ \
130+
__m256i _Eq2 = _mm256_or_si256(Eq2, MHin2); /*Eq | MHin*/ \
131+
__m256i Xh2 = _mm256_and_si256(_Eq2, Pv2); /*(((_Eq & Pv) + Pv) ^ Pv) | _Eq*/ \
132+
Xh2 = _mm256_add_epi64(Xh2, Pv2); \
133+
Xh2 = _mm256_xor_si256(Xh2, Pv2); \
134+
Xh2 = _mm256_or_si256(Xh2, _Eq2); \
135+
__m256i Ph2 = _mm256_or_si256(Xh2, Pv2); /*Mv | ~(Xh | Pv)*/ \
136+
Ph2 = _mm256_or_si256(Mv2, ~Ph2); \
137+
__m256i Mh2 = _mm256_and_si256(Pv2, Xh2); /*Pv & Xh*/ \
138+
PHout2 = _mm256_and_si256(Ph2, mask2); /*(Ph & mask) != 0*/ \
139+
PHout2 = _mm256_cmpeq_epi64(PHout2, _mm256_setzero_si256()); \
140+
PHout2 = _mm256_andnot_si256(PHout2, _mm256_set1_epi64x(1)); \
141+
MHout2 = _mm256_and_si256(Mh2, mask2); /*(Mh & mask) != 0 */ \
142+
MHout2 = _mm256_cmpeq_epi64(MHout2, _mm256_setzero_si256()); \
143+
MHout2 = _mm256_andnot_si256(MHout2, _mm256_set1_epi64x(1)); \
144+
Ph2 = _mm256_slli_epi64(Ph2, 1); /*Ph <<= 1*/ \
145+
Mh2 = _mm256_slli_epi64(Mh2, 1); /*Mh <<= 1*/ \
146+
Ph2 = _mm256_or_si256(Ph2, PHin2); /*Ph |= PHin*/ \
147+
Mh2 = _mm256_or_si256(Mh2, MHin2); /*Mh |= MHin*/ \
148+
Pv2 = _mm256_or_si256(Xv2, Ph2); /*Mh | ~(Xv | Ph)*/ \
149+
Pv2 = _mm256_or_si256(Mh2, ~Pv2); \
150+
Mv2 = _mm256_and_si256(Ph2, Xv2); \
151+
103152
#endif /* BPM_COMMON_H_ */

quicked/include/bpm_hirschberg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ quicked_status_t bpm_compute_matrix_hirschberg(
3737
const int64_t pattern_length,
3838
const int64_t cutoff_score,
3939
cigar_t* cigar_out,
40+
const bool force_scalar,
4041
mm_allocator_t* const mm_allocator);
4142

4243
#endif /* BPM_HIRSCHBERG_H_ */

0 commit comments

Comments
 (0)