! \brief Gets a list of devices for this platform. * * Wraps clGetDeviceIDs(). */
| 2791 | * Wraps clGetDeviceIDs(). |
| 2792 | */ |
| 2793 | cl_int getDevices( |
| 2794 | cl_device_type type, |
| 2795 | vector<Device>* devices) const |
| 2796 | { |
| 2797 | cl_uint n = 0; |
| 2798 | if( devices == nullptr ) { |
| 2799 | return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); |
| 2800 | } |
| 2801 | cl_int err = ::clGetDeviceIDs(object_, type, 0, nullptr, &n); |
| 2802 | if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) { |
| 2803 | return detail::errHandler(err, __GET_DEVICE_IDS_ERR); |
| 2804 | } |
| 2805 | |
| 2806 | vector<cl_device_id> ids(n); |
| 2807 | if (n>0) { |
| 2808 | err = ::clGetDeviceIDs(object_, type, n, ids.data(), nullptr); |
| 2809 | if (err != CL_SUCCESS) { |
| 2810 | return detail::errHandler(err, __GET_DEVICE_IDS_ERR); |
| 2811 | } |
| 2812 | } |
| 2813 | |
| 2814 | // Cannot trivially assign because we need to capture intermediates |
| 2815 | // with safe construction |
| 2816 | // We must retain things we obtain from the API to avoid releasing |
| 2817 | // API-owned objects. |
| 2818 | if (devices) { |
| 2819 | devices->resize(ids.size()); |
| 2820 | |
| 2821 | // Assign to param, constructing with retain behaviour |
| 2822 | // to correctly capture each underlying CL object |
| 2823 | for (size_type i = 0; i < ids.size(); i++) { |
| 2824 | (*devices)[i] = Device(ids[i], true); |
| 2825 | } |
| 2826 | } |
| 2827 | return CL_SUCCESS; |
| 2828 | } |
| 2829 | |
| 2830 | #if defined(CL_HPP_USE_DX_INTEROP) |
| 2831 | /*! \brief Get the list of available D3D10 devices. |
no test coverage detected