Commit 3bdaba42 by FritzFlorian

Adapt tests to new fork-join model.

parent 10ca31dc
Pipeline #1245 failed with stages
in 27 seconds
......@@ -34,7 +34,7 @@ class task {
virtual void execute_internal() = 0;
template<typename T>
void spawn_child(T &sub_task);
void spawn_child(T &&sub_task);
void wait_for_all();
private:
......@@ -42,9 +42,9 @@ class task {
};
template<typename T>
void task::spawn_child(T &sub_task) {
void task::spawn_child(T &&sub_task) {
PROFILE_FORK_JOIN_STEALING("spawn_child")
static_assert(std::is_base_of<task, T>::value, "Only pass task subclasses!");
static_assert(std::is_base_of<task, typename std::remove_reference<T>::type>::value, "Only pass task subclasses!");
// Keep our refcount up to date
ref_count_++;
......
add_executable(tests
main.cpp
data_structures_test.cpp)
data_structures_test.cpp
scheduling_tests.cpp)
target_link_libraries(tests catch2 pls)
......@@ -4,7 +4,7 @@
using namespace pls;
class once_sub_task : public fork_join_sub_task {
class once_sub_task : public task {
std::atomic<int> *counter_;
int children_;
......@@ -18,12 +18,12 @@ class once_sub_task : public fork_join_sub_task {
public:
explicit once_sub_task(std::atomic<int> *counter, int children) :
fork_join_sub_task(),
task{},
counter_{counter},
children_{children} {}
};
class force_steal_sub_task : public fork_join_sub_task {
class force_steal_sub_task : public task {
std::atomic<int> *parent_counter_;
std::atomic<int> *overall_counter_;
......@@ -41,7 +41,7 @@ class force_steal_sub_task : public fork_join_sub_task {
public:
explicit force_steal_sub_task(std::atomic<int> *parent_counter, std::atomic<int> *overall_counter) :
fork_join_sub_task(),
task{},
parent_counter_{parent_counter},
overall_counter_{overall_counter} {}
};
......@@ -57,8 +57,7 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta
my_scheduler.perform_work([&]() {
once_sub_task sub_task{&counter, start_counter};
fork_join_task task{&sub_task, unique_id::create(42)};
scheduler::execute_task(task);
scheduler::spawn_child(sub_task);
});
REQUIRE(counter.load() == total_tasks);
......@@ -70,8 +69,7 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta
my_scheduler.perform_work([&]() {
std::atomic<int> dummy_parent{1}, overall_counter{8};
force_steal_sub_task sub_task{&dummy_parent, &overall_counter};
fork_join_task task{&sub_task, unique_id::create(42)};
scheduler::execute_task(task);
scheduler::spawn_child(sub_task);
});
my_scheduler.terminate(true);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment