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 { ...@@ -34,7 +34,7 @@ class task {
virtual void execute_internal() = 0; virtual void execute_internal() = 0;
template<typename T> template<typename T>
void spawn_child(T &sub_task); void spawn_child(T &&sub_task);
void wait_for_all(); void wait_for_all();
private: private:
...@@ -42,9 +42,9 @@ class task { ...@@ -42,9 +42,9 @@ class task {
}; };
template<typename T> template<typename T>
void task::spawn_child(T &sub_task) { void task::spawn_child(T &&sub_task) {
PROFILE_FORK_JOIN_STEALING("spawn_child") 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 // Keep our refcount up to date
ref_count_++; ref_count_++;
......
add_executable(tests add_executable(tests
main.cpp main.cpp
data_structures_test.cpp) data_structures_test.cpp
scheduling_tests.cpp)
target_link_libraries(tests catch2 pls) target_link_libraries(tests catch2 pls)
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
using namespace pls; using namespace pls;
class once_sub_task : public fork_join_sub_task { class once_sub_task : public task {
std::atomic<int> *counter_; std::atomic<int> *counter_;
int children_; int children_;
...@@ -18,12 +18,12 @@ class once_sub_task : public fork_join_sub_task { ...@@ -18,12 +18,12 @@ class once_sub_task : public fork_join_sub_task {
public: public:
explicit once_sub_task(std::atomic<int> *counter, int children) : explicit once_sub_task(std::atomic<int> *counter, int children) :
fork_join_sub_task(), task{},
counter_{counter}, counter_{counter},
children_{children} {} 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> *parent_counter_;
std::atomic<int> *overall_counter_; std::atomic<int> *overall_counter_;
...@@ -41,7 +41,7 @@ class force_steal_sub_task : public fork_join_sub_task { ...@@ -41,7 +41,7 @@ class force_steal_sub_task : public fork_join_sub_task {
public: public:
explicit force_steal_sub_task(std::atomic<int> *parent_counter, std::atomic<int> *overall_counter) : explicit force_steal_sub_task(std::atomic<int> *parent_counter, std::atomic<int> *overall_counter) :
fork_join_sub_task(), task{},
parent_counter_{parent_counter}, parent_counter_{parent_counter},
overall_counter_{overall_counter} {} overall_counter_{overall_counter} {}
}; };
...@@ -57,8 +57,7 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta ...@@ -57,8 +57,7 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta
my_scheduler.perform_work([&]() { my_scheduler.perform_work([&]() {
once_sub_task sub_task{&counter, start_counter}; once_sub_task sub_task{&counter, start_counter};
fork_join_task task{&sub_task, unique_id::create(42)}; scheduler::spawn_child(sub_task);
scheduler::execute_task(task);
}); });
REQUIRE(counter.load() == total_tasks); REQUIRE(counter.load() == total_tasks);
...@@ -70,8 +69,7 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta ...@@ -70,8 +69,7 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta
my_scheduler.perform_work([&]() { my_scheduler.perform_work([&]() {
std::atomic<int> dummy_parent{1}, overall_counter{8}; std::atomic<int> dummy_parent{1}, overall_counter{8};
force_steal_sub_task sub_task{&dummy_parent, &overall_counter}; force_steal_sub_task sub_task{&dummy_parent, &overall_counter};
fork_join_task task{&sub_task, unique_id::create(42)}; scheduler::spawn_child(sub_task);
scheduler::execute_task(task);
}); });
my_scheduler.terminate(true); 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