Skip to content

Commit

Permalink
Merge pull request #37 from ekg/wflign-through
Browse files Browse the repository at this point in the history
erode and patch alignments in one pass
  • Loading branch information
ekg authored Apr 22, 2021
2 parents 2314c8d + c541e70 commit 1e10586
Show file tree
Hide file tree
Showing 4 changed files with 664 additions and 250 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,30 +159,33 @@ void affine_wavefronts_extend_mwavefront_compute_packed(
const int v = AFFINE_WAVEFRONT_V(k,offset);
const int h = AFFINE_WAVEFRONT_H(k,offset);
// Fetch pattern/text blocks
uint64_t* pattern_blocks = (uint64_t*)(pattern+v);
uint64_t* text_blocks = (uint64_t*)(text+h);
uint64_t pattern_block = *pattern_blocks;
uint64_t text_block = *text_blocks;
// Compare 64-bits blocks
uint64_t cmp = pattern_block ^ text_block;
while (__builtin_expect(!cmp,0)) {
// Increment offset (full block)
offsets[k] += 8;
// Next blocks
++pattern_blocks;
++text_blocks;
// Fetch
pattern_block = *pattern_blocks;
text_block = *text_blocks;
// Compare
cmp = pattern_block ^ text_block;
WAVEFRONT_STATS_COUNTER_ADD(affine_wavefronts,wf_extend_inner_loop,1); // STATS
if (v >= 0 && h >= 0 &&
v < pattern_length && h < text_length) {
uint64_t* pattern_blocks = (uint64_t*)(pattern+v);
uint64_t* text_blocks = (uint64_t*)(text+h);
uint64_t pattern_block = *pattern_blocks;
uint64_t text_block = *text_blocks;
// Compare 64-bits blocks
uint64_t cmp = pattern_block ^ text_block;
while (__builtin_expect(!cmp,0)) {
// Increment offset (full block)
offsets[k] += 8;
// Next blocks
++pattern_blocks;
++text_blocks;
// Fetch
pattern_block = *pattern_blocks;
text_block = *text_blocks;
// Compare
cmp = pattern_block ^ text_block;
WAVEFRONT_STATS_COUNTER_ADD(affine_wavefronts,wf_extend_inner_loop,1); // STATS
}
// Count equal characters
const int equal_right_bits = __builtin_ctzl(cmp);
const int equal_chars = DIV_FLOOR(equal_right_bits,8);
// Increment offset
offsets[k] += equal_chars;
}
// Count equal characters
const int equal_right_bits = __builtin_ctzl(cmp);
const int equal_chars = DIV_FLOOR(equal_right_bits,8);
// Increment offset
offsets[k] += equal_chars;
}
// DEBUG
affine_wavefronts_extend_mwavefront_epiloge(
Expand All @@ -206,8 +209,11 @@ void affine_wavefronts_extend_mwavefront_compute(
const awf_offset_t offset = offsets[k];
int v = AFFINE_WAVEFRONT_V(k,offset);
int h = AFFINE_WAVEFRONT_H(k,offset);
while (pattern[v++]==text[h++]) {
++(offsets[k]);
if (v >= 0 && h >= 0 &&
v < pattern_length && h < text_length) {
while (pattern[v++]==text[h++]) {
++(offsets[k]);
}
}
}
// DEBUG
Expand Down
Loading

0 comments on commit 1e10586

Please sign in to comment.