Commit 41b2f354 by FritzFlorian

Refactor tests to fit new deque

parent 88dd5384
Pipeline #1262 failed with stages
in 51 seconds
......@@ -23,9 +23,9 @@ TEST_CASE("aligned stack stores objects correctly", "[internal/data_structures/a
std::array<char, 64> small_data_two{};
std::array<char, 1> 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<decltype(small_data_one)>(small_data_one);
auto pointer_two = stack.push<decltype(small_data_two)>(small_data_two);
auto pointer_three = stack.push<decltype(small_data_three)>(small_data_three);
REQUIRE(reinterpret_cast<std::uintptr_t>(pointer_one) % system_details::CACHE_LINE_SIZE == 0);
REQUIRE(reinterpret_cast<std::uintptr_t>(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<char, 5> small_data_one{'a', 'b', 'c', 'd', 'e'};
std::array<char, system_details::CACHE_LINE_SIZE + 10> 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<decltype(big_data_one)>(big_data_one);
auto small_pointer_one = stack.push<decltype(small_data_one)>(small_data_one);
REQUIRE(reinterpret_cast<std::uintptr_t>(big_pointer_one) % system_details::CACHE_LINE_SIZE == 0);
REQUIRE(reinterpret_cast<std::uintptr_t>(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<char, 5> data_one{'a', 'b', 'c', 'd', 'e'};
stack.push(data_one);
stack.push<decltype(data_one)>(data_one);
auto retrieved_data = stack.pop<std::array<char, 5>>();
REQUIRE(retrieved_data == std::array<char, 5>{'a', 'b', 'c', 'd', 'e'});
......@@ -57,13 +57,13 @@ TEST_CASE("aligned stack stores objects correctly", "[internal/data_structures/a
std::array<char, 64> small_data_two{};
std::array<char, 1> 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<typeof(small_data_three)>();
stack.pop<typeof(small_data_two)>();
auto pointer_four = stack.push(small_data_two);
auto pointer_five = stack.push(small_data_three);
auto pointer_one = stack.push<decltype(small_data_one)>(small_data_one);
auto pointer_two = stack.push<decltype(small_data_two)>(small_data_two);
auto pointer_three = stack.push<decltype(small_data_three)>(small_data_three);
stack.pop<decltype(small_data_three)>();
stack.pop<decltype(small_data_two)>();
auto pointer_four = stack.push<decltype(small_data_two)>(small_data_two);
auto pointer_five = stack.push<decltype(small_data_three)>(small_data_three);
REQUIRE(reinterpret_cast<std::uintptr_t>(pointer_one) % system_details::CACHE_LINE_SIZE == 0);
REQUIRE(reinterpret_cast<std::uintptr_t>(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<int> 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<int>(no_op, one);
deque.push_tail<int>(no_op, two);
deque.push_tail<int>(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<int>(no_op, one);
REQUIRE(*deque.pop_tail() == one);
deque.push_tail(two);
deque.push_tail<int>(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<int>(no_op, one);
deque.push_tail<int>(no_op, two);
deque.push_tail<int>(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<int>(no_op, one);
REQUIRE(*deque.pop_head() == one);
deque.push_tail(two);
deque.push_tail<int>(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<int>(no_op, one);
REQUIRE(*deque.pop_tail() == one);
deque.push_tail(two);
deque.push_tail<int>(no_op, two);
REQUIRE(*deque.pop_head() == two);
deque.push_tail(three);
deque.push_tail<int>(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<int>(no_op, one);
deque.push_tail<int>(no_op, two);
REQUIRE(*deque.pop_tail() == two);
deque.push_tail(three);
deque.push_tail(four);
deque.push_tail<int>(no_op, three);
deque.push_tail<int>(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<int>(no_op, one);
auto state = deque.save_state();
deque.push_tail(two);
deque.push_tail<int>(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<int>(no_op, three);
deque.push_tail<int>(no_op, four);
REQUIRE(*deque.pop_head() == three);
REQUIRE(*deque.pop_tail() == four);
}
SECTION("synces correctly") {
}
}
......@@ -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<once_sub_task>(counter_, children_ - 1);
}
}
......@@ -32,7 +32,7 @@ class force_steal_sub_task : public task {
(*overall_counter_)--;
if (overall_counter_->load() > 0) {
std::atomic<int> counter{1};
spawn_child(force_steal_sub_task(&counter, overall_counter_));
spawn_child<force_steal_sub_task>(&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<int> counter{0};
my_scheduler.perform_work([&]() {
once_sub_task sub_task{&counter, start_counter};
scheduler::spawn_child(sub_task);
scheduler::spawn_child<once_sub_task>(&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<int> dummy_parent{1}, overall_counter{8};
force_steal_sub_task sub_task{&dummy_parent, &overall_counter};
scheduler::spawn_child(sub_task);
scheduler::spawn_child<force_steal_sub_task>(&dummy_parent, &overall_counter);
// Required, as child operates on our stack's memory!!!
scheduler::wait_for_all();
......
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