Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
las3_pub
/
predictable_parallel_patterns
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
41b2f354
authored
Jun 12, 2019
by
FritzFlorian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor tests to fit new deque
parent
88dd5384
Pipeline
#1262
failed with stages
in 51 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
44 deletions
+39
-44
test/data_structures_test.cpp
+35
-38
test/scheduling_tests.cpp
+4
-6
No files found.
test/data_structures_test.cpp
View file @
41b2f354
...
@@ -23,9 +23,9 @@ TEST_CASE("aligned stack stores objects correctly", "[internal/data_structures/a
...
@@ -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
,
64
>
small_data_two
{};
std
::
array
<
char
,
1
>
small_data_three
{
'A'
};
std
::
array
<
char
,
1
>
small_data_three
{
'A'
};
auto
pointer_one
=
stack
.
push
(
small_data_one
);
auto
pointer_one
=
stack
.
push
<
decltype
(
small_data_one
)
>
(
small_data_one
);
auto
pointer_two
=
stack
.
push
(
small_data_two
);
auto
pointer_two
=
stack
.
push
<
decltype
(
small_data_two
)
>
(
small_data_two
);
auto
pointer_three
=
stack
.
push
(
small_data_three
);
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_one
)
%
system_details
::
CACHE_LINE_SIZE
==
0
);
REQUIRE
(
reinterpret_cast
<
std
::
uintptr_t
>
(
pointer_two
)
%
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
...
@@ -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
,
5
>
small_data_one
{
'a'
,
'b'
,
'c'
,
'd'
,
'e'
};
std
::
array
<
char
,
system_details
::
CACHE_LINE_SIZE
+
10
>
big_data_one
{};
std
::
array
<
char
,
system_details
::
CACHE_LINE_SIZE
+
10
>
big_data_one
{};
auto
big_pointer_one
=
stack
.
push
(
big_data_one
);
auto
big_pointer_one
=
stack
.
push
<
decltype
(
big_data_one
)
>
(
big_data_one
);
auto
small_pointer_one
=
stack
.
push
(
small_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
>
(
big_pointer_one
)
%
system_details
::
CACHE_LINE_SIZE
==
0
);
REQUIRE
(
reinterpret_cast
<
std
::
uintptr_t
>
(
small_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
...
@@ -46,7 +46,7 @@ TEST_CASE("aligned stack stores objects correctly", "[internal/data_structures/a
SECTION
(
"stack correctly stores and retrieves objects"
)
{
SECTION
(
"stack correctly stores and retrieves objects"
)
{
std
::
array
<
char
,
5
>
data_one
{
'a'
,
'b'
,
'c'
,
'd'
,
'e'
};
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
>>
();
auto
retrieved_data
=
stack
.
pop
<
std
::
array
<
char
,
5
>>
();
REQUIRE
(
retrieved_data
==
std
::
array
<
char
,
5
>
{
'a'
,
'b'
,
'c'
,
'd'
,
'e'
});
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
...
@@ -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
,
64
>
small_data_two
{};
std
::
array
<
char
,
1
>
small_data_three
{
'A'
};
std
::
array
<
char
,
1
>
small_data_three
{
'A'
};
auto
pointer_one
=
stack
.
push
(
small_data_one
);
auto
pointer_one
=
stack
.
push
<
decltype
(
small_data_one
)
>
(
small_data_one
);
auto
pointer_two
=
stack
.
push
(
small_data_two
);
auto
pointer_two
=
stack
.
push
<
decltype
(
small_data_two
)
>
(
small_data_two
);
auto
pointer_three
=
stack
.
push
(
small_data_three
);
auto
pointer_three
=
stack
.
push
<
decltype
(
small_data_three
)
>
(
small_data_three
);
stack
.
pop
<
typeof
(
small_data_three
)
>
();
stack
.
pop
<
decltype
(
small_data_three
)
>
();
stack
.
pop
<
typeof
(
small_data_two
)
>
();
stack
.
pop
<
decltype
(
small_data_two
)
>
();
auto
pointer_four
=
stack
.
push
(
small_data_two
);
auto
pointer_four
=
stack
.
push
<
decltype
(
small_data_two
)
>
(
small_data_two
);
auto
pointer_five
=
stack
.
push
(
small_data_three
);
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_one
)
%
system_details
::
CACHE_LINE_SIZE
==
0
);
REQUIRE
(
reinterpret_cast
<
std
::
uintptr_t
>
(
pointer_two
)
%
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
...
@@ -143,11 +143,12 @@ TEST_CASE("work stealing deque stores objects correctly", "[internal/data_struct
work_stealing_deque
<
int
>
deque
{
&
stack
};
work_stealing_deque
<
int
>
deque
{
&
stack
};
int
one
=
1
,
two
=
2
,
three
=
3
,
four
=
4
;
int
one
=
1
,
two
=
2
,
three
=
3
,
four
=
4
;
auto
no_op
=
[](
int
*
)
{};
// Empty-Callback
SECTION
(
"add and remove items form the tail"
)
{
SECTION
(
"add and remove items form the tail"
)
{
deque
.
push_tail
(
one
);
deque
.
push_tail
<
int
>
(
no_op
,
one
);
deque
.
push_tail
(
two
);
deque
.
push_tail
<
int
>
(
no_op
,
two
);
deque
.
push_tail
(
three
);
deque
.
push_tail
<
int
>
(
no_op
,
three
);
REQUIRE
(
*
deque
.
pop_tail
()
==
three
);
REQUIRE
(
*
deque
.
pop_tail
()
==
three
);
REQUIRE
(
*
deque
.
pop_tail
()
==
two
);
REQUIRE
(
*
deque
.
pop_tail
()
==
two
);
...
@@ -155,17 +156,17 @@ TEST_CASE("work stealing deque stores objects correctly", "[internal/data_struct
...
@@ -155,17 +156,17 @@ TEST_CASE("work stealing deque stores objects correctly", "[internal/data_struct
}
}
SECTION
(
"handles getting empty by popping the tail correctly"
)
{
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
);
REQUIRE
(
*
deque
.
pop_tail
()
==
one
);
deque
.
push_tail
(
two
);
deque
.
push_tail
<
int
>
(
no_op
,
two
);
REQUIRE
(
*
deque
.
pop_tail
()
==
two
);
REQUIRE
(
*
deque
.
pop_tail
()
==
two
);
}
}
SECTION
(
"remove items form the head"
)
{
SECTION
(
"remove items form the head"
)
{
deque
.
push_tail
(
one
);
deque
.
push_tail
<
int
>
(
no_op
,
one
);
deque
.
push_tail
(
two
);
deque
.
push_tail
<
int
>
(
no_op
,
two
);
deque
.
push_tail
(
three
);
deque
.
push_tail
<
int
>
(
no_op
,
three
);
REQUIRE
(
*
deque
.
pop_head
()
==
one
);
REQUIRE
(
*
deque
.
pop_head
()
==
one
);
REQUIRE
(
*
deque
.
pop_head
()
==
two
);
REQUIRE
(
*
deque
.
pop_head
()
==
two
);
...
@@ -173,52 +174,48 @@ TEST_CASE("work stealing deque stores objects correctly", "[internal/data_struct
...
@@ -173,52 +174,48 @@ TEST_CASE("work stealing deque stores objects correctly", "[internal/data_struct
}
}
SECTION
(
"handles getting empty by popping the head correctly"
)
{
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
);
REQUIRE
(
*
deque
.
pop_head
()
==
one
);
deque
.
push_tail
(
two
);
deque
.
push_tail
<
int
>
(
no_op
,
two
);
REQUIRE
(
*
deque
.
pop_head
()
==
two
);
REQUIRE
(
*
deque
.
pop_head
()
==
two
);
}
}
SECTION
(
"handles getting empty by popping the head and tail correctly"
)
{
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
);
REQUIRE
(
*
deque
.
pop_tail
()
==
one
);
deque
.
push_tail
(
two
);
deque
.
push_tail
<
int
>
(
no_op
,
two
);
REQUIRE
(
*
deque
.
pop_head
()
==
two
);
REQUIRE
(
*
deque
.
pop_head
()
==
two
);
deque
.
push_tail
(
three
);
deque
.
push_tail
<
int
>
(
no_op
,
three
);
REQUIRE
(
*
deque
.
pop_tail
()
==
three
);
REQUIRE
(
*
deque
.
pop_tail
()
==
three
);
}
}
SECTION
(
"handles jumps bigger 1 correctly"
)
{
SECTION
(
"handles jumps bigger 1 correctly"
)
{
deque
.
push_tail
(
one
);
deque
.
push_tail
<
int
>
(
no_op
,
one
);
deque
.
push_tail
(
two
);
deque
.
push_tail
<
int
>
(
no_op
,
two
);
REQUIRE
(
*
deque
.
pop_tail
()
==
two
);
REQUIRE
(
*
deque
.
pop_tail
()
==
two
);
deque
.
push_tail
(
three
);
deque
.
push_tail
<
int
>
(
no_op
,
three
);
deque
.
push_tail
(
four
);
deque
.
push_tail
<
int
>
(
no_op
,
four
);
REQUIRE
(
*
deque
.
pop_head
()
==
one
);
REQUIRE
(
*
deque
.
pop_head
()
==
one
);
REQUIRE
(
*
deque
.
pop_head
()
==
three
);
REQUIRE
(
*
deque
.
pop_head
()
==
three
);
REQUIRE
(
*
deque
.
pop_head
()
==
four
);
REQUIRE
(
*
deque
.
pop_head
()
==
four
);
}
}
SECTION
(
"handles stack reset 1 correctly when emptied by tail"
)
{
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
();
auto
state
=
deque
.
save_state
();
deque
.
push_tail
(
two
);
deque
.
push_tail
<
int
>
(
no_op
,
two
);
REQUIRE
(
*
deque
.
pop_tail
()
==
two
);
REQUIRE
(
*
deque
.
pop_tail
()
==
two
);
deque
.
release_memory_until
(
state
);
deque
.
release_memory_until
(
state
);
REQUIRE
(
*
deque
.
pop_tail
()
==
one
);
REQUIRE
(
*
deque
.
pop_tail
()
==
one
);
deque
.
push_tail
(
three
);
deque
.
push_tail
<
int
>
(
no_op
,
three
);
deque
.
push_tail
(
four
);
deque
.
push_tail
<
int
>
(
no_op
,
four
);
REQUIRE
(
*
deque
.
pop_head
()
==
three
);
REQUIRE
(
*
deque
.
pop_head
()
==
three
);
REQUIRE
(
*
deque
.
pop_tail
()
==
four
);
REQUIRE
(
*
deque
.
pop_tail
()
==
four
);
}
}
SECTION
(
"synces correctly"
)
{
}
}
}
test/scheduling_tests.cpp
View file @
41b2f354
...
@@ -12,7 +12,7 @@ class once_sub_task : public task {
...
@@ -12,7 +12,7 @@ class once_sub_task : public task {
void
execute_internal
()
override
{
void
execute_internal
()
override
{
(
*
counter_
)
++
;
(
*
counter_
)
++
;
for
(
int
i
=
0
;
i
<
children_
;
i
++
)
{
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 {
...
@@ -32,7 +32,7 @@ class force_steal_sub_task : public task {
(
*
overall_counter_
)
--
;
(
*
overall_counter_
)
--
;
if
(
overall_counter_
->
load
()
>
0
)
{
if
(
overall_counter_
->
load
()
>
0
)
{
std
::
atomic
<
int
>
counter
{
1
};
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...
while
(
counter
.
load
()
>
0
);
// Spin...
}
}
...
@@ -56,8 +56,7 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta
...
@@ -56,8 +56,7 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta
std
::
atomic
<
int
>
counter
{
0
};
std
::
atomic
<
int
>
counter
{
0
};
my_scheduler
.
perform_work
([
&
]()
{
my_scheduler
.
perform_work
([
&
]()
{
once_sub_task
sub_task
{
&
counter
,
start_counter
};
scheduler
::
spawn_child
<
once_sub_task
>
(
&
counter
,
start_counter
);
scheduler
::
spawn_child
(
sub_task
);
});
});
REQUIRE
(
counter
.
load
()
==
total_tasks
);
REQUIRE
(
counter
.
load
()
==
total_tasks
);
...
@@ -68,8 +67,7 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta
...
@@ -68,8 +67,7 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta
scheduler
my_scheduler
{
&
my_scheduler_memory
,
8
};
scheduler
my_scheduler
{
&
my_scheduler_memory
,
8
};
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
};
scheduler
::
spawn_child
<
force_steal_sub_task
>
(
&
dummy_parent
,
&
overall_counter
);
scheduler
::
spawn_child
(
sub_task
);
// Required, as child operates on our stack's memory!!!
// Required, as child operates on our stack's memory!!!
scheduler
::
wait_for_all
();
scheduler
::
wait_for_all
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment