东方耀AI技术分享

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 1448|回复: 2
打印 上一主题 下一主题

[C/C++] Boost.Compute :用于OpenCL的C++ GPU计算库

[复制链接]

1365

主题

1856

帖子

1万

积分

管理员

Rank: 10Rank: 10Rank: 10

积分
14451
QQ
跳转到指定楼层
楼主
发表于 2021-7-28 14:43:49 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
Boost.Compute :用于OpenCL的C++ GPU计算库




Found Boost: /usr/include (found version "1.65.1")自带的Compute报错:


/usr/include/boost/compute/memory/svm_ptr.hpp:131:16: error: binding reference of type ‘boost::compute::context&’ to ‘const boost::compute::context’ discards qualifiers
         return m_context;


第三方:https://github.com/boostorg/compute


The full documentation is available at http://boostorg.github.io/compute/




源码编译安装:
基于以下:
-- Found OpenCL: /usr/lib/x86_64-linux-gnu/libOpenCL.so (found version "2.2")
-- Found Boost: /usr/include (found suitable version "1.65.1", minimum required is "1.54")  


mkdir build
cd build
cmake ..
make
sudo make install
  1. jiang@jiang-Ubuntu:~/jjj_opencl_works/compute-master/build$ sudo make install
  2. [sudo] jiang 的密码:
  3. Install the project...
  4. -- Install configuration: ""
  5. -- Installing: /usr/local/lib/cmake/BoostCompute/BoostComputeConfig.cmake
  6. -- Installing: /usr/local/include/compute/boost
  7. -- Installing: /usr/local/include/compute/boost/compute.hpp
  8. -- Installing: /usr/local/include/compute/boost/compute
  9. -- Installing: /usr/local/include/compute/boost/compute/program.hpp
  10. -- Installing: /usr/local/include/compute/boost/compute/wait_list.hpp
  11. -- Installing: /usr/local/include/compute/boost/compute/command_queue.hpp
  12. -- Installing: /usr/local/include/compute/boost/compute/iterator.hpp
  13. -- Installing: /usr/local/include/compute/boost/compute/lambda.hpp
  14. -- Installing: /usr/local/include/compute/boost/compute/iterator
  15. -- Installing: /usr/local/include/compute/boost/compute/iterator/function_input_iterator.hpp
  16. -- Installing: /usr/local/include/compute/boost/compute/iterator/counting_iterator.hpp
  17. -- Installing: /usr/local/include/compute/boost/compute/iterator/strided_iterator.hpp
  18. -- Installing: /usr/local/include/compute/boost/compute/iterator/zip_iterator.hpp
  19. -- Installing: /usr/local/include/compute/boost/compute/iterator/buffer_iterator.hpp
  20. -- Installing: /usr/local/include/compute/boost/compute/iterator/discard_iterator.hpp
  21. -- Installing: /usr/local/include/compute/boost/compute/iterator/permutation_iterator.hpp
  22. -- Installing: /usr/local/include/compute/boost/compute/iterator/constant_iterator.hpp
  23. -- Installing: /usr/local/include/compute/boost/compute/iterator/detail
  24. -- Installing: /usr/local/include/compute/boost/compute/iterator/detail/get_base_iterator_buffer.hpp
  25. -- Installing: /usr/local/include/compute/boost/compute/iterator/detail/swizzle_iterator.hpp
  26. -- Installing: /usr/local/include/compute/boost/compute/iterator/constant_buffer_iterator.hpp
  27. -- Installing: /usr/local/include/compute/boost/compute/iterator/transform_iterator.hpp
  28. -- Installing: /usr/local/include/compute/boost/compute/cl_ext.hpp
  29. -- Installing: /usr/local/include/compute/boost/compute/buffer.hpp
  30. -- Installing: /usr/local/include/compute/boost/compute/image3d.hpp
  31. -- Installing: /usr/local/include/compute/boost/compute/functional
  32. -- Installing: /usr/local/include/compute/boost/compute/functional/operator.hpp
  33. -- Installing: /usr/local/include/compute/boost/compute/functional/convert.hpp
  34. -- Installing: /usr/local/include/compute/boost/compute/functional/relational.hpp
  35. -- Installing: /usr/local/include/compute/boost/compute/functional/atomic.hpp
  36. -- Installing: /usr/local/include/compute/boost/compute/functional/field.hpp
  37. -- Installing: /usr/local/include/compute/boost/compute/functional/math.hpp
  38. -- Installing: /usr/local/include/compute/boost/compute/functional/logical.hpp
  39. -- Installing: /usr/local/include/compute/boost/compute/functional/identity.hpp
  40. -- Installing: /usr/local/include/compute/boost/compute/functional/hash.hpp
  41. -- Installing: /usr/local/include/compute/boost/compute/functional/bind.hpp
  42. -- Installing: /usr/local/include/compute/boost/compute/functional/common.hpp
  43. -- Installing: /usr/local/include/compute/boost/compute/functional/geometry.hpp
  44. -- Installing: /usr/local/include/compute/boost/compute/functional/detail
  45. -- Installing: /usr/local/include/compute/boost/compute/functional/detail/nvidia_ballot.hpp
  46. -- Installing: /usr/local/include/compute/boost/compute/functional/detail/unpack.hpp
  47. -- Installing: /usr/local/include/compute/boost/compute/functional/detail/macros.hpp
  48. -- Installing: /usr/local/include/compute/boost/compute/functional/detail/nvidia_popcount.hpp
  49. -- Installing: /usr/local/include/compute/boost/compute/functional/get.hpp
  50. -- Installing: /usr/local/include/compute/boost/compute/functional/as.hpp
  51. -- Installing: /usr/local/include/compute/boost/compute/functional/integer.hpp
  52. -- Installing: /usr/local/include/compute/boost/compute/functional/popcount.hpp
  53. -- Installing: /usr/local/include/compute/boost/compute/kernel.hpp
  54. -- Installing: /usr/local/include/compute/boost/compute/async.hpp
  55. -- Installing: /usr/local/include/compute/boost/compute/types.hpp
  56. -- Installing: /usr/local/include/compute/boost/compute/image
  57. -- Installing: /usr/local/include/compute/boost/compute/image/image3d.hpp
  58. -- Installing: /usr/local/include/compute/boost/compute/image/image_object.hpp
  59. -- Installing: /usr/local/include/compute/boost/compute/image/image2d.hpp
  60. -- Installing: /usr/local/include/compute/boost/compute/image/image_sampler.hpp
  61. -- Installing: /usr/local/include/compute/boost/compute/image/image_format.hpp
  62. -- Installing: /usr/local/include/compute/boost/compute/image/image1d.hpp
  63. -- Installing: /usr/local/include/compute/boost/compute/functional.hpp
  64. -- Installing: /usr/local/include/compute/boost/compute/source.hpp
  65. -- Installing: /usr/local/include/compute/boost/compute/function.hpp
  66. -- Installing: /usr/local/include/compute/boost/compute/closure.hpp
  67. -- Installing: /usr/local/include/compute/boost/compute/utility
  68. -- Installing: /usr/local/include/compute/boost/compute/utility/wait_list.hpp
  69. -- Installing: /usr/local/include/compute/boost/compute/utility/program_cache.hpp
  70. -- Installing: /usr/local/include/compute/boost/compute/utility/invoke.hpp
  71. -- Installing: /usr/local/include/compute/boost/compute/utility/source.hpp
  72. -- Installing: /usr/local/include/compute/boost/compute/utility/extents.hpp
  73. -- Installing: /usr/local/include/compute/boost/compute/utility/dim.hpp
  74. -- Installing: /usr/local/include/compute/boost/compute/memory.hpp
  75. -- Installing: /usr/local/include/compute/boost/compute/algorithm.hpp
  76. -- Installing: /usr/local/include/compute/boost/compute/user_event.hpp
  77. -- Installing: /usr/local/include/compute/boost/compute/version.hpp
  78. -- Installing: /usr/local/include/compute/boost/compute/interop
  79. -- Installing: /usr/local/include/compute/boost/compute/interop/qt.hpp
  80. -- Installing: /usr/local/include/compute/boost/compute/interop/vtk.hpp
  81. -- Installing: /usr/local/include/compute/boost/compute/interop/eigen
  82. -- Installing: /usr/local/include/compute/boost/compute/interop/eigen/core.hpp
  83. -- Installing: /usr/local/include/compute/boost/compute/interop/qt
  84. -- Installing: /usr/local/include/compute/boost/compute/interop/qt/qpoint.hpp
  85. -- Installing: /usr/local/include/compute/boost/compute/interop/qt/qtcore.hpp
  86. -- Installing: /usr/local/include/compute/boost/compute/interop/qt/qvector.hpp
  87. -- Installing: /usr/local/include/compute/boost/compute/interop/qt/qtgui.hpp
  88. -- Installing: /usr/local/include/compute/boost/compute/interop/qt/qimage.hpp
  89. -- Installing: /usr/local/include/compute/boost/compute/interop/qt/qpointf.hpp
  90. -- Installing: /usr/local/include/compute/boost/compute/interop/opencv.hpp
  91. -- Installing: /usr/local/include/compute/boost/compute/interop/eigen.hpp
  92. -- Installing: /usr/local/include/compute/boost/compute/interop/opengl.hpp
  93. -- Installing: /usr/local/include/compute/boost/compute/interop/opencv
  94. -- Installing: /usr/local/include/compute/boost/compute/interop/opencv/highgui.hpp
  95. -- Installing: /usr/local/include/compute/boost/compute/interop/opencv/core.hpp
  96. -- Installing: /usr/local/include/compute/boost/compute/interop/opencv/ocl.hpp
  97. -- Installing: /usr/local/include/compute/boost/compute/interop/vtk
  98. -- Installing: /usr/local/include/compute/boost/compute/interop/vtk/matrix4x4.hpp
  99. -- Installing: /usr/local/include/compute/boost/compute/interop/vtk/data_array.hpp
  100. -- Installing: /usr/local/include/compute/boost/compute/interop/vtk/bounds.hpp
  101. -- Installing: /usr/local/include/compute/boost/compute/interop/vtk/points.hpp
  102. -- Installing: /usr/local/include/compute/boost/compute/interop/opengl
  103. -- Installing: /usr/local/include/compute/boost/compute/interop/opengl/acquire.hpp
  104. -- Installing: /usr/local/include/compute/boost/compute/interop/opengl/gl.hpp
  105. -- Installing: /usr/local/include/compute/boost/compute/interop/opengl/cl_gl.hpp
  106. -- Installing: /usr/local/include/compute/boost/compute/interop/opengl/cl_gl_ext.hpp
  107. -- Installing: /usr/local/include/compute/boost/compute/interop/opengl/opengl_buffer.hpp
  108. -- Installing: /usr/local/include/compute/boost/compute/interop/opengl/context.hpp
  109. -- Installing: /usr/local/include/compute/boost/compute/interop/opengl/opengl_renderbuffer.hpp
  110. -- Installing: /usr/local/include/compute/boost/compute/interop/opengl/opengl_texture.hpp
  111. -- Installing: /usr/local/include/compute/boost/compute/exception
  112. -- Installing: /usr/local/include/compute/boost/compute/exception/program_build_failure.hpp
  113. -- Installing: /usr/local/include/compute/boost/compute/exception/no_device_found.hpp
  114. -- Installing: /usr/local/include/compute/boost/compute/exception/context_error.hpp
  115. -- Installing: /usr/local/include/compute/boost/compute/exception/unsupported_extension_error.hpp
  116. -- Installing: /usr/local/include/compute/boost/compute/exception/opencl_error.hpp
  117. -- Installing: /usr/local/include/compute/boost/compute/core.hpp
  118. -- Installing: /usr/local/include/compute/boost/compute/exception.hpp
  119. -- Installing: /usr/local/include/compute/boost/compute/image.hpp
  120. -- Installing: /usr/local/include/compute/boost/compute/algorithm
  121. -- Installing: /usr/local/include/compute/boost/compute/algorithm/min_element.hpp
  122. -- Installing: /usr/local/include/compute/boost/compute/algorithm/stable_partition.hpp
  123. -- Installing: /usr/local/include/compute/boost/compute/algorithm/swap_ranges.hpp
  124. -- Installing: /usr/local/include/compute/boost/compute/algorithm/merge.hpp
  125. -- Installing: /usr/local/include/compute/boost/compute/algorithm/copy_n.hpp
  126. -- Installing: /usr/local/include/compute/boost/compute/algorithm/none_of.hpp
  127. -- Installing: /usr/local/include/compute/boost/compute/algorithm/remove_if.hpp
  128. -- Installing: /usr/local/include/compute/boost/compute/algorithm/stable_sort_by_key.hpp
  129. -- Installing: /usr/local/include/compute/boost/compute/algorithm/reverse.hpp
  130. -- Installing: /usr/local/include/compute/boost/compute/algorithm/count.hpp
  131. -- Installing: /usr/local/include/compute/boost/compute/algorithm/adjacent_difference.hpp
  132. -- Installing: /usr/local/include/compute/boost/compute/algorithm/adjacent_find.hpp
  133. -- Installing: /usr/local/include/compute/boost/compute/algorithm/transform.hpp
  134. -- Installing: /usr/local/include/compute/boost/compute/algorithm/replace.hpp
  135. -- Installing: /usr/local/include/compute/boost/compute/algorithm/copy_if.hpp
  136. -- Installing: /usr/local/include/compute/boost/compute/algorithm/max_element.hpp
  137. -- Installing: /usr/local/include/compute/boost/compute/algorithm/all_of.hpp
  138. -- Installing: /usr/local/include/compute/boost/compute/algorithm/search_n.hpp
  139. -- Installing: /usr/local/include/compute/boost/compute/algorithm/next_permutation.hpp
  140. -- Installing: /usr/local/include/compute/boost/compute/algorithm/reverse_copy.hpp
  141. -- Installing: /usr/local/include/compute/boost/compute/algorithm/scatter_if.hpp
  142. -- Installing: /usr/local/include/compute/boost/compute/algorithm/any_of.hpp
  143. -- Installing: /usr/local/include/compute/boost/compute/algorithm/reduce.hpp
  144. -- Installing: /usr/local/include/compute/boost/compute/algorithm/partial_sum.hpp
  145. -- Installing: /usr/local/include/compute/boost/compute/algorithm/unique.hpp
  146. -- Installing: /usr/local/include/compute/boost/compute/algorithm/for_each.hpp
  147. -- Installing: /usr/local/include/compute/boost/compute/algorithm/accumulate.hpp
  148. -- Installing: /usr/local/include/compute/boost/compute/algorithm/equal_range.hpp
  149. -- Installing: /usr/local/include/compute/boost/compute/algorithm/iota.hpp
  150. -- Installing: /usr/local/include/compute/boost/compute/algorithm/for_each_n.hpp
  151. -- Installing: /usr/local/include/compute/boost/compute/algorithm/fill.hpp
  152. -- Installing: /usr/local/include/compute/boost/compute/algorithm/generate_n.hpp
  153. -- Installing: /usr/local/include/compute/boost/compute/algorithm/remove.hpp
  154. -- Installing: /usr/local/include/compute/boost/compute/algorithm/nth_element.hpp
  155. -- Installing: /usr/local/include/compute/boost/compute/algorithm/set_difference.hpp
  156. -- Installing: /usr/local/include/compute/boost/compute/algorithm/fill_n.hpp
  157. -- Installing: /usr/local/include/compute/boost/compute/algorithm/mismatch.hpp
  158. -- Installing: /usr/local/include/compute/boost/compute/algorithm/set_symmetric_difference.hpp
  159. -- Installing: /usr/local/include/compute/boost/compute/algorithm/upper_bound.hpp
  160. -- Installing: /usr/local/include/compute/boost/compute/algorithm/count_if.hpp
  161. -- Installing: /usr/local/include/compute/boost/compute/algorithm/sort_by_key.hpp
  162. -- Installing: /usr/local/include/compute/boost/compute/algorithm/equal.hpp
  163. -- Installing: /usr/local/include/compute/boost/compute/algorithm/is_permutation.hpp
  164. -- Installing: /usr/local/include/compute/boost/compute/algorithm/rotate_copy.hpp
  165. -- Installing: /usr/local/include/compute/boost/compute/algorithm/partition.hpp
  166. -- Installing: /usr/local/include/compute/boost/compute/algorithm/set_intersection.hpp
  167. -- Installing: /usr/local/include/compute/boost/compute/algorithm/rotate.hpp
  168. -- Installing: /usr/local/include/compute/boost/compute/algorithm/is_partitioned.hpp
  169. -- Installing: /usr/local/include/compute/boost/compute/algorithm/find_if.hpp
  170. -- Installing: /usr/local/include/compute/boost/compute/algorithm/replace_copy.hpp
  171. -- Installing: /usr/local/include/compute/boost/compute/algorithm/inner_product.hpp
  172. -- Installing: /usr/local/include/compute/boost/compute/algorithm/exclusive_scan.hpp
  173. -- Installing: /usr/local/include/compute/boost/compute/algorithm/is_sorted.hpp
  174. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail
  175. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/serial_merge.hpp
  176. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/random_fill.hpp
  177. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/compact.hpp
  178. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/merge_sort_on_gpu.hpp
  179. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/serial_scan.hpp
  180. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/find_extrema.hpp
  181. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/count_if_with_ballot.hpp
  182. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/balanced_path.hpp
  183. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/find_extrema_on_cpu.hpp
  184. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/reduce_on_gpu.hpp
  185. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/copy_to_device.hpp
  186. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/count_if_with_reduce.hpp
  187. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/copy_to_host.hpp
  188. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/find_if_with_atomics.hpp
  189. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/merge_sort_on_cpu.hpp
  190. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/radix_sort.hpp
  191. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/find_extrema_with_reduce.hpp
  192. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/scan_on_gpu.hpp
  193. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/serial_reduce.hpp
  194. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/scan.hpp
  195. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/merge_path.hpp
  196. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/reduce_by_key_with_scan.hpp
  197. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/find_extrema_with_atomics.hpp
  198. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/insertion_sort.hpp
  199. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/serial_find_extrema.hpp
  200. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/scan_on_cpu.hpp
  201. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/serial_count_if.hpp
  202. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/search_all.hpp
  203. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/serial_accumulate.hpp
  204. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/reduce_on_cpu.hpp
  205. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/inplace_reduce.hpp
  206. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/merge_with_merge_path.hpp
  207. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/reduce_by_key.hpp
  208. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/binary_find.hpp
  209. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/serial_reduce_by_key.hpp
  210. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/count_if_with_threads.hpp
  211. -- Installing: /usr/local/include/compute/boost/compute/algorithm/detail/copy_on_device.hpp
  212. -- Installing: /usr/local/include/compute/boost/compute/algorithm/find.hpp
  213. -- Installing: /usr/local/include/compute/boost/compute/algorithm/binary_search.hpp
  214. -- Installing: /usr/local/include/compute/boost/compute/algorithm/set_union.hpp
  215. -- Installing: /usr/local/include/compute/boost/compute/algorithm/sort.hpp
  216. -- Installing: /usr/local/include/compute/boost/compute/algorithm/inclusive_scan.hpp
  217. -- Installing: /usr/local/include/compute/boost/compute/algorithm/lexicographical_compare.hpp
  218. -- Installing: /usr/local/include/compute/boost/compute/algorithm/lower_bound.hpp
  219. -- Installing: /usr/local/include/compute/boost/compute/algorithm/inplace_merge.hpp
  220. -- Installing: /usr/local/include/compute/boost/compute/algorithm/partition_copy.hpp
  221. -- Installing: /usr/local/include/compute/boost/compute/algorithm/find_if_not.hpp
  222. -- Installing: /usr/local/include/compute/boost/compute/algorithm/includes.hpp
  223. -- Installing: /usr/local/include/compute/boost/compute/algorithm/generate.hpp
  224. -- Installing: /usr/local/include/compute/boost/compute/algorithm/reduce_by_key.hpp
  225. -- Installing: /usr/local/include/compute/boost/compute/algorithm/transform_if.hpp
  226. -- Installing: /usr/local/include/compute/boost/compute/algorithm/minmax_element.hpp
  227. -- Installing: /usr/local/include/compute/boost/compute/algorithm/prev_permutation.hpp
  228. -- Installing: /usr/local/include/compute/boost/compute/algorithm/partition_point.hpp
  229. -- Installing: /usr/local/include/compute/boost/compute/algorithm/transform_reduce.hpp
  230. -- Installing: /usr/local/include/compute/boost/compute/algorithm/copy.hpp
  231. -- Installing: /usr/local/include/compute/boost/compute/algorithm/random_shuffle.hpp
  232. -- Installing: /usr/local/include/compute/boost/compute/algorithm/scatter.hpp
  233. -- Installing: /usr/local/include/compute/boost/compute/algorithm/gather.hpp
  234. -- Installing: /usr/local/include/compute/boost/compute/algorithm/find_end.hpp
  235. -- Installing: /usr/local/include/compute/boost/compute/algorithm/unique_copy.hpp
  236. -- Installing: /usr/local/include/compute/boost/compute/algorithm/stable_sort.hpp
  237. -- Installing: /usr/local/include/compute/boost/compute/algorithm/search.hpp
  238. -- Installing: /usr/local/include/compute/boost/compute/image2d.hpp
  239. -- Installing: /usr/local/include/compute/boost/compute/image_sampler.hpp
  240. -- Installing: /usr/local/include/compute/boost/compute/random.hpp
  241. -- Installing: /usr/local/include/compute/boost/compute/type_traits.hpp
  242. -- Installing: /usr/local/include/compute/boost/compute/config.hpp
  243. -- Installing: /usr/local/include/compute/boost/compute/image_format.hpp
  244. -- Installing: /usr/local/include/compute/boost/compute/random
  245. -- Installing: /usr/local/include/compute/boost/compute/random/uniform_real_distribution.hpp
  246. -- Installing: /usr/local/include/compute/boost/compute/random/default_random_engine.hpp
  247. -- Installing: /usr/local/include/compute/boost/compute/random/discrete_distribution.hpp
  248. -- Installing: /usr/local/include/compute/boost/compute/random/normal_distribution.hpp
  249. -- Installing: /usr/local/include/compute/boost/compute/random/uniform_int_distribution.hpp
  250. -- Installing: /usr/local/include/compute/boost/compute/random/linear_congruential_engine.hpp
  251. -- Installing: /usr/local/include/compute/boost/compute/random/threefry_engine.hpp
  252. -- Installing: /usr/local/include/compute/boost/compute/random/bernoulli_distribution.hpp
  253. -- Installing: /usr/local/include/compute/boost/compute/random/mersenne_twister_engine.hpp
  254. -- Installing: /usr/local/include/compute/boost/compute/utility.hpp
  255. -- Installing: /usr/local/include/compute/boost/compute/types
  256. -- Installing: /usr/local/include/compute/boost/compute/types/builtin.hpp
  257. -- Installing: /usr/local/include/compute/boost/compute/types/fundamental.hpp
  258. -- Installing: /usr/local/include/compute/boost/compute/types/complex.hpp
  259. -- Installing: /usr/local/include/compute/boost/compute/types/struct.hpp
  260. -- Installing: /usr/local/include/compute/boost/compute/types/pair.hpp
  261. -- Installing: /usr/local/include/compute/boost/compute/types/size_t.hpp
  262. -- Installing: /usr/local/include/compute/boost/compute/types/tuple.hpp
  263. -- Installing: /usr/local/include/compute/boost/compute/cl.hpp
  264. -- Installing: /usr/local/include/compute/boost/compute/container
  265. -- Installing: /usr/local/include/compute/boost/compute/container/stack.hpp
  266. -- Installing: /usr/local/include/compute/boost/compute/container/array.hpp
  267. -- Installing: /usr/local/include/compute/boost/compute/container/string.hpp
  268. -- Installing: /usr/local/include/compute/boost/compute/container/dynamic_bitset.hpp
  269. -- Installing: /usr/local/include/compute/boost/compute/container/vector.hpp
  270. -- Installing: /usr/local/include/compute/boost/compute/container/basic_string.hpp
  271. -- Installing: /usr/local/include/compute/boost/compute/container/mapped_view.hpp
  272. -- Installing: /usr/local/include/compute/boost/compute/container/flat_map.hpp
  273. -- Installing: /usr/local/include/compute/boost/compute/container/flat_set.hpp
  274. -- Installing: /usr/local/include/compute/boost/compute/container/detail
  275. -- Installing: /usr/local/include/compute/boost/compute/container/detail/scalar.hpp
  276. -- Installing: /usr/local/include/compute/boost/compute/container/valarray.hpp
  277. -- Installing: /usr/local/include/compute/boost/compute/memory_object.hpp
  278. -- Installing: /usr/local/include/compute/boost/compute/allocator
  279. -- Installing: /usr/local/include/compute/boost/compute/allocator/buffer_allocator.hpp
  280. -- Installing: /usr/local/include/compute/boost/compute/allocator/pinned_allocator.hpp
  281. -- Installing: /usr/local/include/compute/boost/compute/type_traits
  282. -- Installing: /usr/local/include/compute/boost/compute/type_traits/type_name.hpp
  283. -- Installing: /usr/local/include/compute/boost/compute/type_traits/common_type.hpp
  284. -- Installing: /usr/local/include/compute/boost/compute/type_traits/is_vector_type.hpp
  285. -- Installing: /usr/local/include/compute/boost/compute/type_traits/is_device_iterator.hpp
  286. -- Installing: /usr/local/include/compute/boost/compute/type_traits/result_of.hpp
  287. -- Installing: /usr/local/include/compute/boost/compute/type_traits/vector_size.hpp
  288. -- Installing: /usr/local/include/compute/boost/compute/type_traits/scalar_type.hpp
  289. -- Installing: /usr/local/include/compute/boost/compute/type_traits/is_fundamental.hpp
  290. -- Installing: /usr/local/include/compute/boost/compute/type_traits/detail
  291. -- Installing: /usr/local/include/compute/boost/compute/type_traits/detail/capture_traits.hpp
  292. -- Installing: /usr/local/include/compute/boost/compute/type_traits/make_vector_type.hpp
  293. -- Installing: /usr/local/include/compute/boost/compute/type_traits/type_definition.hpp
  294. -- Installing: /usr/local/include/compute/boost/compute/memory
  295. -- Installing: /usr/local/include/compute/boost/compute/memory/svm_ptr.hpp
  296. -- Installing: /usr/local/include/compute/boost/compute/memory/local_buffer.hpp
  297. -- Installing: /usr/local/include/compute/boost/compute/experimental
  298. -- Installing: /usr/local/include/compute/boost/compute/experimental/clamp_range.hpp
  299. -- Installing: /usr/local/include/compute/boost/compute/experimental/sort_by_transform.hpp
  300. -- Installing: /usr/local/include/compute/boost/compute/experimental/tabulate.hpp
  301. -- Installing: /usr/local/include/compute/boost/compute/experimental/malloc.hpp
  302. -- Installing: /usr/local/include/compute/boost/compute/lambda
  303. -- Installing: /usr/local/include/compute/boost/compute/lambda/functional.hpp
  304. -- Installing: /usr/local/include/compute/boost/compute/lambda/result_of.hpp
  305. -- Installing: /usr/local/include/compute/boost/compute/lambda/placeholder.hpp
  306. -- Installing: /usr/local/include/compute/boost/compute/lambda/placeholders.hpp
  307. -- Installing: /usr/local/include/compute/boost/compute/lambda/get.hpp
  308. -- Installing: /usr/local/include/compute/boost/compute/lambda/make_tuple.hpp
  309. -- Installing: /usr/local/include/compute/boost/compute/lambda/context.hpp
  310. -- Installing: /usr/local/include/compute/boost/compute/lambda/make_pair.hpp
  311. -- Installing: /usr/local/include/compute/boost/compute/allocator.hpp
  312. -- Installing: /usr/local/include/compute/boost/compute/detail
  313. -- Installing: /usr/local/include/compute/boost/compute/detail/diagnostic.hpp
  314. -- Installing: /usr/local/include/compute/boost/compute/detail/meta_kernel.hpp
  315. -- Installing: /usr/local/include/compute/boost/compute/detail/duration.hpp
  316. -- Installing: /usr/local/include/compute/boost/compute/detail/buffer_value.hpp
  317. -- Installing: /usr/local/include/compute/boost/compute/detail/variadic_macros.hpp
  318. -- Installing: /usr/local/include/compute/boost/compute/detail/sha1.hpp
  319. -- Installing: /usr/local/include/compute/boost/compute/detail/iterator_plus_distance.hpp
  320. -- Installing: /usr/local/include/compute/boost/compute/detail/mpl_vector_to_tuple.hpp
  321. -- Installing: /usr/local/include/compute/boost/compute/detail/device_ptr.hpp
  322. -- Installing: /usr/local/include/compute/boost/compute/detail/print_range.hpp
  323. -- Installing: /usr/local/include/compute/boost/compute/detail/is_buffer_iterator.hpp
  324. -- Installing: /usr/local/include/compute/boost/compute/detail/iterator_range_size.hpp
  325. -- Installing: /usr/local/include/compute/boost/compute/detail/global_static.hpp
  326. -- Installing: /usr/local/include/compute/boost/compute/detail/read_write_single_value.hpp
  327. -- Installing: /usr/local/include/compute/boost/compute/detail/literal.hpp
  328. -- Installing: /usr/local/include/compute/boost/compute/detail/work_size.hpp
  329. -- Installing: /usr/local/include/compute/boost/compute/detail/iterator_traits.hpp
  330. -- Installing: /usr/local/include/compute/boost/compute/detail/lru_cache.hpp
  331. -- Installing: /usr/local/include/compute/boost/compute/detail/getenv.hpp
  332. -- Installing: /usr/local/include/compute/boost/compute/detail/parameter_cache.hpp
  333. -- Installing: /usr/local/include/compute/boost/compute/detail/is_contiguous_iterator.hpp
  334. -- Installing: /usr/local/include/compute/boost/compute/detail/vendor.hpp
  335. -- Installing: /usr/local/include/compute/boost/compute/detail/nvidia_compute_capability.hpp
  336. -- Installing: /usr/local/include/compute/boost/compute/detail/assert_cl_success.hpp
  337. -- Installing: /usr/local/include/compute/boost/compute/detail/cl_versions.hpp
  338. -- Installing: /usr/local/include/compute/boost/compute/detail/path.hpp
  339. -- Installing: /usr/local/include/compute/boost/compute/detail/get_object_info.hpp
  340. -- Installing: /usr/local/include/compute/boost/compute/container.hpp
  341. -- Installing: /usr/local/include/compute/boost/compute/event.hpp
  342. -- Installing: /usr/local/include/compute/boost/compute/svm.hpp
  343. -- Installing: /usr/local/include/compute/boost/compute/device.hpp
  344. -- Installing: /usr/local/include/compute/boost/compute/context.hpp
  345. -- Installing: /usr/local/include/compute/boost/compute/pipe.hpp
  346. -- Installing: /usr/local/include/compute/boost/compute/system.hpp
  347. -- Installing: /usr/local/include/compute/boost/compute/platform.hpp
  348. -- Installing: /usr/local/include/compute/boost/compute/async
  349. -- Installing: /usr/local/include/compute/boost/compute/async/wait_guard.hpp
  350. -- Installing: /usr/local/include/compute/boost/compute/async/future.hpp
  351. -- Installing: /usr/local/include/compute/boost/compute/async/wait.hpp
