7 #include <boost/compute/command_queue.hpp> 19 int main(
int argc,
char* argv[]) {
20 auto testcases = create_testcases();
34 template <
bool pipelined>
37 fixture(boost::compute::context& context, boost::compute::command_queue& q)
38 : fixture(nsamples, context, q) {
41 int size, boost::compute::context& context,
42 boost::compute::command_queue& q)
52 boost::compute::copy(src.begin(), src.end(), in.begin(), queue);
53 fft.enqueue(out, in, queue).wait();
54 boost::compute::copy(out.begin(), out.end(), dst.begin(), queue);
55 return static_cast<int>(src.size());
59 typedef boost::compute::vector<std::complex<float>> invector;
60 typedef boost::compute::vector<std::complex<float>> outvector;
61 std::vector<std::complex<float>> src;
64 std::vector<std::complex<float>> dst;
65 boost::compute::command_queue queue;
70 int fixture<true>::run() {
71 using namespace boost::compute;
72 auto upload_done = copy_async(src.begin(), src.end(), in.begin(), queue);
74 fft.
enqueue(out, in, queue, wait_list(upload_done.get_event()));
75 queue.enqueue_barrier();
76 auto download_done = copy_async(out.begin(), out.end(), dst.begin(), queue);
78 return static_cast<int>(src.size());
81 template <
bool pipelined>
82 std::function<void(config const&)> test_case() {
83 return [](config
const& cfg) {
86 boost::compute::context context(device);
87 boost::compute::command_queue queue(context, device);
89 benchmark bm(cfg.microbenchmark());
91 auto r = bm.
run(context, queue);
98 {
"complex:float:async", test_case<true>()},
99 {
"complex:float:sync", test_case<false>()},
plan< invector, outvector > create_forward_plan_1d(outvector const &out, invector const &in, boost::compute::context &ct, boost::compute::command_queue &q, int batch_size=1)
Create a forward DFT plan.
Wrap clfftPlanHandle objects in a class that can automatically destroy them.
boost::compute::event enqueue(out_timeseries_type &out, in_timeseries_type const &in, boost::compute::command_queue &queue, boost::compute::wait_list const &wait=boost::compute::wait_list())
Enqueue the transform to be executed.
boost::compute::device device_selector(config const &cfg)
Select an OpenCL device matching the current configuration.
The configuration shared by all OpenCL microbenchmarks.
results run(Args &&... args)
Run the microbenchmaark.
int microbenchmark_group_main(int argc, char *argv[], microbenchmark_group< microbenchmark_config > const &testcases)
Overload microbenchmark_group_main for jb::testing::microbenchmark_config.
std::map< std::string, std::function< void(config const &cfg)> > microbenchmark_group
Define a representation for a group of microbenchmarks.
Wrap clfftPlanHandle objects.
void init(config const &cfg)
Initialize the logging functions using the configuration provided.
int main(int argc, char *argv[])
std::size_t nsamples(container_type const &a)
Count the elements in the last dimension of a vector-like container.
Run a micro-benchmark on a given class.