quirks.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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_TEST_QUIRKS_HPP
  11. #define BOOST_COMPUTE_TEST_QUIRKS_HPP
  12. #include <boost/compute/device.hpp>
  13. #include <boost/compute/platform.hpp>
  14. #include <boost/compute/detail/vendor.hpp>
  15. // this file contains functions which check for 'quirks' or buggy
  16. // behavior in OpenCL implementations. this allows us to skip certain
  17. // tests when running on buggy platforms.
  18. // returns true if the device is a POCL device
  19. inline bool is_pocl_device(const boost::compute::device &device)
  20. {
  21. return device.platform().name() == "Portable Computing Language";
  22. }
  23. // returns true if the device is from Apple OpenCL platform
  24. inline bool is_apple_device(const boost::compute::device &device)
  25. {
  26. return device.platform().name() == "Apple";
  27. }
  28. // AMD platforms have a bug when using struct assignment. this affects
  29. // algorithms like fill() when used with pairs/tuples.
  30. //
  31. // see: https://community.amd.com/thread/166622
  32. inline bool bug_in_struct_assignment(const boost::compute::device &device)
  33. {
  34. return boost::compute::detail::is_amd_device(device);
  35. }
  36. // clEnqueueSVMMemcpy() operation does not work on AMD devices. This affects
  37. // copy() algorithm. This bug was fixed in AMD drivers for Windows.
  38. //
  39. // see: https://community.amd.com/thread/190585
  40. inline bool bug_in_svmmemcpy(const boost::compute::device &device)
  41. {
  42. #ifdef _WIN32
  43. return false;
  44. #else
  45. return boost::compute::detail::is_amd_device(device);
  46. #endif
  47. }
  48. // For CPU devices on Apple platform local memory can not be used when work
  49. // group size is not [1;1;1]. If work group size is greater "Invalid Work Group
  50. // Size" error is thrown. (Apple OpenCL implementation can sometimes reduce
  51. // max work group size for other reasons.)
  52. // When local memory is not used max work group size for CPU devices on Apple
  53. // platform should be [1024;1;1].
  54. inline bool is_apple_cpu_device(const boost::compute::device &device)
  55. {
  56. return is_apple_device(device) && (device.type() & ::boost::compute::device::cpu);
  57. }
  58. // On Apple devices clCreateBuffer does not return NULL and does no set error
  59. // to CL_INVALID_BUFFER_SIZE when size of the buffer memory object is greater
  60. // than CL_DEVICE_MAX_MEM_ALLOC_SIZE.
  61. inline bool bug_in_clcreatebuffer(const boost::compute::device &device)
  62. {
  63. return is_apple_device(device);
  64. }
  65. // returns true if the device supports image samplers.
  66. inline bool supports_image_samplers(const boost::compute::device &device)
  67. {
  68. // POCL does not yet support image samplers and gives the following
  69. // error when attempting to create one:
  70. //
  71. // pocl error: encountered unimplemented part of the OpenCL specs
  72. // in clCreateSampler.c:28
  73. if(is_pocl_device(device)){
  74. return false;
  75. }
  76. return true;
  77. }
  78. // returns true if the device has remquo() built-in OpenCL function implementation
  79. inline bool has_remquo_func(const boost::compute::device &device)
  80. {
  81. // POCL does not have it
  82. if(is_pocl_device(device)){
  83. return false;
  84. }
  85. return true;
  86. }
  87. // returns true if the device supports clSetMemObjectDestructorCallback
  88. inline bool supports_destructor_callback(const boost::compute::device &device)
  89. {
  90. // unimplemented in POCL
  91. return !is_pocl_device(device);
  92. }
  93. // returns true if the device supports clCompileProgram
  94. inline bool supports_compile_program(const boost::compute::device &device)
  95. {
  96. // unimplemented in POCL
  97. return !is_pocl_device(device);
  98. }
  99. // returns true if the device supports clLinkProgram
  100. inline bool supports_link_program(const boost::compute::device &device)
  101. {
  102. // unimplemented in POCL
  103. return !is_pocl_device(device);
  104. }
  105. // See https://github.com/pocl/pocl/issues/577, POCL fails when a program
  106. // with incorrect code is built for the 2nd time
  107. inline bool pocl_bug_issue_577(const boost::compute::device &device)
  108. {
  109. return is_pocl_device(device);
  110. }
  111. #endif // BOOST_COMPUTE_TEST_QUIRKS_HPP