Browse Source

test: add group parallel

master
Dnomd343 4 weeks ago
parent
commit
f0ad61d725
  1. 1
      src/core_test/cases/ranges.cc
  2. 10
      src/core_test/helper/internal/parallel.cc

1
src/core_test/cases/ranges.cc

@ -20,6 +20,7 @@ using klotski::cases::BASIC_RANGES_NUM_;
constexpr auto Heads = RangesUnion::Heads; constexpr auto Heads = RangesUnion::Heads;
static_assert(std::is_default_constructible_v<Ranges>); // TODO: more concept assert
static_assert(std::is_base_of_v<std::vector<uint32_t>, Ranges>); static_assert(std::is_base_of_v<std::vector<uint32_t>, Ranges>);
TEST(Ranges, check) { TEST(Ranges, check) {

10
src/core_test/helper/internal/parallel.cc

@ -32,7 +32,15 @@ void helper::block_num_parallel(std::function<void(int n, int n_2x1, int n_1x1)>
} }
void helper::group_parallel(std::function<void(Group)> &&func) { void helper::group_parallel(std::function<void(Group)> &&func) {
// TODO: spawn all Groups BS::thread_pool pool;
for (uint32_t type_id = 0; type_id < TYPE_ID_LIMIT; ++type_id) {
for (auto group : GroupUnion::unsafe_create(type_id).groups()) {
pool.detach_task([group, &func] {
func(group);
});
}
}
pool.wait();
} }
void helper::type_id_parallel(std::function<void(uint32_t type_id)> &&func) { void helper::type_id_parallel(std::function<void(uint32_t type_id)> &&func) {

Loading…
Cancel
Save