]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | //---------------------------------------------------------------------------// |
2 | // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com> | |
3 | // | |
4 | // Distributed under the Boost Software License, Version 1.0 | |
5 | // See accompanying file LICENSE_1_0.txt or copy at | |
6 | // http://www.boost.org/LICENSE_1_0.txt | |
7 | // | |
8 | // See http://boostorg.github.com/compute for more information. | |
9 | //---------------------------------------------------------------------------// | |
10 | ||
11 | #ifndef BOOST_COMPUTE_DEVICE_HPP | |
12 | #define BOOST_COMPUTE_DEVICE_HPP | |
13 | ||
14 | #include <algorithm> | |
15 | #include <string> | |
16 | #include <vector> | |
17 | ||
18 | #include <boost/algorithm/string/split.hpp> | |
19 | #include <boost/algorithm/string/classification.hpp> | |
20 | ||
21 | #include <boost/compute/config.hpp> | |
22 | #include <boost/compute/exception.hpp> | |
23 | #include <boost/compute/types/fundamental.hpp> | |
b32b8144 | 24 | #include <boost/compute/detail/duration.hpp> |
7c673cae FG |
25 | #include <boost/compute/detail/get_object_info.hpp> |
26 | #include <boost/compute/detail/assert_cl_success.hpp> | |
27 | ||
28 | namespace boost { | |
29 | namespace compute { | |
30 | ||
31 | class platform; | |
32 | ||
33 | /// \class device | |
34 | /// \brief A compute device. | |
35 | /// | |
36 | /// Typical compute devices include GPUs and multi-core CPUs. A list | |
37 | /// of all compute devices available on a platform can be obtained | |
38 | /// via the platform::devices() method. | |
39 | /// | |
40 | /// The default compute device for the system can be obtained with | |
41 | /// the system::default_device() method. For example: | |
42 | /// | |
43 | /// \snippet test/test_device.cpp default_gpu | |
44 | /// | |
45 | /// \see platform, context, command_queue | |
46 | class device | |
47 | { | |
48 | public: | |
49 | enum type { | |
50 | cpu = CL_DEVICE_TYPE_CPU, | |
51 | gpu = CL_DEVICE_TYPE_GPU, | |
52 | accelerator = CL_DEVICE_TYPE_ACCELERATOR | |
53 | }; | |
54 | ||
55 | /// Creates a null device object. | |
56 | device() | |
57 | : m_id(0) | |
58 | { | |
59 | } | |
60 | ||
61 | /// Creates a new device object for \p id. If \p retain is \c true, | |
62 | /// the reference count for the device will be incremented. | |
63 | explicit device(cl_device_id id, bool retain = true) | |
64 | : m_id(id) | |
65 | { | |
b32b8144 | 66 | #ifdef BOOST_COMPUTE_CL_VERSION_1_2 |
7c673cae FG |
67 | if(m_id && retain && is_subdevice()){ |
68 | clRetainDevice(m_id); | |
69 | } | |
70 | #else | |
71 | (void) retain; | |
72 | #endif | |
73 | } | |
74 | ||
75 | /// Creates a new device object as a copy of \p other. | |
76 | device(const device &other) | |
77 | : m_id(other.m_id) | |
78 | { | |
b32b8144 | 79 | #ifdef BOOST_COMPUTE_CL_VERSION_1_2 |
7c673cae FG |
80 | if(m_id && is_subdevice()){ |
81 | clRetainDevice(m_id); | |
82 | } | |
83 | #endif | |
84 | } | |
85 | ||
86 | /// Copies the device from \p other to \c *this. | |
87 | device& operator=(const device &other) | |
88 | { | |
89 | if(this != &other){ | |
b32b8144 | 90 | #ifdef BOOST_COMPUTE_CL_VERSION_1_2 |
7c673cae FG |
91 | if(m_id && is_subdevice()){ |
92 | clReleaseDevice(m_id); | |
93 | } | |
94 | #endif | |
95 | ||
96 | m_id = other.m_id; | |
97 | ||
b32b8144 | 98 | #ifdef BOOST_COMPUTE_CL_VERSION_1_2 |
7c673cae FG |
99 | if(m_id && is_subdevice()){ |
100 | clRetainDevice(m_id); | |
101 | } | |
102 | #endif | |
103 | } | |
104 | ||
105 | return *this; | |
106 | } | |
107 | ||
108 | #ifndef BOOST_COMPUTE_NO_RVALUE_REFERENCES | |
109 | /// Move-constructs a new device object from \p other. | |
110 | device(device&& other) BOOST_NOEXCEPT | |
111 | : m_id(other.m_id) | |
112 | { | |
113 | other.m_id = 0; | |
114 | } | |
115 | ||
116 | /// Move-assigns the device from \p other to \c *this. | |
117 | device& operator=(device&& other) BOOST_NOEXCEPT | |
118 | { | |
b32b8144 | 119 | #ifdef BOOST_COMPUTE_CL_VERSION_1_2 |
7c673cae FG |
120 | if(m_id && is_subdevice()){ |
121 | clReleaseDevice(m_id); | |
122 | } | |
123 | #endif | |
124 | ||
125 | m_id = other.m_id; | |
126 | other.m_id = 0; | |
127 | ||
128 | return *this; | |
129 | } | |
130 | #endif // BOOST_COMPUTE_NO_RVALUE_REFERENCES | |
131 | ||
132 | /// Destroys the device object. | |
133 | ~device() | |
134 | { | |
b32b8144 | 135 | #ifdef BOOST_COMPUTE_CL_VERSION_1_2 |
7c673cae FG |
136 | if(m_id && is_subdevice()){ |
137 | BOOST_COMPUTE_ASSERT_CL_SUCCESS( | |
138 | clReleaseDevice(m_id) | |
139 | ); | |
140 | } | |
141 | #endif | |
142 | } | |
143 | ||
144 | /// Returns the ID of the device. | |
145 | cl_device_id id() const | |
146 | { | |
147 | return m_id; | |
148 | } | |
149 | ||
150 | /// Returns a reference to the underlying OpenCL device id. | |
151 | cl_device_id& get() const | |
152 | { | |
153 | return const_cast<cl_device_id&>(m_id); | |
154 | } | |
155 | ||
156 | /// Returns the type of the device. | |
157 | cl_device_type type() const | |
158 | { | |
159 | return get_info<cl_device_type>(CL_DEVICE_TYPE); | |
160 | } | |
161 | ||
162 | #ifdef BOOST_COMPUTE_DOXYGEN_INVOKED | |
163 | /// Returns the platform for the device. | |
164 | platform platform() const; | |
165 | #else | |
166 | boost::compute::platform platform() const; | |
167 | #endif | |
168 | ||
169 | /// Returns the name of the device. | |
170 | std::string name() const | |
171 | { | |
172 | return get_info<std::string>(CL_DEVICE_NAME); | |
173 | } | |
174 | ||
175 | /// Returns the name of the vendor for the device. | |
176 | std::string vendor() const | |
177 | { | |
178 | return get_info<std::string>(CL_DEVICE_VENDOR); | |
179 | } | |
180 | ||
181 | /// Returns the device profile string. | |
182 | std::string profile() const | |
183 | { | |
184 | return get_info<std::string>(CL_DEVICE_PROFILE); | |
185 | } | |
186 | ||
187 | /// Returns the device version string. | |
188 | std::string version() const | |
189 | { | |
190 | return get_info<std::string>(CL_DEVICE_VERSION); | |
191 | } | |
192 | ||
193 | /// Returns the driver version string. | |
194 | std::string driver_version() const | |
195 | { | |
196 | return get_info<std::string>(CL_DRIVER_VERSION); | |
197 | } | |
198 | ||
199 | /// Returns a list of extensions supported by the device. | |
200 | std::vector<std::string> extensions() const | |
201 | { | |
202 | std::string extensions_string = | |
203 | get_info<std::string>(CL_DEVICE_EXTENSIONS); | |
204 | std::vector<std::string> extensions_vector; | |
205 | boost::split(extensions_vector, | |
206 | extensions_string, | |
207 | boost::is_any_of("\t "), | |
208 | boost::token_compress_on); | |
209 | return extensions_vector; | |
210 | } | |
211 | ||
212 | /// Returns \c true if the device supports the extension with | |
213 | /// \p name. | |
214 | bool supports_extension(const std::string &name) const | |
215 | { | |
216 | const std::vector<std::string> extensions = this->extensions(); | |
217 | ||
218 | return std::find( | |
219 | extensions.begin(), extensions.end(), name) != extensions.end(); | |
220 | } | |
221 | ||
222 | /// Returns the number of address bits. | |
223 | uint_ address_bits() const | |
224 | { | |
225 | return get_info<uint_>(CL_DEVICE_ADDRESS_BITS); | |
226 | } | |
227 | ||
228 | /// Returns the global memory size in bytes. | |
229 | ulong_ global_memory_size() const | |
230 | { | |
231 | return get_info<ulong_>(CL_DEVICE_GLOBAL_MEM_SIZE); | |
232 | } | |
233 | ||
234 | /// Returns the local memory size in bytes. | |
235 | ulong_ local_memory_size() const | |
236 | { | |
237 | return get_info<ulong_>(CL_DEVICE_LOCAL_MEM_SIZE); | |
238 | } | |
239 | ||
240 | /// Returns the clock frequency for the device's compute units. | |
241 | uint_ clock_frequency() const | |
242 | { | |
243 | return get_info<uint_>(CL_DEVICE_MAX_CLOCK_FREQUENCY); | |
244 | } | |
245 | ||
246 | /// Returns the number of compute units in the device. | |
247 | uint_ compute_units() const | |
248 | { | |
249 | return get_info<uint_>(CL_DEVICE_MAX_COMPUTE_UNITS); | |
250 | } | |
251 | ||
252 | /// \internal_ | |
253 | ulong_ max_memory_alloc_size() const | |
254 | { | |
255 | return get_info<ulong_>(CL_DEVICE_MAX_MEM_ALLOC_SIZE); | |
256 | } | |
257 | ||
258 | /// \internal_ | |
259 | size_t max_work_group_size() const | |
260 | { | |
261 | return get_info<size_t>(CL_DEVICE_MAX_WORK_GROUP_SIZE); | |
262 | } | |
263 | ||
264 | /// \internal_ | |
265 | uint_ max_work_item_dimensions() const | |
266 | { | |
267 | return get_info<uint_>(CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS); | |
268 | } | |
269 | ||
270 | /// Returns the preferred vector width for type \c T. | |
271 | template<class T> | |
272 | uint_ preferred_vector_width() const | |
273 | { | |
274 | return 0; | |
275 | } | |
276 | ||
277 | /// Returns the profiling timer resolution in nanoseconds. | |
278 | size_t profiling_timer_resolution() const | |
279 | { | |
280 | return get_info<size_t>(CL_DEVICE_PROFILING_TIMER_RESOLUTION); | |
281 | } | |
282 | ||
283 | /// Returns \c true if the device is a sub-device. | |
284 | bool is_subdevice() const | |
285 | { | |
b32b8144 | 286 | #if defined(BOOST_COMPUTE_CL_VERSION_1_2) |
7c673cae FG |
287 | try { |
288 | return get_info<cl_device_id>(CL_DEVICE_PARENT_DEVICE) != 0; | |
289 | } | |
290 | catch(opencl_error&){ | |
291 | // the get_info() call above will throw if the device's opencl version | |
292 | // is less than 1.2 (in which case it can't be a sub-device). | |
293 | return false; | |
294 | } | |
295 | #else | |
296 | return false; | |
297 | #endif | |
298 | } | |
299 | ||
300 | /// Returns information about the device. | |
301 | /// | |
302 | /// For example, to get the number of compute units: | |
303 | /// \code | |
304 | /// device.get_info<cl_uint>(CL_DEVICE_MAX_COMPUTE_UNITS); | |
305 | /// \endcode | |
306 | /// | |
307 | /// Alternatively, the template-specialized version can be used which | |
308 | /// automatically determines the result type: | |
309 | /// \code | |
310 | /// device.get_info<CL_DEVICE_MAX_COMPUTE_UNITS>(); | |
311 | /// \endcode | |
312 | /// | |
313 | /// \see_opencl_ref{clGetDeviceInfo} | |
314 | template<class T> | |
315 | T get_info(cl_device_info info) const | |
316 | { | |
317 | return detail::get_object_info<T>(clGetDeviceInfo, m_id, info); | |
318 | } | |
319 | ||
320 | /// \overload | |
321 | template<int Enum> | |
322 | typename detail::get_object_info_type<device, Enum>::type | |
323 | get_info() const; | |
324 | ||
b32b8144 | 325 | #if defined(BOOST_COMPUTE_CL_VERSION_1_2) || defined(BOOST_COMPUTE_DOXYGEN_INVOKED) |
7c673cae FG |
326 | /// Partitions the device into multiple sub-devices according to |
327 | /// \p properties. | |
328 | /// | |
329 | /// \opencl_version_warning{1,2} | |
330 | std::vector<device> | |
331 | partition(const cl_device_partition_property *properties) const | |
332 | { | |
333 | // get sub-device count | |
334 | uint_ count = 0; | |
335 | int_ ret = clCreateSubDevices(m_id, properties, 0, 0, &count); | |
336 | if(ret != CL_SUCCESS){ | |
337 | BOOST_THROW_EXCEPTION(opencl_error(ret)); | |
338 | } | |
339 | ||
340 | // get sub-device ids | |
341 | std::vector<cl_device_id> ids(count); | |
342 | ret = clCreateSubDevices(m_id, properties, count, &ids[0], 0); | |
343 | if(ret != CL_SUCCESS){ | |
344 | BOOST_THROW_EXCEPTION(opencl_error(ret)); | |
345 | } | |
346 | ||
347 | // convert ids to device objects | |
348 | std::vector<device> devices(count); | |
349 | for(size_t i = 0; i < count; i++){ | |
350 | devices[i] = device(ids[i], false); | |
351 | } | |
352 | ||
353 | return devices; | |
354 | } | |
355 | ||
356 | /// \opencl_version_warning{1,2} | |
357 | std::vector<device> partition_equally(size_t count) const | |
358 | { | |
359 | cl_device_partition_property properties[] = { | |
360 | CL_DEVICE_PARTITION_EQUALLY, | |
361 | static_cast<cl_device_partition_property>(count), | |
362 | 0 | |
363 | }; | |
364 | ||
365 | return partition(properties); | |
366 | } | |
367 | ||
368 | /// \opencl_version_warning{1,2} | |
369 | std::vector<device> | |
370 | partition_by_counts(const std::vector<size_t> &counts) const | |
371 | { | |
372 | std::vector<cl_device_partition_property> properties; | |
373 | ||
374 | properties.push_back(CL_DEVICE_PARTITION_BY_COUNTS); | |
375 | for(size_t i = 0; i < counts.size(); i++){ | |
376 | properties.push_back( | |
377 | static_cast<cl_device_partition_property>(counts[i])); | |
378 | } | |
379 | properties.push_back(CL_DEVICE_PARTITION_BY_COUNTS_LIST_END); | |
380 | properties.push_back(0); | |
381 | ||
382 | return partition(&properties[0]); | |
383 | } | |
384 | ||
385 | /// \opencl_version_warning{1,2} | |
386 | std::vector<device> | |
387 | partition_by_affinity_domain(cl_device_affinity_domain domain) const | |
388 | { | |
389 | cl_device_partition_property properties[] = { | |
390 | CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, | |
391 | static_cast<cl_device_partition_property>(domain), | |
392 | 0 | |
393 | }; | |
394 | ||
395 | return partition(properties); | |
396 | } | |
b32b8144 FG |
397 | #endif // BOOST_COMPUTE_CL_VERSION_1_2 |
398 | ||
399 | #if defined(BOOST_COMPUTE_CL_VERSION_2_1) || defined(BOOST_COMPUTE_DOXYGEN_INVOKED) | |
400 | /// Returns the current value of the host clock as seen by device | |
401 | /// in nanoseconds. | |
402 | /// | |
403 | /// \see_opencl21_ref{clGetHostTimer} | |
404 | /// | |
405 | /// \opencl_version_warning{2,1} | |
406 | ulong_ get_host_timer() const | |
407 | { | |
408 | ulong_ host_timestamp = 0; | |
409 | cl_int ret = clGetHostTimer(m_id, &host_timestamp); | |
410 | if(ret != CL_SUCCESS){ | |
411 | BOOST_THROW_EXCEPTION(opencl_error(ret)); | |
412 | } | |
413 | return host_timestamp; | |
414 | } | |
415 | ||
416 | /// Returns a reasonably synchronized pair of timestamps from the device timer | |
417 | /// and the host timer as seen by device in nanoseconds. The first of returned | |
418 | /// std::pair is a device timer timestamp, the second is a host timer timestamp. | |
419 | /// | |
420 | /// \see_opencl21_ref{clGetDeviceAndHostTimer} | |
421 | /// | |
422 | /// \opencl_version_warning{2,1} | |
423 | std::pair<ulong_, ulong_> get_device_and_host_timer() const | |
424 | { | |
425 | ulong_ host_timestamp; | |
426 | ulong_ device_timestamp; | |
427 | cl_int ret = clGetDeviceAndHostTimer( | |
428 | m_id, &device_timestamp, &host_timestamp | |
429 | ); | |
430 | if(ret != CL_SUCCESS){ | |
431 | BOOST_THROW_EXCEPTION(opencl_error(ret)); | |
432 | } | |
433 | return std::make_pair( | |
434 | device_timestamp, host_timestamp | |
435 | ); | |
436 | } | |
437 | ||
438 | #if !defined(BOOST_COMPUTE_NO_HDR_CHRONO) || !defined(BOOST_COMPUTE_NO_BOOST_CHRONO) | |
439 | /// Returns the current value of the host clock as seen by device | |
440 | /// as duration. | |
441 | /// | |
442 | /// For example, to print the current value of the host clock as seen by device | |
443 | /// in milliseconds: | |
444 | /// \code | |
445 | /// std::cout << device.get_host_timer<std::chrono::milliseconds>().count() << " ms"; | |
446 | /// \endcode | |
447 | /// | |
448 | /// \see_opencl21_ref{clGetHostTimer} | |
449 | /// | |
450 | /// \opencl_version_warning{2,1} | |
451 | template<class Duration> | |
452 | Duration get_host_timer() const | |
453 | { | |
454 | const ulong_ nanoseconds = this->get_host_timer(); | |
455 | return detail::make_duration_from_nanoseconds(Duration(), nanoseconds); | |
456 | } | |
457 | ||
458 | /// Returns a reasonably synchronized pair of timestamps from the device timer | |
459 | /// and the host timer as seen by device as a std::pair<Duration, Duration> value. | |
460 | /// The first of returned std::pair is a device timer timestamp, the second is | |
461 | /// a host timer timestamp. | |
462 | /// | |
463 | /// \see_opencl21_ref{clGetDeviceAndHostTimer} | |
464 | /// | |
465 | /// \opencl_version_warning{2,1} | |
466 | template<class Duration> | |
467 | std::pair<Duration, Duration> get_device_and_host_timer() const | |
468 | { | |
469 | const std::pair<ulong_, ulong_> timestamps = this->get_device_and_host_timer(); | |
470 | return std::make_pair( | |
471 | detail::make_duration_from_nanoseconds(Duration(), timestamps.first), | |
472 | detail::make_duration_from_nanoseconds(Duration(), timestamps.second) | |
473 | ); | |
474 | } | |
475 | #endif // !defined(BOOST_COMPUTE_NO_HDR_CHRONO) || !defined(BOOST_COMPUTE_NO_BOOST_CHRONO) | |
476 | #endif // BOOST_COMPUTE_CL_VERSION_2_1 | |
7c673cae FG |
477 | |
478 | /// Returns \c true if the device is the same at \p other. | |
479 | bool operator==(const device &other) const | |
480 | { | |
481 | return m_id == other.m_id; | |
482 | } | |
483 | ||
484 | /// Returns \c true if the device is different from \p other. | |
485 | bool operator!=(const device &other) const | |
486 | { | |
487 | return m_id != other.m_id; | |
488 | } | |
489 | ||
b32b8144 FG |
490 | /// Returns \c true if the device OpenCL version is major.minor |
491 | /// or newer; otherwise returns \c false. | |
7c673cae FG |
492 | bool check_version(int major, int minor) const |
493 | { | |
494 | std::stringstream stream; | |
495 | stream << version(); | |
496 | ||
497 | int actual_major, actual_minor; | |
498 | stream.ignore(7); // 'OpenCL ' | |
499 | stream >> actual_major; | |
500 | stream.ignore(1); // '.' | |
501 | stream >> actual_minor; | |
502 | ||
503 | return actual_major > major || | |
504 | (actual_major == major && actual_minor >= minor); | |
505 | } | |
506 | ||
507 | private: | |
508 | cl_device_id m_id; | |
509 | }; | |
510 | ||
511 | /// \internal_ | |
512 | template<> | |
513 | inline uint_ device::preferred_vector_width<short_>() const | |
514 | { | |
515 | return get_info<uint_>(CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT); | |
516 | } | |
517 | ||
518 | /// \internal_ | |
519 | template<> | |
520 | inline uint_ device::preferred_vector_width<int_>() const | |
521 | { | |
522 | return get_info<uint_>(CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT); | |
523 | } | |
524 | ||
525 | /// \internal_ | |
526 | template<> | |
527 | inline uint_ device::preferred_vector_width<long_>() const | |
528 | { | |
529 | return get_info<uint_>(CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG); | |
530 | } | |
531 | ||
532 | /// \internal_ | |
533 | template<> | |
534 | inline uint_ device::preferred_vector_width<float_>() const | |
535 | { | |
536 | return get_info<uint_>(CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT); | |
537 | } | |
538 | ||
539 | /// \internal_ | |
540 | template<> | |
541 | inline uint_ device::preferred_vector_width<double_>() const | |
542 | { | |
543 | return get_info<uint_>(CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE); | |
544 | } | |
545 | ||
546 | /// \internal_ define get_info() specializations for device | |
547 | BOOST_COMPUTE_DETAIL_DEFINE_GET_INFO_SPECIALIZATIONS(device, | |
548 | ((cl_uint, CL_DEVICE_ADDRESS_BITS)) | |
549 | ((bool, CL_DEVICE_AVAILABLE)) | |
550 | ((bool, CL_DEVICE_COMPILER_AVAILABLE)) | |
551 | ((bool, CL_DEVICE_ENDIAN_LITTLE)) | |
552 | ((bool, CL_DEVICE_ERROR_CORRECTION_SUPPORT)) | |
553 | ((cl_device_exec_capabilities, CL_DEVICE_EXECUTION_CAPABILITIES)) | |
554 | ((std::string, CL_DEVICE_EXTENSIONS)) | |
555 | ((cl_ulong, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE)) | |
556 | ((cl_device_mem_cache_type, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE)) | |
557 | ((cl_ulong, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE)) | |
558 | ((cl_ulong, CL_DEVICE_GLOBAL_MEM_SIZE)) | |
559 | ((bool, CL_DEVICE_IMAGE_SUPPORT)) | |
560 | ((size_t, CL_DEVICE_IMAGE2D_MAX_HEIGHT)) | |
561 | ((size_t, CL_DEVICE_IMAGE2D_MAX_WIDTH)) | |
562 | ((size_t, CL_DEVICE_IMAGE3D_MAX_DEPTH)) | |
563 | ((size_t, CL_DEVICE_IMAGE3D_MAX_HEIGHT)) | |
564 | ((size_t, CL_DEVICE_IMAGE3D_MAX_WIDTH)) | |
565 | ((cl_ulong, CL_DEVICE_LOCAL_MEM_SIZE)) | |
566 | ((cl_device_local_mem_type, CL_DEVICE_LOCAL_MEM_TYPE)) | |
567 | ((cl_uint, CL_DEVICE_MAX_CLOCK_FREQUENCY)) | |
568 | ((cl_uint, CL_DEVICE_MAX_COMPUTE_UNITS)) | |
569 | ((cl_uint, CL_DEVICE_MAX_CONSTANT_ARGS)) | |
570 | ((cl_ulong, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE)) | |
571 | ((cl_ulong, CL_DEVICE_MAX_MEM_ALLOC_SIZE)) | |
572 | ((size_t, CL_DEVICE_MAX_PARAMETER_SIZE)) | |
573 | ((cl_uint, CL_DEVICE_MAX_READ_IMAGE_ARGS)) | |
574 | ((cl_uint, CL_DEVICE_MAX_SAMPLERS)) | |
575 | ((size_t, CL_DEVICE_MAX_WORK_GROUP_SIZE)) | |
576 | ((cl_uint, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS)) | |
577 | ((std::vector<size_t>, CL_DEVICE_MAX_WORK_ITEM_SIZES)) | |
578 | ((cl_uint, CL_DEVICE_MAX_WRITE_IMAGE_ARGS)) | |
579 | ((cl_uint, CL_DEVICE_MEM_BASE_ADDR_ALIGN)) | |
580 | ((cl_uint, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE)) | |
581 | ((std::string, CL_DEVICE_NAME)) | |
582 | ((cl_platform_id, CL_DEVICE_PLATFORM)) | |
583 | ((cl_uint, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR)) | |
584 | ((cl_uint, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT)) | |
585 | ((cl_uint, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT)) | |
586 | ((cl_uint, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG)) | |
587 | ((cl_uint, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT)) | |
588 | ((cl_uint, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE)) | |
589 | ((std::string, CL_DEVICE_PROFILE)) | |
590 | ((size_t, CL_DEVICE_PROFILING_TIMER_RESOLUTION)) | |
591 | ((cl_command_queue_properties, CL_DEVICE_QUEUE_PROPERTIES)) | |
592 | ((cl_device_fp_config, CL_DEVICE_SINGLE_FP_CONFIG)) | |
593 | ((cl_device_type, CL_DEVICE_TYPE)) | |
594 | ((std::string, CL_DEVICE_VENDOR)) | |
595 | ((cl_uint, CL_DEVICE_VENDOR_ID)) | |
596 | ((std::string, CL_DEVICE_VERSION)) | |
597 | ((std::string, CL_DRIVER_VERSION)) | |
598 | ) | |
599 | ||
600 | #ifdef CL_DEVICE_DOUBLE_FP_CONFIG | |
601 | BOOST_COMPUTE_DETAIL_DEFINE_GET_INFO_SPECIALIZATIONS(device, | |
602 | ((cl_device_fp_config, CL_DEVICE_DOUBLE_FP_CONFIG)) | |
603 | ) | |
604 | #endif | |
605 | ||
606 | #ifdef CL_DEVICE_HALF_FP_CONFIG | |
607 | BOOST_COMPUTE_DETAIL_DEFINE_GET_INFO_SPECIALIZATIONS(device, | |
608 | ((cl_device_fp_config, CL_DEVICE_HALF_FP_CONFIG)) | |
609 | ) | |
610 | #endif | |
611 | ||
b32b8144 | 612 | #ifdef BOOST_COMPUTE_CL_VERSION_1_1 |
7c673cae FG |
613 | BOOST_COMPUTE_DETAIL_DEFINE_GET_INFO_SPECIALIZATIONS(device, |
614 | ((bool, CL_DEVICE_HOST_UNIFIED_MEMORY)) | |
615 | ((cl_uint, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR)) | |
616 | ((cl_uint, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT)) | |
617 | ((cl_uint, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT)) | |
618 | ((cl_uint, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG)) | |
619 | ((cl_uint, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT)) | |
620 | ((cl_uint, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE)) | |
621 | ((std::string, CL_DEVICE_OPENCL_C_VERSION)) | |
622 | ) | |
b32b8144 | 623 | #endif // BOOST_COMPUTE_CL_VERSION_1_1 |
7c673cae | 624 | |
b32b8144 | 625 | #ifdef BOOST_COMPUTE_CL_VERSION_1_2 |
7c673cae FG |
626 | BOOST_COMPUTE_DETAIL_DEFINE_GET_INFO_SPECIALIZATIONS(device, |
627 | ((std::string, CL_DEVICE_BUILT_IN_KERNELS)) | |
628 | ((bool, CL_DEVICE_LINKER_AVAILABLE)) | |
629 | ((cl_device_id, CL_DEVICE_PARENT_DEVICE)) | |
630 | ((cl_uint, CL_DEVICE_PARTITION_MAX_SUB_DEVICES)) | |
631 | ((cl_device_partition_property, CL_DEVICE_PARTITION_PROPERTIES)) | |
632 | ((cl_device_affinity_domain, CL_DEVICE_PARTITION_AFFINITY_DOMAIN)) | |
633 | ((cl_device_partition_property, CL_DEVICE_PARTITION_TYPE)) | |
634 | ((size_t, CL_DEVICE_PRINTF_BUFFER_SIZE)) | |
635 | ((bool, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC)) | |
636 | ((cl_uint, CL_DEVICE_REFERENCE_COUNT)) | |
637 | ) | |
b32b8144 | 638 | #endif // BOOST_COMPUTE_CL_VERSION_1_2 |
7c673cae | 639 | |
b32b8144 | 640 | #ifdef BOOST_COMPUTE_CL_VERSION_2_0 |
7c673cae FG |
641 | BOOST_COMPUTE_DETAIL_DEFINE_GET_INFO_SPECIALIZATIONS(device, |
642 | ((size_t, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE)) | |
643 | ((size_t, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE)) | |
644 | ((cl_uint, CL_DEVICE_MAX_ON_DEVICE_EVENTS)) | |
645 | ((cl_uint, CL_DEVICE_MAX_ON_DEVICE_QUEUES)) | |
646 | ((cl_uint, CL_DEVICE_MAX_PIPE_ARGS)) | |
647 | ((cl_uint, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS)) | |
648 | ((cl_uint, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS)) | |
649 | ((cl_uint, CL_DEVICE_PIPE_MAX_PACKET_SIZE)) | |
650 | ((cl_uint, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT)) | |
651 | ((cl_uint, CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT)) | |
652 | ((cl_uint, CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT)) | |
653 | ((cl_uint, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE)) | |
654 | ((cl_uint, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE)) | |
655 | ((cl_command_queue_properties, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES)) | |
656 | ((cl_device_svm_capabilities, CL_DEVICE_SVM_CAPABILITIES)) | |
657 | ((cl_uint, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT)) | |
658 | ((cl_uint, CL_DEVICE_IMAGE_PITCH_ALIGNMENT)) | |
659 | ) | |
b32b8144 FG |
660 | #endif // BOOST_COMPUTE_CL_VERSION_2_0 |
661 | ||
662 | #ifdef BOOST_COMPUTE_CL_VERSION_2_1 | |
663 | BOOST_COMPUTE_DETAIL_DEFINE_GET_INFO_SPECIALIZATIONS(device, | |
664 | ((std::string, CL_DEVICE_IL_VERSION)) | |
665 | ((cl_uint, CL_DEVICE_MAX_NUM_SUB_GROUPS)) | |
666 | ((bool, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS)) | |
667 | ) | |
668 | #endif // BOOST_COMPUTE_CL_VERSION_2_1 | |
7c673cae FG |
669 | |
670 | } // end compute namespace | |
671 | } // end boost namespace | |
672 | ||
673 | #endif // BOOST_COMPUTE_DEVICE_HPP |