JayBeams  0.1
Another project to have fun coding.
device_selector.cpp
Go to the documentation of this file.
2 #include <jb/opencl/config.hpp>
3 
4 #include <iostream>
5 
6 namespace {
7 boost::compute::device device_selector(std::string const& name) {
8  using boost::compute::device;
9  if (name == "BESTCPU") {
11  [](device const& d) { return d.type() & device::cpu; }, "CPU");
12  }
13  if (name == "BESTGPU") {
15  [](device const& d) { return d.type() & device::gpu; }, "GPU");
16  }
17  if (name == "" or name == "SYSTEM:DEFAULT") {
18  return boost::compute::system::default_device();
19  }
20  return boost::compute::system::find_device(name);
21 }
22 } // anonymous namespace
23 
24 boost::compute::device jb::opencl::device_selector(config const& cfg) {
25  auto device = ::device_selector(cfg.device_name());
26  if (device.name().substr(0, 8) == "AMD SUMO" and cfg.device_name() == "") {
27  // LCOV_EXCL_START
28  // TODO(#124) - fix this when we have a better workaround ...
29  device = device_selector(jb::opencl::config().device_name("BESTGPU"));
30  // LCOV_EXCL_STOP
31  }
32  return device;
33 }
34 
35 boost::compute::device jb::opencl::device_selector() {
37 }
Configure the OpenCL device / context options.
Definition: config.hpp:12
boost::compute::device device_selector(config const &cfg)
Select an OpenCL device matching the current configuration.
boost::compute::device best_device(Filter filter, char const *filter_name)
Return the best available device of the given type.
std::string device_name(JB_DEFAULT_device_name)
jb::config_attribute< config, std::string > device_name
Definition: config.hpp:17