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

add OpenCL device iteration for the Boost.Compute benchmark

parent 7ff5a5c6
......@@ -36,51 +36,59 @@ 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;
// ;
boost::compute::default_random_engine rng(queue);
bc::uniform_int_distribution<int> dist(0, 3);
BOOST_COMPUTE_FUNCTION(char, acgt, (char b),
for (auto const& platform : bc::system::platforms())
{
char acgt[] = "ACGT";
return acgt[b];
});
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);
seq rs(PERF_N, context);
perf_timer t;
for (size_t trial = 0; trial < PERF_TRIALS; ++trial)
{
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();
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)
{
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"
<< 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;
}
}
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"
<< 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
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