Commit 7ff5a5c6 authored by Armin Sobhani's avatar Armin Sobhani
Browse files

fix problem with boost.compute random sequence benchmark

parent f0260b0e
......@@ -11,6 +11,7 @@
#define BOOST_BIOSEQ_SEQUENCE_HPP
#include <boost/algorithm/string/replace.hpp>
#include <boost/compute/system.hpp>
#ifndef BOOST_BIOSEQ_HAS_COMPONENT_HPP
#include <boost/bioseq/has_component.hpp>
......@@ -40,8 +41,8 @@ public:
: ContainerT<CharT, AllocatorT<CharT>>()
{}
explicit sequence_host(size_t count)
: ContainerT<CharT, AllocatorT<CharT>>(count)
explicit sequence_host(size_t count, const boost::compute::context& cntxt)
: ContainerT<CharT, AllocatorT<CharT>>(count, cntxt)
{}
explicit sequence_host(
......
......@@ -11,13 +11,14 @@
#include <iomanip>
#include <numeric>
#include <boost/range/algorithm/copy.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/compute/system.hpp>
#include <boost/compute/command_queue.hpp>
#include <boost/compute/container/vector.hpp>
#include <boost/compute/random.hpp>
#include <boost/compute/algorithm/transform.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>
......@@ -39,25 +40,38 @@ int main(int argc, char *argv[])
bc::context context(device);
bc::command_queue queue(context, device);
std::cout << "device: " << device.name() << std::endl;
// char acgt[] = "ACGT";
bc::default_random_engine rng(queue);
// ;
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];
});
seq rs(PERF_N, context);
perf_timer t;
for (size_t trial = 0; trial < PERF_TRIALS; ++trial)
{
seq rs(PERF_N);
t.start();
dist.generate(
rs.begin()
, rs.end()
, rng
, queue);
queue.finish();
bc::transform(
rs.begin()
, rs.end()
, rs.begin()
, acgt
, queue);
queue.finish();
t.stop();
}
std::cout << rs[0] << rs[1] << rs[2] << rs[3] << std::endl;
std::cout << "time: "
<< std::fixed << std::setprecision(2)
<< t.min_time() / 1e6 << " ms"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment