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
2b269f96
authored
May 13, 2019
by
FritzFlorian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add matrix multiplication benchmark.
parent
e3237abd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
0 deletions
+87
-0
app/benchmark_matrix/CMakeLists.txt
+5
-0
app/benchmark_matrix/main.cpp
+82
-0
No files found.
app/benchmark_matrix/CMakeLists.txt
0 → 100644
View file @
2b269f96
add_executable
(
benchmark_matrix main.cpp
)
target_link_libraries
(
benchmark_matrix pls
)
if
(
EASY_PROFILER
)
target_link_libraries
(
benchmark_matrix easy_profiler
)
endif
()
app/benchmark_matrix/main.cpp
0 → 100644
View file @
2b269f96
#include <pls/pls.h>
#include <pls/internal/helpers/profiler.h>
#include <pls/internal/helpers/mini_benchmark.h>
#include <boost/range/irange.hpp>
const
int
MATRIX_SIZE
=
128
;
template
<
typename
T
,
int
SIZE
>
class
matrix
{
public
:
T
data
[
SIZE
][
SIZE
];
matrix
(
T
i
=
1
)
{
std
::
fill
(
&
data
[
0
][
0
],
&
data
[
0
][
0
]
+
SIZE
*
SIZE
,
i
);
}
void
multiply
(
const
matrix
<
T
,
SIZE
>
&
a
,
const
matrix
<
T
,
SIZE
>
&
b
)
{
auto
range
=
boost
::
irange
(
0
,
SIZE
);
pls
::
algorithm
::
parallel_for
(
range
.
begin
(),
range
.
end
(),
[
&
](
int
i
)
{
this
->
multiply_column
(
i
,
a
,
b
);
});
}
private
:
void
multiply_column
(
int
i
,
const
matrix
<
T
,
SIZE
>
&
a
,
const
matrix
<
T
,
SIZE
>
&
b
)
{
for
(
int
j
=
0
;
j
<
SIZE
;
++
j
)
{
data
[
i
][
j
]
=
0
;
}
for
(
int
k
=
0
;
k
<
SIZE
;
++
k
)
{
for
(
int
j
=
0
;
j
<
SIZE
;
++
j
)
{
data
[
i
][
j
]
+=
a
.
data
[
i
][
k
]
*
b
.
data
[
k
][
j
];
}
}
}
};
void
fill_with_data
(
matrix
<
double
,
MATRIX_SIZE
>
&
a
,
matrix
<
double
,
MATRIX_SIZE
>
&
b
)
{
// Fill in some data...
for
(
int
i
=
0
;
i
<
MATRIX_SIZE
;
i
++
)
{
for
(
int
j
=
0
;
j
<
MATRIX_SIZE
;
j
++
)
{
a
.
data
[
i
][
j
]
=
i
;
b
.
data
[
i
][
j
]
=
j
;
}
}
}
int
main
()
{
PROFILE_ENABLE
matrix
<
double
,
MATRIX_SIZE
>
a
;
matrix
<
double
,
MATRIX_SIZE
>
b
;
matrix
<
double
,
MATRIX_SIZE
>
result
;
fill_with_data
(
a
,
b
);
pls
::
internal
::
helpers
::
run_mini_benchmark
([
&
]
{
result
.
multiply
(
a
,
b
);
},
8
,
1000
);
PROFILE_SAVE
(
"test_profile.prof"
)
}
//int main() {
// PROFILE_ENABLE
// pls::malloc_scheduler_memory my_scheduler_memory{8, 2u << 18};
// pls::scheduler scheduler{&my_scheduler_memory, 8};
//
// matrix<double, MATRIX_SIZE> a;
// matrix<double, MATRIX_SIZE> b;
// matrix<double, MATRIX_SIZE> result;
// fill_with_data(a, b);
//
// scheduler.perform_work([&] {
// PROFILE_MAIN_THREAD
// for (int i = 0; i < 10; i++) {
// PROFILE_WORK_BLOCK("Top Level")
// result.multiply(a, b);
// }
// });
//
// PROFILE_SAVE("test_profile.prof")
//}
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