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
ce936ae6
authored
Jun 14, 2019
by
FritzFlorian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for for_each and for_each_range.
parent
7581ccfa
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
2 deletions
+49
-2
app/benchmark_matrix/main.cpp
+1
-1
lib/pls/include/pls/pls.h
+1
-0
test/CMakeLists.txt
+2
-1
test/algorithm_test.cpp
+45
-0
No files found.
app/benchmark_matrix/main.cpp
View file @
ce936ae6
...
...
@@ -14,7 +14,7 @@ class matrix {
}
void
multiply
(
const
matrix
<
T
,
SIZE
>
&
a
,
const
matrix
<
T
,
SIZE
>
&
b
)
{
pls
::
algorithm
::
for_each_range
(
0
,
SIZE
,
[
&
](
int
i
)
{
pls
::
for_each_range
(
0
,
SIZE
,
[
&
](
int
i
)
{
this
->
multiply_column
(
i
,
a
,
b
);
});
}
...
...
lib/pls/include/pls/pls.h
View file @
ce936ae6
...
...
@@ -24,6 +24,7 @@ using internal::scheduling::task;
using
algorithm
::
invoke
;
using
algorithm
::
for_each
;
using
algorithm
::
for_each_range
;
using
algorithm
::
scan
;
}
...
...
test/CMakeLists.txt
View file @
ce936ae6
add_executable
(
tests
main.cpp
data_structures_test.cpp
scheduling_tests.cpp
)
scheduling_tests.cpp
algorithm_test.cpp
)
target_link_libraries
(
tests catch2 pls
)
test/algorithm_test.cpp
0 → 100644
View file @
ce936ae6
#include <catch.hpp>
#include <array>
#include <pls/pls.h>
using
namespace
pls
;
TEST_CASE
(
"for_each functions correctly"
,
"[algorithms/for_each.h]"
)
{
malloc_scheduler_memory
my_scheduler_memory
{
8
,
2
<<
12
};
scheduler
my_scheduler
{
&
my_scheduler_memory
,
2
};
my_scheduler
.
perform_work
([]()
{
constexpr
int
SIZE
=
1000
;
std
::
array
<
int
,
SIZE
>
result_array
{};
result_array
.
fill
(
0
);
SECTION
(
"integer ranges are processed exactly once"
)
{
pls
::
for_each_range
(
0
,
SIZE
,
[
&
result_array
](
int
i
)
{
result_array
[
i
]
++
;
});
bool
all_equal
=
true
;
for
(
int
i
=
0
;
i
<
SIZE
;
i
++
)
{
all_equal
&=
result_array
[
i
]
==
1
;
}
REQUIRE
(
all_equal
);
}
SECTION
(
"iterators are processed exactly once"
)
{
std
::
array
<
int
,
SIZE
>
iterator_array
{};
for
(
int
i
=
0
;
i
<
SIZE
;
i
++
)
{
iterator_array
[
i
]
=
i
;
}
pls
::
for_each
(
iterator_array
.
begin
(),
iterator_array
.
end
(),
[
&
result_array
](
int
i
)
{
result_array
[
i
]
++
;
});
bool
all_equal
=
true
;
for
(
int
i
=
0
;
i
<
SIZE
;
i
++
)
{
all_equal
&=
result_array
[
i
]
==
1
;
}
REQUIRE
(
all_equal
);
}
});
}
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