Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61193743
main_benchmark.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, May 5, 03:25
Size
2 KB
Mime Type
text/x-c++
Expires
Tue, May 7, 03:25 (2 d)
Engine
blob
Format
Raw Data
Handle
17478423
Attached To
R12667 gbench-stream
main_benchmark.cpp
View Options
/* -------------------------------------------------------------------------- */
#include <aka_iterators.hh>
#include <algorithm>
#include <benchmark/benchmark.h>
//#include <execution>
#include <vector>
//#include <tbb/tbb.h>
/* -------------------------------------------------------------------------- */
using
namespace
akantu
;
template
<
class
T
>
struct
uninitialized
{
uninitialized
()
{}
uninitialized
(
const
T
&
t
)
:
t
(
t
)
{}
constexpr
uninitialized
&
operator
=
(
const
T
&
t
)
noexcept
{
this
->
t
=
t
;
return
*
this
;
}
constexpr
operator
T
&
()
noexcept
{
return
this
->
t
;
}
T
t
;
};
class
MyFixture
:
public
benchmark
::
Fixture
{
using
stream_type
=
int
;
public
:
void
SetUp
(
::
benchmark
::
State
&
state
)
{
auto
&&
size
=
state
.
range
(
0
)
*
1024
/
sizeof
(
stream_type
);
A
.
resize
(
size
);
B
.
resize
(
size
);
// nthreads = oneapi::tbb::this_task_arena::max_concurrency();
state
.
counters
[
"size_kb"
]
=
A
.
size
()
*
sizeof
(
typename
decltype
(
A
)
::
value_type
)
/
1024
;
state
.
counters
[
"nthreads"
]
=
nthreads
;
auto
view
=
enumerate
(
A
,
B
);
std
::
for_each
(
view
.
begin
(),
view
.
end
(),
[](
auto
&&
data
)
{
std
::
get
<
1
>
(
data
)
=
2.
*
std
::
get
<
0
>
(
data
);
std
::
get
<
2
>
(
data
)
=
0.
;
});
}
void
TearDown
(
const
::
benchmark
::
State
&
/*state*/
)
{}
std
::
vector
<
stream_type
>
A
;
std
::
vector
<
stream_type
>
B
;
int
nthreads
{
0
};
};
BENCHMARK_DEFINE_F
(
MyFixture
,
CopyZip
)(
benchmark
::
State
&
st
)
{
auto
view
=
zip
(
A
,
B
);
for
(
auto
_
:
st
)
{
std
::
for_each
(
view
.
begin
(),
view
.
end
(),
[](
auto
&&
data
)
{
std
::
get
<
1
>
(
data
)
=
std
::
get
<
0
>
(
data
);
});
}
st
.
SetBytesProcessed
(
int64_t
(
st
.
iterations
())
*
A
.
size
()
*
sizeof
(
typename
decltype
(
A
)
::
value_type
)
*
2
);
}
BENCHMARK_REGISTER_F
(
MyFixture
,
CopyZip
)
->
RangeMultiplier
(
2
)
->
Range
(
2
,
1
<<
18
);
BENCHMARK_DEFINE_F
(
MyFixture
,
Copy
)(
benchmark
::
State
&
st
)
{
for
(
auto
_
:
st
)
{
for
(
auto
i
=
0
;
i
<
A
.
size
();
++
i
)
{
B
[
i
]
=
A
[
i
];
}
}
st
.
SetBytesProcessed
(
int64_t
(
st
.
iterations
())
*
A
.
size
()
*
sizeof
(
typename
decltype
(
A
)
::
value_type
)
*
2
);
}
BENCHMARK_REGISTER_F
(
MyFixture
,
Copy
)
->
RangeMultiplier
(
2
)
->
Range
(
2
,
1
<<
18
);
BENCHMARK_MAIN
();
Event Timeline
Log In to Comment