复制代码

会安装到目录 /usr/local/include 下

安装后使用Boost.Compute的步骤:


  1. CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
  2. set(project_name "main_cl")
  3. PROJECT(${project_name})
  4. #FIND_PACKAGE(CUDA REQUIRED)
  5. FIND_PACKAGE(OpenCL REQUIRED)
  6. find_package(Boost 1.54 REQUIRED)
  7. FIND_PACKAGE(BoostCompute REQUIRED)
  8. # 这个很关键 头文件不能歧义
  9. set(BoostCompute_INCLUDE_DIRS "/usr/local/include/compute")
  10. include_directories(${BoostCompute_INCLUDE_DIRS})
  11. message(WARNING ${BoostCompute_INCLUDE_DIRS})
  12. ADD_EXECUTABLE(${project_name} copy_data.cpp)
  13. target_link_libraries(${project_name} -lboost_system OpenCL)
复制代码


  1. //[copy_data_example

  2. #include <vector>
  3. #include <iostream>
  4. #include <boost/compute/algorithm/copy.hpp>
  5. #include <boost/compute/container/vector.hpp>

  6. namespace compute = boost::compute;

  7. //警告很多 为啥?

  8. int main()
  9. {
  10.     // get default device and setup context
  11.     compute::device device = compute::system::default_device();

  12.     // print the device's name and platform
  13.     std::cout << "hello from " << device.name();
  14.     std::cout << " (platform: " << device.platform().name() << ")" << std::endl;

  15.     compute::context context(device);
  16.     compute::command_queue queue(context, device);

  17.     // create data array on host
  18.     int host_data[] = { 1, 3, 5, 7, 9 };

  19.     // create vector on device
  20.     compute::vector<int> device_vector(5, context);

  21.     // copy from host to device
  22.     compute::copy(
  23.         host_data, host_data + 5, device_vector.begin(), queue
  24.     );

  25.     // create vector on host
  26.     std::vector<int> host_vector(5);

  27.     // copy data back to host
  28.     compute::copy(
  29.         device_vector.begin(), device_vector.end(), host_vector.begin(), queue
  30.     );
  31.     //遍历看看 对不对啊?
  32.     for(std::vector<int>::iterator it=host_vector.begin();it!=host_vector.end();it++){
  33.         std::cout << *it << " ";
  34.     }
  35.     std::cout << std::endl;
  36.     getchar();

  37.     return 0;
  38. }
复制代码








boost.compute.png (86.68 KB, 下载次数: 129)

boost.compute.png
让天下人人学会人工智能!人工智能的前景一片大好!
回复

使用道具 举报

0

主题

7

帖子

26

积分

新手上路

Rank: 1

积分
26
沙发
发表于 2021-8-1 13:22:46 | 只看该作者
网站还在运营吗?权限要高于198怎么解决
回复

使用道具 举报

1365

主题

1856

帖子

1万

积分

管理员

Rank: 10Rank: 10Rank: 10

积分
14451
QQ
板凳
 楼主| 发表于 2021-8-2 09:53:10 | 只看该作者
weiyuan 发表于 2021-8-1 13:22
网站还在运营吗?权限要高于198怎么解决

一直都在,联系我的微信:dfy_88888
让天下人人学会人工智能!人工智能的前景一片大好!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|人工智能工程师的摇篮 ( 湘ICP备2020019608号-1 )

GMT+8, 2024-6-18 21:49 , Processed in 0.201261 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表