Skip to content

Commit

Permalink
[MISC] Workaround: GCC Bug 114013
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Feb 26, 2024
1 parent 49f7ecf commit 65927e6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
11 changes: 11 additions & 0 deletions include/seqan3/core/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ static_assert(sdsl::sdsl_version_major == 3, "Only version 3 of the SDSL is supp
# endif
#endif

/*!\brief Workaround for variable template specialisations not being emitted.
* \see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114013
*/
#ifndef SEQAN3_WORKAROUND_GCC_114013
# if SEQAN3_COMPILER_IS_GCC && (__GNUC__ == 14)
# define SEQAN3_WORKAROUND_GCC_114013 1
# else
# define SEQAN3_WORKAROUND_GCC_114013 0
# endif
#endif

/*!\brief This is needed to support CentOS 7 or RHEL 7; Newer CentOS's include a more modern default-gcc version making
* this macro obsolete.
*
Expand Down
51 changes: 30 additions & 21 deletions include/seqan3/search/detail/search_scheme_precomputed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ template <uint8_t nbr_blocks>
struct search
{
//!\brief Type for storing the length of blocks
typedef std::array<size_t, nbr_blocks> blocks_length_type;
using blocks_length_type = std::array<size_t, nbr_blocks>;

//!\brief Order of blocks
std::array<uint8_t, nbr_blocks> pi;
Expand All @@ -46,7 +46,7 @@ struct search
struct search_dyn
{
//!\brief Type for storing the length of blocks
typedef std::vector<size_t> blocks_length_type;
using blocks_length_type = std::vector<size_t>;

//!\brief Order of blocks
std::vector<uint8_t> pi;
Expand All @@ -71,6 +71,12 @@ using search_scheme_type = std::array<search<nbr_blocks>, nbr_searches>;
//!\ingroup search
using search_scheme_dyn_type = std::vector<search_dyn>;

#ifdef SEQAN3_WORKAROUND_GCC_114013
# define SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER constexpr
#else
# define SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER inline constexpr
#endif

/*!\brief Search scheme that is optimal in the running time for the specified lower and upper error bound.
* \ingroup search
* \tparam min_error Lower bound of errors.
Expand All @@ -81,60 +87,63 @@ using search_scheme_dyn_type = std::vector<search_dyn>;
* seems to be a good greedy approach.
*/
template <uint8_t min_error, uint8_t max_error>
inline constexpr int optimum_search_scheme{0};
SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER int optimum_search_scheme{0};

//!\cond

template <>
inline constexpr search_scheme_type<1, 1> optimum_search_scheme<0, 0>{{{{1}, {0}, {0}}}};
SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER search_scheme_type<1, 1> optimum_search_scheme<0, 0>{{{{1}, {0}, {0}}}};

template <>
inline constexpr search_scheme_type<2, 2> optimum_search_scheme<0, 1>{
SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER search_scheme_type<2, 2> optimum_search_scheme<0, 1>{
{{{1, 2}, {0, 0}, {0, 1}}, {{2, 1}, {0, 1}, {0, 1}}}};

template <>
inline constexpr search_scheme_type<2, 2> optimum_search_scheme<1, 1>{
SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER search_scheme_type<2, 2> optimum_search_scheme<1, 1>{
{{{1, 2}, {0, 1}, {0, 1}}, {{2, 1}, {0, 1}, {0, 1}}}};

template <>
inline constexpr search_scheme_type<3, 4> optimum_search_scheme<0, 2>{{{{1, 2, 3, 4}, {0, 0, 1, 1}, {0, 0, 2, 2}},
{{3, 2, 1, 4}, {0, 0, 0, 0}, {0, 1, 1, 2}},
{{4, 3, 2, 1}, {0, 0, 0, 2}, {0, 1, 2, 2}}}};
SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER search_scheme_type<3, 4> optimum_search_scheme<0, 2>{
{{{1, 2, 3, 4}, {0, 0, 1, 1}, {0, 0, 2, 2}},
{{3, 2, 1, 4}, {0, 0, 0, 0}, {0, 1, 1, 2}},
{{4, 3, 2, 1}, {0, 0, 0, 2}, {0, 1, 2, 2}}}};

template <>
inline constexpr search_scheme_type<3, 4> optimum_search_scheme<1, 2>{{{{1, 2, 3, 4}, {0, 0, 0, 1}, {0, 0, 2, 2}},
{{3, 2, 1, 4}, {0, 0, 1, 1}, {0, 1, 1, 2}},
{{4, 3, 2, 1}, {0, 0, 0, 2}, {0, 1, 2, 2}}}};
SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER search_scheme_type<3, 4> optimum_search_scheme<1, 2>{
{{{1, 2, 3, 4}, {0, 0, 0, 1}, {0, 0, 2, 2}},
{{3, 2, 1, 4}, {0, 0, 1, 1}, {0, 1, 1, 2}},
{{4, 3, 2, 1}, {0, 0, 0, 2}, {0, 1, 2, 2}}}};

template <>
inline constexpr search_scheme_type<3, 4> optimum_search_scheme<2, 2>{{{{4, 3, 2, 1}, {0, 0, 1, 2}, {0, 0, 2, 2}},
{{2, 3, 4, 1}, {0, 0, 0, 2}, {0, 1, 1, 2}},
{{1, 2, 3, 4}, {0, 0, 0, 2}, {0, 1, 2, 2}}}};
SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER search_scheme_type<3, 4> optimum_search_scheme<2, 2>{
{{{4, 3, 2, 1}, {0, 0, 1, 2}, {0, 0, 2, 2}},
{{2, 3, 4, 1}, {0, 0, 0, 2}, {0, 1, 1, 2}},
{{1, 2, 3, 4}, {0, 0, 0, 2}, {0, 1, 2, 2}}}};

// TODO: benchmark whether the first search is really the fastest one (see \details of optimum_search_scheme)
template <>
inline constexpr search_scheme_type<4, 5> optimum_search_scheme<0, 3>{
{// TODO: benchmark whether the first search is really the fastest one (see \details of optimum_search_scheme)
{{5, 4, 3, 2, 1}, {0, 0, 0, 0, 0}, {0, 0, 3, 3, 3}},
SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER search_scheme_type<4, 5> optimum_search_scheme<0, 3>{
{{{5, 4, 3, 2, 1}, {0, 0, 0, 0, 0}, {0, 0, 3, 3, 3}},
{{3, 4, 5, 2, 1}, {0, 0, 1, 1, 1}, {0, 1, 1, 2, 3}},
{{2, 3, 4, 5, 1}, {0, 0, 0, 2, 2}, {0, 1, 2, 2, 3}},
{{1, 2, 3, 4, 5}, {0, 0, 0, 0, 3}, {0, 2, 2, 3, 3}}}};

template <>
inline constexpr search_scheme_type<4, 5> optimum_search_scheme<1, 3>{
SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER search_scheme_type<4, 5> optimum_search_scheme<1, 3>{
{{{5, 4, 3, 2, 1}, {0, 0, 0, 0, 1}, {0, 0, 3, 3, 3}},
{{3, 4, 5, 2, 1}, {0, 0, 1, 1, 1}, {0, 1, 1, 2, 3}},
{{2, 3, 4, 5, 1}, {0, 0, 0, 2, 2}, {0, 1, 2, 2, 3}},
{{1, 2, 3, 4, 5}, {0, 0, 0, 0, 3}, {0, 2, 2, 3, 3}}}};

template <>
inline constexpr search_scheme_type<4, 5> optimum_search_scheme<2, 3>{
SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER search_scheme_type<4, 5> optimum_search_scheme<2, 3>{
{{{5, 4, 3, 2, 1}, {0, 0, 0, 0, 2}, {0, 0, 3, 3, 3}},
{{3, 4, 5, 2, 1}, {0, 0, 1, 1, 2}, {0, 1, 1, 2, 3}},
{{2, 3, 4, 5, 1}, {0, 0, 0, 2, 2}, {0, 1, 2, 2, 3}},
{{1, 2, 3, 4, 5}, {0, 0, 0, 0, 3}, {0, 2, 2, 3, 3}}}};

template <>
inline constexpr search_scheme_type<4, 5> optimum_search_scheme<3, 3>{
SEQAN3_SEARCH_SCHEME_VAR_SPECIFIER search_scheme_type<4, 5> optimum_search_scheme<3, 3>{
{{{5, 4, 3, 2, 1}, {0, 0, 0, 0, 3}, {0, 0, 3, 3, 3}},
{{3, 4, 5, 2, 1}, {0, 0, 1, 1, 3}, {0, 1, 1, 2, 3}},
{{2, 3, 4, 5, 1}, {0, 0, 0, 2, 3}, {0, 1, 2, 2, 3}},
Expand Down

0 comments on commit 65927e6

Please sign in to comment.