Raptor 3.0.0-rc.1
A fast and space-efficient pre-filter for querying very large collections of nucleotide sequences
 
call_parallel_on_bins.hpp
Go to the documentation of this file.
1// --------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/raptor/blob/main/LICENSE.md
6// --------------------------------------------------------------------------------------------------
7
13#pragma once
14
15#include <seqan3/core/algorithm/detail/execution_handler_parallel.hpp>
16#include <seqan3/utility/views/chunk.hpp>
17#include <seqan3/utility/views/zip.hpp>
18
19namespace raptor
20{
21
22template <typename algorithm_t>
23void call_parallel_on_bins(algorithm_t && worker,
24 std::vector<std::vector<std::string>> const & bin_paths,
25 uint8_t const threads)
26{
27 // GCOVR_EXCL_START
28 size_t const chunk_size = std::clamp<size_t>(std::bit_ceil(bin_paths.size() / threads), 8u, 64u);
29 // GCOVR_EXCL_STOP
30 auto chunked_view = seqan3::views::zip(bin_paths, std::views::iota(0u)) | seqan3::views::chunk(chunk_size);
31 seqan3::detail::execution_handler_parallel executioner{threads};
32 executioner.bulk_execute(std::move(worker), std::move(chunked_view), []() {});
33}
34
35} // namespace raptor
T bit_ceil(T... args)