Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge AVX2/512 extend from development to main #103

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions wavefront/wavefront_extend.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ void wavefront_extend_end2end_dispatcher_seq(
wavefront_sequences_t* const seqs = &wf_aligner->sequences;
// Check the sequence mode
if (seqs->mode == wf_sequences_ascii) {
//#if __AVX2__ // TODO
// wavefront_extend_matches_packed_end2end_avx2(wf_aligner,mwavefront,lo,hi);
//#else
wavefront_extend_matches_packed_end2end(wf_aligner,mwavefront,lo,hi);
//#endif
} else {
wf_offset_t dummy;
wavefront_extend_matches_custom(wf_aligner,mwavefront,score,lo,hi,false,&dummy);
Expand Down
75 changes: 52 additions & 23 deletions wavefront/wavefront_extend_kernels.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "wavefront_extend_kernels.h"
#include "wavefront_termination.h"
#include "wavefront_extend_kernels_avx.h"

#if __BYTE_ORDER == __LITTLE_ENDIAN
#define wavefront_extend_matches_kernel wavefront_extend_matches_kernel_blockwise
Expand Down Expand Up @@ -63,6 +64,7 @@ FORCE_INLINE wf_offset_t wavefront_extend_matches_kernel_charwise(
// Return extended offset
return offset;
}

FORCE_INLINE wf_offset_t wavefront_extend_matches_kernel_blockwise(
wavefront_aligner_t* const wf_aligner,
const int k,
Expand All @@ -88,6 +90,7 @@ FORCE_INLINE wf_offset_t wavefront_extend_matches_kernel_blockwise(
// Return extended offset
return offset;
}

/*
* Wavefront-Extend Inner Kernels
* Wavefront offset extension comparing characters
Expand All @@ -100,42 +103,67 @@ FORCE_NO_INLINE void wavefront_extend_matches_packed_end2end(
wavefront_t* const mwavefront,
const int lo,
const int hi) {
wf_offset_t* const offsets = mwavefront->offsets;
int k;
for (k=lo;k<=hi;++k) {
// Fetch offset
const wf_offset_t offset = offsets[k];
if (offset == WAVEFRONT_OFFSET_NULL) continue;
// Extend offset
offsets[k] = wavefront_extend_matches_kernel(wf_aligner,k,offset);
}
#if __AVX2__ && __BYTE_ORDER == __LITTLE_ENDIAN
#if __AVX512CD__ && __AVX512VL__
wavefront_extend_matches_packed_end2end_avx512(wf_aligner, mwavefront, lo, hi);
#else
wavefront_extend_matches_packed_end2end_avx2(wf_aligner, mwavefront, lo, hi);
#endif
#else
wf_offset_t* const offsets = mwavefront->offsets;
int k;
for (k=lo;k<=hi;++k) {
// Fetch offset
const wf_offset_t offset = offsets[k];
if (offset == WAVEFRONT_OFFSET_NULL) continue;
// Extend offset
offsets[k] = wavefront_extend_matches_kernel(wf_aligner,k,offset);
}
#endif
}

FORCE_NO_INLINE wf_offset_t wavefront_extend_matches_packed_end2end_max(
wavefront_aligner_t* const wf_aligner,
wavefront_t* const mwavefront,
const int lo,
const int hi) {
wf_offset_t* const offsets = mwavefront->offsets;
wf_offset_t max_antidiag = 0;
int k;
for (k=lo;k<=hi;++k) {
// Fetch offset
const wf_offset_t offset = offsets[k];
if (offset == WAVEFRONT_OFFSET_NULL) continue;
// Extend offset
offsets[k] = wavefront_extend_matches_kernel(wf_aligner,k,offset);
// Compute max
const wf_offset_t antidiag = WAVEFRONT_ANTIDIAGONAL(k,offsets[k]);
if (max_antidiag < antidiag) max_antidiag = antidiag;
}
return max_antidiag;
#if __AVX2__ && __BYTE_ORDER == __LITTLE_ENDIAN
#if __AVX512CD__ && __AVX512VL__
return wavefront_extend_matches_packed_end2end_max_avx512(wf_aligner, mwavefront, lo, hi);
#else
return wavefront_extend_matches_packed_end2end_max_avx2(wf_aligner, mwavefront, lo, hi);
#endif
#else
wf_offset_t* const offsets = mwavefront->offsets;
wf_offset_t max_antidiag = 0;
int k;
for (k=lo;k<=hi;++k) {
// Fetch offset
const wf_offset_t offset = offsets[k];
if (offset == WAVEFRONT_OFFSET_NULL) continue;
// Extend offset
offsets[k] = wavefront_extend_matches_kernel(wf_aligner,k,offset);
// Compute max
const wf_offset_t antidiag = WAVEFRONT_ANTIDIAGONAL(k,offsets[k]);
if (max_antidiag < antidiag) max_antidiag = antidiag;
}
return max_antidiag;
#endif
}

FORCE_NO_INLINE bool wavefront_extend_matches_packed_endsfree(
wavefront_aligner_t* const wf_aligner,
wavefront_t* const mwavefront,
const int score,
const int lo,
const int hi) {
#if __AVX2__ && __BYTE_ORDER == __LITTLE_ENDIAN
#if __AVX512CD__ && __AVX512VL__
return wavefront_extend_matches_packed_endsfree_avx512(wf_aligner, mwavefront, score, lo, hi);
#else
return wavefront_extend_matches_packed_endsfree_avx2(wf_aligner, mwavefront, score, lo, hi);
#endif
#else
// Parameters
wf_offset_t* const offsets = mwavefront->offsets;
int k;
Expand All @@ -162,6 +190,7 @@ FORCE_NO_INLINE bool wavefront_extend_matches_packed_endsfree(
}
// Alignment not finished
return false;
#endif
}
/*
* Wavefront-Extend Inner Kernel (Custom match function)
Expand Down
Loading
Loading