Skip to content

Commit 731c264

Browse files
committed
* Do not assume a device holds only a cl_device_id
1 parent d0c4e17 commit 731c264

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Diff for: include/boost/compute/context.hpp

+16-3
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,19 @@ class context
8383

8484
cl_int error = 0;
8585

86+
std::vector<cl_device_id> device_ids;
87+
std::string name, version;
88+
for (size_t i = 0; i < devices.size(); ++i) {
89+
const device &dev = devices[i];
90+
name = dev.name();
91+
version = dev.version();
92+
device_ids.push_back(devices[i].get());
93+
}
8694
m_version = 0;
8795
m_context = clCreateContext(
8896
properties,
89-
static_cast<cl_uint>(devices.size()),
90-
reinterpret_cast<const cl_device_id *>(&devices[0]),
97+
static_cast<cl_uint>(device_ids.size()),
98+
reinterpret_cast<const cl_device_id *>(&device_ids[0]),
9199
0,
92100
0,
93101
&error
@@ -207,7 +215,12 @@ class context
207215
/// Returns a vector of devices for the context.
208216
std::vector<device> get_devices() const
209217
{
210-
return get_info<std::vector<device> >(CL_CONTEXT_DEVICES);
218+
std::vector<device> out;
219+
std::vector<cl_device_id> id_vector = get_info<std::vector<cl_device_id> >(CL_CONTEXT_DEVICES);
220+
for (std::vector<cl_device_id>::iterator it = id_vector.begin(); it != id_vector.end(); ++it) {
221+
out.push_back(device(*it));
222+
}
223+
return out;
211224
}
212225

213226
/// Returns information about the context.

0 commit comments

Comments
 (0)