device.hpp 21 KB

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