Skip to content

Commit

Permalink
platform: add the device_selector constructor
Browse files Browse the repository at this point in the history
this needs to be in the tail due to device_selector
interactions.
  • Loading branch information
airlied committed Jun 28, 2018
1 parent 288dd40 commit 6e496a7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
5 changes: 1 addition & 4 deletions include/CL/sycl/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ class platform
Returns errors via the SYCL exception class.
*/
explicit platform(const device_selector &dev_selector) {
detail::unimplemented();
}

explicit platform(const device_selector &dev_selector);

#ifdef TRISYCL_OPENCL
/** Returns the cl_platform_id of the underlying OpenCL platform
Expand Down
18 changes: 18 additions & 0 deletions include/CL/sycl/platform/detail/platform_tail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@
namespace cl {
namespace sycl {

inline
platform::platform(const device_selector &device_selector) {
platform host_platform = {};
#ifdef TRISYCL_OPENCL
if (host_platform.implementation->get_devices(device_selector).empty()) {
for (const auto &d : boost::compute::system::platforms()) {
auto clplatform = cl::sycl::platform { d };
auto devices = clplatform.implementation->get_devices(device_selector);
if (!devices.empty()) {
*this = std::move(clplatform);
return;
}
}
}
#endif
*this = std::move(host_platform);
}

inline vector_class<device>
platform::get_devices(info::device_type device_type) const {
return implementation->get_devices(device_type_selector { device_type });
Expand Down

0 comments on commit 6e496a7

Please sign in to comment.