4 #include <boost/compute/system.hpp> 5 #include <boost/test/unit_test.hpp> 11 auto devices = boost::compute::system::devices();
12 for (
auto const& d : devices) {
13 BOOST_TEST_MESSAGE(
"searching for " << d.name());
14 boost::compute::device actual =
17 BOOST_CHECK_EQUAL(d.name(), actual.name());
18 BOOST_CHECK_EQUAL(d.id(), actual.id());
27 auto expected = boost::compute::system::default_device();
28 BOOST_TEST_MESSAGE(
"Default selector picked " << actual.name());
30 if (expected.name().substr(0, 8) ==
"AMD SUMO") {
33 BOOST_CHECK_NE(expected.id(), actual.id());
34 BOOST_CHECK_NE(expected.name(), actual.name());
36 BOOST_CHECK_EQUAL(expected.id(), actual.id());
37 BOOST_CHECK_EQUAL(expected.name(), actual.name());
45 boost::compute::device actual;
49 }
catch (std::exception
const& ex) {
51 BOOST_TEST_MESSAGE(
"No available CPU, abort test");
54 BOOST_TEST_MESSAGE(
"Default selector picked " << actual.name());
56 for (
auto const& d : boost::compute::system::devices()) {
57 if (d.type() & boost::compute::device::cpu) {
58 BOOST_TEST_MESSAGE(
"checking compute unit count for " << d.name());
59 BOOST_CHECK_GE(actual.compute_units(), d.compute_units());
68 boost::compute::device actual;
72 }
catch (std::exception
const& ex) {
75 BOOST_TEST_MESSAGE(
"No available GPU, abort test");
78 BOOST_TEST_MESSAGE(
"Default selector picked " << actual.name());
80 for (
auto const& d : boost::compute::system::devices()) {
81 if (d.type() & boost::compute::device::gpu) {
82 BOOST_TEST_MESSAGE(
"checking compute unit count for " << d.name());
83 BOOST_CHECK_GE(actual.compute_units(), d.compute_units());
96 "Default device name=" << actual.name() <<
", id=" << actual.id()
97 <<
", type=" << actual.type());
98 if (expected.name().substr(0, 8) ==
"AMD SUMO") {
101 BOOST_CHECK_NE(expected.id(), actual.id());
102 BOOST_CHECK_NE(expected.name(), actual.name());
104 BOOST_CHECK_EQUAL(expected.id(), actual.id());
105 BOOST_CHECK_EQUAL(expected.name(), actual.name());
115 auto expected = boost::compute::system::default_device();
117 BOOST_CHECK_EQUAL(expected.id(), actual.id());
118 BOOST_CHECK_EQUAL(expected.name(), actual.name());
125 using boost::compute::device;
128 [](device
const&) {
return false; },
"FAIL"),
131 [](device
const&) {
return true; },
"ANY"));
Configure the OpenCL device / context options.
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)
BOOST_AUTO_TEST_CASE(opencl_device_selector_by_name)