Skip to content

Commit

Permalink
[FEATURE] Enable vectorised alignment computation.
Browse files Browse the repository at this point in the history
  • Loading branch information
rrahn committed Dec 5, 2019
1 parent 3ef5a54 commit b25884b
Show file tree
Hide file tree
Showing 5 changed files with 368 additions and 200 deletions.
18 changes: 7 additions & 11 deletions include/seqan3/alignment/pairwise/align_pairwise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <seqan3/alignment/configuration/all.hpp>
#include <seqan3/alignment/pairwise/alignment_result.hpp>
#include <seqan3/alignment/pairwise/alignment_configurator.hpp>
#include <seqan3/alignment/pairwise/detail/concept.hpp>
#include <seqan3/alignment/pairwise/detail/type_traits.hpp>
#include <seqan3/alignment/pairwise/execution/all.hpp>
#include <seqan3/core/algorithm/all.hpp>
#include <seqan3/core/parallel/execution.hpp>
Expand Down Expand Up @@ -148,7 +150,7 @@ constexpr auto align_pairwise(sequence_t && seq, alignment_config_t const & conf

//!\cond
template <typename sequence_t, typename alignment_config_t>
requires detail::align_pairwise_range_input_concept<sequence_t> &&
requires detail::align_pairwise_range_input<sequence_t> &&
detail::is_type_specialisation_of_v<alignment_config_t, configuration>
constexpr auto align_pairwise(sequence_t && sequences,
alignment_config_t const & config)
Expand All @@ -166,26 +168,20 @@ constexpr auto align_pairwise(sequence_t && sequences,
// Configure the alignment algorithm.
auto && [algorithm, adapted_config] = detail::alignment_configurator::configure<decltype(seq_view)>(config);

using traits_t = detail::alignment_configuration_traits<remove_cvref_t<decltype(adapted_config)>>;
//!brief Lambda function to translate specified parallel and or vectorised configurations into their execution rules.
constexpr auto get_execution_rule = [] ()
{
if constexpr (alignment_config_t::template exists<align_cfg::parallel>())
return seqan3::par;
if constexpr (traits_t::is_parallel)
return seqan3::par;
else
return seqan3::seq;
};

size_t chunk_size = 1;
if constexpr (alignment_config_t::template exists<detail::vectorise_tag>())
{
using score_t = typename detail::align_config_result_score<decltype(adapted_config)>::type;
chunk_size = simd_traits<simd_type_t<score_t>>::length;
}

// Create a two-way executor for the alignment.
detail::alignment_executor_two_way executor{std::move(seq_view),
std::move(algorithm),
chunk_size,
traits_t::alignments_per_vector,
get_execution_rule()};
// Return the range over the alignments.
return alignment_range{std::move(executor)};
Expand Down
11 changes: 6 additions & 5 deletions include/seqan3/alignment/pairwise/align_result_selector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <seqan3/alignment/matrix/alignment_coordinate.hpp>
#include <seqan3/alignment/matrix/detail/two_dimensional_matrix.hpp>
#include <seqan3/alignment/matrix/trace_directions.hpp>
#include <seqan3/alignment/pairwise/detail/type_traits.hpp>
#include <seqan3/alphabet/gap/gapped.hpp>
#include <seqan3/core/algorithm/configuration.hpp>
#include <seqan3/core/type_traits/basic.hpp>
Expand Down Expand Up @@ -71,14 +72,14 @@ template <std::ranges::forward_range first_range_t,
struct align_result_selector
{
private:
//!\brief The user configured score type.
using score_type = typename alignment_configuration_traits<configuration_t>::original_score_t;

//!\brief Helper function to determine the actual result type.
static constexpr auto select()
{
static_assert(configuration_t::template exists<align_cfg::result>());

using result_type = decltype(get<align_cfg::result>(std::declval<configuration_t>()));
using score_type = typename std::remove_reference_t<result_type>::score_type;

if constexpr (configuration_t::template exists<align_cfg::result<with_back_coordinate_type, score_type>>())
{
return alignment_result_value_type<uint32_t,
Expand Down Expand Up @@ -123,8 +124,8 @@ struct align_result_selector
if constexpr (configuration_t::template exists<detail::algorithm_debugging>())
{
using as_type_list = transfer_template_args_onto_t<alignment_result_value_t, type_list>;
using score_matrix_t = two_dimensional_matrix<std::optional<int32_t>,
std::allocator<std::optional<int32_t>>,
using score_matrix_t = two_dimensional_matrix<std::optional<score_type>,
std::allocator<std::optional<score_type>>,
matrix_major_order::column>;
using trace_matrix_t = two_dimensional_matrix<std::optional<trace_directions>,
std::allocator<std::optional<trace_directions>>,
Expand Down
Loading

0 comments on commit b25884b

Please sign in to comment.