Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Armin Sobhani
bioseq
Commits
092aae60
Commit
092aae60
authored
Aug 09, 2018
by
Armin Sobhani
Browse files
add perf_bc_reverse_complement.cpp
parent
d8785060
Changes
2
Hide whitespace changes
Inline
Side-by-side
perf/CMakeLists.txt
View file @
092aae60
...
...
@@ -29,6 +29,7 @@ endforeach()
set
(
BOOST_COMPUTE_BENCHMARKS
bc_random_sequence
bc_reverse_complement
)
foreach
(
BENCHMARK
${
BOOST_COMPUTE_BENCHMARKS
}
)
...
...
perf/perf_bc_reverse_complement.cpp
0 → 100644
View file @
092aae60
//----------------------------------------------------------------------------//
// Copyright (c) 2018 Armin Sobhani <arminms@gmail.com>
//
// Distributed under the Boost Software License Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//----------------------------------------------------------------------------//
#include
<iostream>
#include
<iomanip>
#include
<numeric>
#include
<vector>
#include
<random>
#include
<boost/compute/system.hpp>
#include
<boost/compute/command_queue.hpp>
#include
<boost/compute/container/vector.hpp>
#include
<boost/compute/algorithm/transform.hpp>
#include
<boost/compute/random.hpp>
// #include <boost/compute/algorithm/sort.hpp>
// #include <boost/compute/random/default_random_engine.hpp>
// #include <boost/compute/random/uniform_int_distribution.hpp>
#include
<boost/bioseq/type_traits.hpp>
#include
<boost/bioseq/sequence.hpp>
#include
"perf.hpp"
#include
"rss.hpp"
namespace
bsq
=
boost
::
bioseq
;
namespace
bc
=
boost
::
compute
;
typedef
bsq
::
sequence_host
<
char
,
std
::
allocator
,
std
::
vector
>
seq
;
int
main
(
int
argc
,
char
*
argv
[])
{
perf_parse_args
(
argc
,
argv
);
std
::
cout
<<
"size: "
<<
PERF_N
<<
std
::
endl
;
// char acgt[] = "ACGT";
// std::random_device rd;
// std::uniform_int_distribution<int> dist(0, 3);
// seq rs;
// rs.reserve(PERF_N);
// // create vector of random sequence
// std::generate_n(
// std::back_inserter(rs)
// , PERF_N
// , [&] () { return acgt[dist(rd)]; } );
// std::cout << rs[0] << rs[1] << rs[2] << rs[3] << std::endl;
for
(
auto
const
&
platform
:
bc
::
system
::
platforms
())
{
std
::
cout
<<
">>>>>>>>>> "
<<
platform
.
name
()
<<
" <<<<<<<<<<
\n
:"
<<
std
::
endl
;
for
(
auto
const
&
device
:
platform
.
devices
())
{
std
::
cout
<<
"device: "
<<
device
.
name
()
<<
std
::
endl
;
bc
::
context
context
(
device
);
bc
::
command_queue
queue
(
context
,
device
);
boost
::
compute
::
default_random_engine
rng
(
queue
);
bc
::
uniform_int_distribution
<
int
>
dist
(
0
,
3
);
BOOST_COMPUTE_FUNCTION
(
char
,
acgt
,
(
char
b
),
{
char
acgt
[]
=
"ACGT"
;
return
acgt
[
b
];
});
bc
::
vector
<
char
>
rs
(
PERF_N
,
context
);
dist
.
generate
(
rs
.
begin
()
,
rs
.
end
()
,
rng
,
queue
);
queue
.
finish
();
bc
::
transform
(
rs
.
begin
()
,
rs
.
end
()
,
rs
.
begin
()
,
acgt
,
queue
);
queue
.
finish
();
boost
::
compute
::
copy
(
rs
.
begin
()
,
rs
.
begin
()
+
10
,
std
::
ostream_iterator
<
char
>
(
std
::
cout
)
,
queue
);
std
::
cout
<<
std
::
endl
;
// bc::vector<char> cs(PERF_N, context);
// bc::copy(rs.begin(), rs.end(), cs.begin(), queue);
BOOST_COMPUTE_FUNCTION
(
char
,
complement
,
(
char
b
),
{
char
cmplmnt
[]
=
"--------------------------------"
" !-#$%&-()*+,-./0123456789:;<=>?"
"@TVGHEFCHIJMLKNOPQYSAUBWXRZ[-]^_"
"`tvghefcdijmlknopqysaubwxrz{|}~"
;
return
cmplmnt
[
b
];
});
// BOOST_COMPUTE_CLOSURE(char, complement, (char b), (cmplmnt),
// {
// return cmplmnt[b];
// });
perf_timer
t
;
for
(
size_t
trial
=
0
;
trial
<
PERF_TRIALS
;
++
trial
)
{
t
.
start
();
// bc::sort(rs.begin(), rs.end(), queue);
bc
::
transform
(
rs
.
begin
()
,
rs
.
end
()
,
rs
.
begin
()
,
complement
,
queue
);
queue
.
finish
();
t
.
stop
();
}
seq
cs
;
cs
.
reserve
(
PERF_N
);
bc
::
copy
(
rs
.
begin
(),
rs
.
end
(),
std
::
back_inserter
(
cs
),
queue
);
std
::
cout
<<
cs
(
0
,
10
)
<<
std
::
endl
;
std
::
cout
<<
"time: "
<<
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
t
.
min_time
()
/
1e6
<<
" ms"
<<
std
::
endl
;
std
::
cout
<<
"rate: "
<<
perf_rate
<
char
>
(
PERF_N
,
t
.
min_time
())
<<
" MB/s"
<<
std
::
endl
;
std
::
cout
<<
"mrss: "
<<
bytes2size
(
get_peak_rss
())
<<
std
::
endl
<<
':'
<<
std
::
endl
;
}
}
return
0
;
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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