1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
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
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_TEST_QUIRKS_HPP
12 #define BOOST_COMPUTE_TEST_QUIRKS_HPP
14 #include <boost/compute/device.hpp>
15 #include <boost/compute/platform.hpp>
16 #include <boost/compute/detail/vendor.hpp>
18 // this file contains functions which check for 'quirks' or buggy
19 // behavior in OpenCL implementations. this allows us to skip certain
20 // tests when running on buggy platforms.
22 // returns true if the device is a POCL device
23 inline bool is_pocl_device(const boost::compute::device &device)
25 return device.platform().name() == "Portable Computing Language";
28 // returns true if the device is from Apple OpenCL platform
29 inline bool is_apple_device(const boost::compute::device &device)
31 return device.platform().name() == "Apple";
34 // AMD platforms have a bug when using struct assignment. this affects
35 // algorithms like fill() when used with pairs/tuples.
37 // see: https://community.amd.com/thread/166622
38 inline bool bug_in_struct_assignment(const boost::compute::device &device)
40 return boost::compute::detail::is_amd_device(device);
43 // clEnqueueSVMMemcpy() operation does not work on AMD devices. This affects
44 // copy() algorithm. This bug was fixed in AMD drivers for Windows.
46 // see: https://community.amd.com/thread/190585
47 inline bool bug_in_svmmemcpy(const boost::compute::device &device)
52 return boost::compute::detail::is_amd_device(device);
56 // For CPU devices on Apple platform local memory can not be used when work
57 // group size is not [1;1;1]. If work group size is greater "Invalid Work Group
58 // Size" error is thrown. (Apple OpenCL implementation can sometimes reduce
59 // max work group size for other reasons.)
60 // When local memory is not used max work group size for CPU devices on Apple
61 // platform should be [1024;1;1].
62 inline bool is_apple_cpu_device(const boost::compute::device &device)
64 return is_apple_device(device) && (device.type() & ::boost::compute::device::cpu);
67 // On Apple devices clCreateBuffer does not return NULL and does no set error
68 // to CL_INVALID_BUFFER_SIZE when size of the buffer memory object is greater
69 // than CL_DEVICE_MAX_MEM_ALLOC_SIZE.
70 inline bool bug_in_clcreatebuffer(const boost::compute::device &device)
72 return is_apple_device(device);
75 // returns true if the device supports image samplers.
76 inline bool supports_image_samplers(const boost::compute::device &device)
78 // POCL does not yet support image samplers and gives the following
79 // error when attempting to create one:
81 // pocl error: encountered unimplemented part of the OpenCL specs
82 // in clCreateSampler.c:28
83 if(is_pocl_device(device)){
90 // returns true if the device has remquo() built-in OpenCL function implementation
91 inline bool has_remquo_func(const boost::compute::device &device)
93 // POCL does not have it
94 if(is_pocl_device(device)){
100 // returns true if the device supports clSetMemObjectDestructorCallback
101 inline bool supports_destructor_callback(const boost::compute::device &device)
103 // unimplemented in POCL
104 return !is_pocl_device(device);
107 // returns true if the device supports clCompileProgram
108 inline bool supports_compile_program(const boost::compute::device &device)
110 // unimplemented in POCL
111 return !is_pocl_device(device);
114 // returns true if the device supports clLinkProgram
115 inline bool supports_link_program(const boost::compute::device &device)
117 // unimplemented in POCL
118 return !is_pocl_device(device);
121 // See https://github.com/pocl/pocl/issues/577, POCL fails when a program
122 // with incorrect code is built for the 2nd time
123 inline bool pocl_bug_issue_577(const boost::compute::device &device)
125 return is_pocl_device(device);
128 #endif // BOOST_COMPUTE_TEST_QUIRKS_HPP