[MISC] Config parallel with member thread_count - #1917
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1917 +/- ##
========================================
Coverage 97.76% 97.76%
========================================
Files 253 258 +5
Lines 9560 9684 +124
========================================
+ Hits 9346 9468 +122
- Misses 214 216 +2
Continue to review full report at Codecov.
|
| //!\} | ||
|
|
||
| //!\brief The maximum number of threads the algorithm can use. | ||
| uint32_t thread_count{1u}; |
There was a problem hiding this comment.
Question: Do we want std::thread::hardware_concurrency as a default here?
There was a problem hiding this comment.
hmm good question. I would vote for yes. I'll ask @seqan/core
simonsasse
left a comment
There was a problem hiding this comment.
Thanks for the explanation ! Just found two lines which are slightly too long. :)
8484ba1 to
ea28521
Compare
|
Rebased on master. |
| * \param[in] thread_c The maximum number of threads to be used by the algorithm. | ||
| */ | ||
| explicit parallel_mode(uint32_t thread_c) noexcept : thread_count{thread_c} |
There was a problem hiding this comment.
| * \param[in] thread_c The maximum number of threads to be used by the algorithm. | |
| */ | |
| explicit parallel_mode(uint32_t thread_c) noexcept : thread_count{thread_c} | |
| * \param[in] thread_count_ The maximum number of threads to be used by the algorithm. | |
| */ | |
| explicit parallel_mode(uint32_t thread_count_) noexcept : thread_count{thread_count_} | |
| :nail_care: |
| parallel_mode(parallel_mode &&) noexcept = default; //!< Defaulted. | ||
| parallel_mode & operator=(parallel_mode const &) = default; //!< Defaulted. | ||
| parallel_mode & operator=(parallel_mode &&) noexcept = default; //!< Defaulted. |
There was a problem hiding this comment.
| parallel_mode(parallel_mode &&) noexcept = default; //!< Defaulted. | |
| parallel_mode & operator=(parallel_mode const &) = default; //!< Defaulted. | |
| parallel_mode & operator=(parallel_mode &&) noexcept = default; //!< Defaulted. | |
| parallel_mode(parallel_mode &&) = default; //!< Defaulted. | |
| parallel_mode & operator=(parallel_mode const &) = default; //!< Defaulted. | |
| parallel_mode & operator=(parallel_mode &&) = default; //!< Defaulted. |
or did you define this on purpose? because usually for = default constructors this is added automatically.
There was a problem hiding this comment.
I added noexcept on purpose, because when I left it away, CLion told me:
Clang-Tidy: Move constructors should be marked noexcept.
Clang-Tidy: Move assignment operators should be marked noexcept.
If it's our policy I can remove them now.
There was a problem hiding this comment.
Yes :)
See here: https://en.cppreference.com/w/cpp/language/noexcept_spec that they are noexcept if they can.
| //!\} | ||
|
|
||
| //!\brief The maximum number of threads the algorithm can use. | ||
| uint32_t thread_count{1u}; |
There was a problem hiding this comment.
hmm good question. I would vote for yes. I'll ask @seqan/core
|
What should be the default thread count if the user does not specifies anything? Resolution 24.06.2020The option should default to |
|
I cannot assign |
Yes, |
| else if constexpr (std::same_as<type_param_t, seqan3::align_cfg::parallel>) | ||
| { | ||
| auto && config = cfg | type_param_t{}; | ||
| auto && config = cfg | seqan3::align_cfg::parallel{4}; |
There was a problem hiding this comment.
I don't understand this change?
There was a problem hiding this comment.
type_param_t is either void or seqan3::align_cfg::parallel, because we want to test the serial and the parallel version. And if it is parallel, we do not want to use the default initialisation, because half of the tests would fail with the std::bad_optional_access exception. So I initialise the parallel tests with 4.
There was a problem hiding this comment.
thank you for the explanation :)
| return execution_handler_t{get<align_cfg::parallel>(complete_config).thread_count.value()}; | ||
| else | ||
| return execution_handler_t{}; |
There was a problem hiding this comment.
| return execution_handler_t{get<align_cfg::parallel>(complete_config).thread_count.value()}; | |
| else | |
| return execution_handler_t{}; | |
| { | |
| if (!get<align_cfg::parallel>(complete_config).thread_count.has_value()) | |
| throw std::runtime_error{"You must configure the number of threads in seqan3::align_cfg::parallel."}; | |
| return execution_handler_t{get<align_cfg::parallel>(complete_config).thread_count.value()}; | |
| } | |
| else | |
| { | |
| return execution_handler_t{}; | |
| } |
I think this will be more easy to understand for the user than a std::bad_optional_acces ?
Maybe rephrase the sentence, it's just a proposal :)
There was a problem hiding this comment.
Yes, I like this suggestion :)
This PR adds a member variable
thread_countto the parallel config (it replaces the old value member). It influences bothseqan3::align_cfg::parallelandseqan3::search_cfg::parallel.Documentation and tests are included in the second commit.
Closes seqan/product_backlog#68 and contributes to seqan/product_backlog#131.