Blame view

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