diff --git a/test/data_structures_test.cpp b/test/data_structures_test.cpp index 0b27ee0..dda7b26 100644 --- a/test/data_structures_test.cpp +++ b/test/data_structures_test.cpp @@ -23,9 +23,9 @@ TEST_CASE("aligned stack stores objects correctly", "[internal/data_structures/a std::array small_data_two{}; std::array small_data_three{'A'}; - auto pointer_one = stack.push(small_data_one); - auto pointer_two = stack.push(small_data_two); - auto pointer_three = stack.push(small_data_three); + auto pointer_one = stack.push(small_data_one); + auto pointer_two = stack.push(small_data_two); + auto pointer_three = stack.push(small_data_three); REQUIRE(reinterpret_cast(pointer_one) % system_details::CACHE_LINE_SIZE == 0); REQUIRE(reinterpret_cast(pointer_two) % system_details::CACHE_LINE_SIZE == 0); @@ -36,8 +36,8 @@ TEST_CASE("aligned stack stores objects correctly", "[internal/data_structures/a std::array small_data_one{'a', 'b', 'c', 'd', 'e'}; std::array big_data_one{}; - auto big_pointer_one = stack.push(big_data_one); - auto small_pointer_one = stack.push(small_data_one); + auto big_pointer_one = stack.push(big_data_one); + auto small_pointer_one = stack.push(small_data_one); REQUIRE(reinterpret_cast(big_pointer_one) % system_details::CACHE_LINE_SIZE == 0); REQUIRE(reinterpret_cast(small_pointer_one) % system_details::CACHE_LINE_SIZE == 0); @@ -46,7 +46,7 @@ TEST_CASE("aligned stack stores objects correctly", "[internal/data_structures/a SECTION("stack correctly stores and retrieves objects") { std::array data_one{'a', 'b', 'c', 'd', 'e'}; - stack.push(data_one); + stack.push(data_one); auto retrieved_data = stack.pop>(); REQUIRE(retrieved_data == std::array{'a', 'b', 'c', 'd', 'e'}); @@ -57,13 +57,13 @@ TEST_CASE("aligned stack stores objects correctly", "[internal/data_structures/a std::array small_data_two{}; std::array small_data_three{'A'}; - auto pointer_one = stack.push(small_data_one); - auto pointer_two = stack.push(small_data_two); - auto pointer_three = stack.push(small_data_three); - stack.pop(); - stack.pop(); - auto pointer_four = stack.push(small_data_two); - auto pointer_five = stack.push(small_data_three); + auto pointer_one = stack.push(small_data_one); + auto pointer_two = stack.push(small_data_two); + auto pointer_three = stack.push(small_data_three); + stack.pop(); + stack.pop(); + auto pointer_four = stack.push(small_data_two); + auto pointer_five = stack.push(small_data_three); REQUIRE(reinterpret_cast(pointer_one) % system_details::CACHE_LINE_SIZE == 0); REQUIRE(reinterpret_cast(pointer_two) % system_details::CACHE_LINE_SIZE == 0); @@ -143,11 +143,12 @@ TEST_CASE("work stealing deque stores objects correctly", "[internal/data_struct work_stealing_deque deque{&stack}; int one = 1, two = 2, three = 3, four = 4; + auto no_op = [](int *) {}; // Empty-Callback SECTION("add and remove items form the tail") { - deque.push_tail(one); - deque.push_tail(two); - deque.push_tail(three); + deque.push_tail(no_op, one); + deque.push_tail(no_op, two); + deque.push_tail(no_op, three); REQUIRE(*deque.pop_tail() == three); REQUIRE(*deque.pop_tail() == two); @@ -155,17 +156,17 @@ TEST_CASE("work stealing deque stores objects correctly", "[internal/data_struct } SECTION("handles getting empty by popping the tail correctly") { - deque.push_tail(one); + deque.push_tail(no_op, one); REQUIRE(*deque.pop_tail() == one); - deque.push_tail(two); + deque.push_tail(no_op, two); REQUIRE(*deque.pop_tail() == two); } SECTION("remove items form the head") { - deque.push_tail(one); - deque.push_tail(two); - deque.push_tail(three); + deque.push_tail(no_op, one); + deque.push_tail(no_op, two); + deque.push_tail(no_op, three); REQUIRE(*deque.pop_head() == one); REQUIRE(*deque.pop_head() == two); @@ -173,52 +174,48 @@ TEST_CASE("work stealing deque stores objects correctly", "[internal/data_struct } SECTION("handles getting empty by popping the head correctly") { - deque.push_tail(one); + deque.push_tail(no_op, one); REQUIRE(*deque.pop_head() == one); - deque.push_tail(two); + deque.push_tail(no_op, two); REQUIRE(*deque.pop_head() == two); } SECTION("handles getting empty by popping the head and tail correctly") { - deque.push_tail(one); + deque.push_tail(no_op, one); REQUIRE(*deque.pop_tail() == one); - deque.push_tail(two); + deque.push_tail(no_op, two); REQUIRE(*deque.pop_head() == two); - deque.push_tail(three); + deque.push_tail(no_op, three); REQUIRE(*deque.pop_tail() == three); } SECTION("handles jumps bigger 1 correctly") { - deque.push_tail(one); - deque.push_tail(two); + deque.push_tail(no_op, one); + deque.push_tail(no_op, two); REQUIRE(*deque.pop_tail() == two); - deque.push_tail(three); - deque.push_tail(four); + deque.push_tail(no_op, three); + deque.push_tail(no_op, four); REQUIRE(*deque.pop_head() == one); REQUIRE(*deque.pop_head() == three); REQUIRE(*deque.pop_head() == four); } SECTION("handles stack reset 1 correctly when emptied by tail") { - deque.push_tail(one); + deque.push_tail(no_op, one); auto state = deque.save_state(); - deque.push_tail(two); + deque.push_tail(no_op, two); REQUIRE(*deque.pop_tail() == two); deque.release_memory_until(state); REQUIRE(*deque.pop_tail() == one); - deque.push_tail(three); - deque.push_tail(four); + deque.push_tail(no_op, three); + deque.push_tail(no_op, four); REQUIRE(*deque.pop_head() == three); REQUIRE(*deque.pop_tail() == four); } - - SECTION("synces correctly") { - - } } diff --git a/test/scheduling_tests.cpp b/test/scheduling_tests.cpp index 710fc80..481a75e 100644 --- a/test/scheduling_tests.cpp +++ b/test/scheduling_tests.cpp @@ -12,7 +12,7 @@ class once_sub_task : public task { void execute_internal() override { (*counter_)++; for (int i = 0; i < children_; i++) { - spawn_child(once_sub_task(counter_, children_ - 1)); + spawn_child(counter_, children_ - 1); } } @@ -32,7 +32,7 @@ class force_steal_sub_task : public task { (*overall_counter_)--; if (overall_counter_->load() > 0) { std::atomic counter{1}; - spawn_child(force_steal_sub_task(&counter, overall_counter_)); + spawn_child(&counter, overall_counter_); while (counter.load() > 0); // Spin... } @@ -56,8 +56,7 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta std::atomic counter{0}; my_scheduler.perform_work([&]() { - once_sub_task sub_task{&counter, start_counter}; - scheduler::spawn_child(sub_task); + scheduler::spawn_child(&counter, start_counter); }); REQUIRE(counter.load() == total_tasks); @@ -68,8 +67,7 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta scheduler my_scheduler{&my_scheduler_memory, 8}; my_scheduler.perform_work([&]() { std::atomic dummy_parent{1}, overall_counter{8}; - force_steal_sub_task sub_task{&dummy_parent, &overall_counter}; - scheduler::spawn_child(sub_task); + scheduler::spawn_child(&dummy_parent, &overall_counter); // Required, as child operates on our stack's memory!!! scheduler::wait_for_all();