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

update alignment optimizations #52

Merged
merged 2 commits into from
Jun 1, 2024
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
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if ENABLE_SHORT
AM_CXXFLAGS += -DENABLE_SHORT
endif

CXXFLAGS = -O3 # default has optimization on
CXXFLAGS = -O3 -DNDEBUG # default has optimization on

noinst_LIBRARIES = libabismal.a

Expand Down
19 changes: 13 additions & 6 deletions src/AbismalAlign.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,9 @@ is_insertion(const uint8_t c) {

static inline void
get_traceback(const size_t n_col, const std::vector<score_t> &table,
// const std::vector<uint8_t> &traceback,
const std::vector<int8_t> &traceback,
std::vector<uint32_t> &cigar, size_t &the_row, size_t &the_col) {
int8_t prev_arrow = traceback[the_row * n_col + the_col];
// int8_t prev_arrow = traceback[the_row * n_col + the_col];
const bool is_del = is_deletion(prev_arrow);
const bool is_ins = is_insertion(prev_arrow);
the_row -= !is_ins;
Expand Down Expand Up @@ -211,8 +209,15 @@ get_best_score(const std::vector<score_t> &table, const size_t n_cells,
// ADS: it seems like with g++-13, on macos ventura on intel hardware
// the dynamic vectorized optimization of -O3 might be too aggressive
// and makes this function have strange behavior. Placing this pragma
// here helps, and below we restore it to the `-O3` default.
#pragma GCC optimize("vect-cost-model=very-cheap")
// here helps, and below we restore it to the `-O3` default. Probably
// should move to attribute syntax soon.

#ifdef __APPLE__
#pragma GCC push_options
// ADS: below this won't make sense if the user wants no optimizations
// at all...
#pragma GCC optimize ("O2")
#endif

template<score_t (*scr_fun)(const uint8_t, const uint8_t), class T,
class QueryConstItr>
Expand Down Expand Up @@ -284,7 +289,9 @@ from_left(T left_itr, T target, const T target_end, U traceback) {
}
}

#pragma GCC optimize("vect-cost-model=dynamic")
#ifdef __APPLE__
#pragma GCC pop_options
#endif

inline void
make_default_cigar(const uint32_t len, std::string &cigar) {
Expand Down Expand Up @@ -323,7 +330,7 @@ AbismalAlign<scr_fun, indel_pen>::align(const score_t diffs,

// points to relevant reference sequence positions
genome_iterator t_itr = target + t_beg;
const auto q_itr(std::begin(qseq));
const auto q_itr(std::cbegin(qseq));
auto tb_cur(std::begin(traceback));

// prev and cur point to rows in the alignment matrix
Expand Down
Loading