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 27, 2024
1 parent 49f7ecf commit 4311ad5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 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 constexpr
# else
# define SEQAN3_WORKAROUND_GCC_114013 inline constexpr
# 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
45 changes: 24 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 Down Expand Up @@ -81,60 +81,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_WORKAROUND_GCC_114013 int optimum_search_scheme{0};

//!\cond

template <>
inline constexpr search_scheme_type<1, 1> optimum_search_scheme<0, 0>{{{{1}, {0}, {0}}}};
SEQAN3_WORKAROUND_GCC_114013 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_WORKAROUND_GCC_114013 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_WORKAROUND_GCC_114013 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_WORKAROUND_GCC_114013 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_WORKAROUND_GCC_114013 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_WORKAROUND_GCC_114013 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_WORKAROUND_GCC_114013 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_WORKAROUND_GCC_114013 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_WORKAROUND_GCC_114013 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_WORKAROUND_GCC_114013 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
3 changes: 2 additions & 1 deletion test/documentation/seqan3_doxygen_cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ PREDEFINED = CEREAL_SERIALIZE_FUNCTION_NAME=serialize \
__cpp_lib_three_way_comparison=1 \
SEQAN3_WORKAROUND_LITERAL=constexpr
EXPAND_AS_DEFINED = SEQAN3_CPO_OVERLOAD_BODY \
SEQAN3_CPO_OVERLOAD
SEQAN3_CPO_OVERLOAD \
SEQAN3_WORKAROUND_GCC_114013
SKIP_FUNCTION_MACROS = NO
#---------------------------------------------------------------------------
# Configuration options related to external references
Expand Down

0 comments on commit 4311ad5

Please sign in to comment.