Commit f0260b0e authored by Armin Sobhani's avatar Armin Sobhani
Browse files

add benchmark for random_sequence for boost.compute

parent 63da0b10
......@@ -40,6 +40,10 @@ public:
: ContainerT<CharT, AllocatorT<CharT>>()
{}
explicit sequence_host(size_t count)
: ContainerT<CharT, AllocatorT<CharT>>(count)
{}
explicit sequence_host(
const AllocatorT<CharT>& alloc)
: ContainerT<CharT, AllocatorT<CharT>>(alloc)
......
......@@ -14,7 +14,7 @@ set(BOOST_COMPONENTS system timer chrono program_options)
if(BOOST_COMPONENTS)
list(REMOVE_DUPLICATES BOOST_COMPONENTS)
endif()
find_package(Boost 1.53 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
find_package(Boost 1.61 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
set(BENCHMARKS
stl_random_sequence
......@@ -22,7 +22,17 @@ set(BENCHMARKS
)
foreach(BENCHMARK ${BENCHMARKS})
set(PERF_TARGET perf_${BENCHMARK})
add_executable(${PERF_TARGET} perf_${BENCHMARK}.cpp)
target_link_libraries(${PERF_TARGET} ${Boost_LIBRARIES})
endforeach()
set(BOOST_COMPUTE_BENCHMARKS
bc_random_sequence
)
foreach(BENCHMARK ${BOOST_COMPUTE_BENCHMARKS})
set(PERF_TARGET perf_${BENCHMARK})
add_executable(${PERF_TARGET} perf_${BENCHMARK}.cpp)
target_link_libraries(${PERF_TARGET} ${OpenCL_LIBRARIES} ${Boost_LIBRARIES})
endforeach()
\ No newline at end of file
endforeach()
//----------------------------------------------------------------------------//
// 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 <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/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, bc::buffer_allocator, bc::vector> seq;
int main(int argc, char *argv[])
{
perf_parse_args(argc, argv);
std::cout << "size: " << PERF_N << std::endl;
bc::device device(bc::system::default_device());
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);
bc::uniform_int_distribution<int> dist(0, 3);
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);
t.stop();
}
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;
return 0;
}
\ No newline at end of file
......@@ -46,6 +46,7 @@ int main(int argc, char *argv[])
, [&] () { return acgt[dist(rd)]; } );
t.stop();
}
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