Skip to content

Commit 0777e27

Browse files
committed
Don't expose simd.h in any MMseqs2 header
1 parent 73e15d1 commit 0777e27

27 files changed

+1327
-1368
lines changed

lib/simd/simd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// optimze based on technolegy double, float and integer (32) SIMD instructions
33
// writen by Martin Steinegger
44

5+
// #ifdef SIMD_H
6+
// #error "simd.h included multiple times in the same translation unit"
7+
// #endif
8+
59
#ifndef SIMD_H
610
#define SIMD_H
711
#include <cstdlib>

src/alignment/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ set(alignment_source_files
2323
alignment/PSSMCalculator.cpp
2424
alignment/StripedSmithWaterman.cpp
2525
alignment/BandedNucleotideAligner.cpp
26+
alignment/DistanceCalculator.cpp
2627
alignment/rescorediagonal.cpp
2728
alignment/Fwbw.cpp
2829
PARENT_SCOPE
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include "DistanceCalculator.h"
2+
3+
#include "simd.h"
4+
5+
template<typename T>
6+
unsigned int DistanceCalculator::computeInverseHammingDistance(const T *seq1, const T *seq2, unsigned int length){
7+
unsigned int diff = 0;
8+
unsigned int simdBlock = length/(VECSIZE_INT*4);
9+
simd_int * simdSeq1 = (simd_int *) seq1;
10+
simd_int * simdSeq2 = (simd_int *) seq2;
11+
for (unsigned int pos = 0; pos < simdBlock; pos++ ) {
12+
simd_int seq1vec = simdi_loadu(simdSeq1+pos);
13+
simd_int seq2vec = simdi_loadu(simdSeq2+pos);
14+
// int _mm_movemask_epi8(__m128i a) creates 16-bit mask from most significant bits of
15+
// the 16 signed or unsigned 8-bit integers in a and zero-extends the upper bits.
16+
simd_int seqComparision = simdi8_eq(seq1vec, seq2vec);
17+
int res = simdi8_movemask(seqComparision);
18+
diff += __builtin_popcount(res); // subtract positions that should not contribute to coverage
19+
}
20+
// compute missing rest
21+
for (unsigned int pos = simdBlock*(VECSIZE_INT*4); pos < length; pos++ ) {
22+
diff += (seq1[pos] == seq2[pos]);
23+
}
24+
return diff;
25+
}
26+
27+
template unsigned int DistanceCalculator::computeInverseHammingDistance<char>(const char *seq1, const char *seq2, unsigned int length);

src/alignment/DistanceCalculator.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <cstring>
66
#include <vector>
77

8-
#include "simd.h"
98
#include "MathUtil.h"
109
#include "BaseMatrix.h"
1110
#include "Parameters.h"
@@ -273,26 +272,7 @@ class DistanceCalculator {
273272

274273

275274
template<typename T>
276-
static unsigned int computeInverseHammingDistance(const T *seq1, const T *seq2, unsigned int length){
277-
unsigned int diff = 0;
278-
unsigned int simdBlock = length/(VECSIZE_INT*4);
279-
simd_int * simdSeq1 = (simd_int *) seq1;
280-
simd_int * simdSeq2 = (simd_int *) seq2;
281-
for (unsigned int pos = 0; pos < simdBlock; pos++ ) {
282-
simd_int seq1vec = simdi_loadu(simdSeq1+pos);
283-
simd_int seq2vec = simdi_loadu(simdSeq2+pos);
284-
// int _mm_movemask_epi8(__m128i a) creates 16-bit mask from most significant bits of
285-
// the 16 signed or unsigned 8-bit integers in a and zero-extends the upper bits.
286-
simd_int seqComparision = simdi8_eq(seq1vec, seq2vec);
287-
int res = simdi8_movemask(seqComparision);
288-
diff += __builtin_popcount(res); // subtract positions that should not contribute to coverage
289-
}
290-
// compute missing rest
291-
for (unsigned int pos = simdBlock*(VECSIZE_INT*4); pos < length; pos++ ) {
292-
diff += (seq1[pos] == seq2[pos]);
293-
}
294-
return diff;
295-
}
275+
static unsigned int computeInverseHammingDistance(const T *seq1, const T *seq2, unsigned int length);
296276

297277

298278

src/alignment/MultipleAlignment.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "MultipleAlignment.h"
22

33
#include "Debug.h"
4+
#include "simd.h"
45
#include "Sequence.h"
56
#include "SubstitutionMatrix.h"
67
#include "Util.h"

0 commit comments

Comments
 (0)