From 65927e6d69bd2e6a00b53a66ed9939bafc369427 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 26 Feb 2024 19:43:09 +0100 Subject: [PATCH] [MISC] Workaround: GCC Bug 114013 --- include/seqan3/core/platform.hpp | 11 ++++ .../detail/search_scheme_precomputed.hpp | 51 +++++++++++-------- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/include/seqan3/core/platform.hpp b/include/seqan3/core/platform.hpp index aec8b8aad8..395e64c2b3 100644 --- a/include/seqan3/core/platform.hpp +++ b/include/seqan3/core/platform.hpp @@ -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. * diff --git a/include/seqan3/search/detail/search_scheme_precomputed.hpp b/include/seqan3/search/detail/search_scheme_precomputed.hpp index eddabbacff..73e09759c9 100644 --- a/include/seqan3/search/detail/search_scheme_precomputed.hpp +++ b/include/seqan3/search/detail/search_scheme_precomputed.hpp @@ -24,7 +24,7 @@ template struct search { //!\brief Type for storing the length of blocks - typedef std::array blocks_length_type; + using blocks_length_type = std::array; //!\brief Order of blocks std::array pi; @@ -46,7 +46,7 @@ struct search struct search_dyn { //!\brief Type for storing the length of blocks - typedef std::vector blocks_length_type; + using blocks_length_type = std::vector; //!\brief Order of blocks std::vector pi; @@ -71,6 +71,12 @@ using search_scheme_type = std::array, nbr_searches>; //!\ingroup search using search_scheme_dyn_type = std::vector; +#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. @@ -81,60 +87,63 @@ using search_scheme_dyn_type = std::vector; * seems to be a good greedy approach. */ template -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}},