[关闭]
@babydragon 2016-06-11T14:09:57.000000Z 字数 1867 阅读 2364

Boost 1.61发布,带来了新的CPU/CPU计算、插件管理和其他程序库

c++

在1.60版本发布的5个月后,Boost发布了1.61版本,增加了一些新程序库,同时更新了许多程序库。


在1.60版本发布的5个月后,Boost发布了1.61版本,增加了一些新程序库,同时更新了许多程序库。

Boost 1.61包括4个新程序库:

  1. std::vector<float> host_vector(10000);
  2. // 定义宿主机内容向量
  3. // 获取默认设备,并且设置上下文
  4. compute::device device = compute::system::default_device();
  5. compute::context context(device);
  6. compute::command_queue queue(context, device);
  7. // 在设备上创建向量
  8. compute::vector<float> device_vector(host_vector.size(), context);
  9. // 将数据从宿主机传输到设备上
  10. compute::copy(
  11. host_vector.begin(), host_vector.end(), device_vector.begin(), queue
  12. );
  13. // 就地计算每个元素的平方根
  14. compute::transform(
  15. device_vector.begin(),
  16. device_vector.end(),
  17. device_vector.begin(),
  18. compute::sqrt<float>(),
  19. queue
  20. );
  21. // 将数据复制回宿主机
  22. compute::copy(
  23. device_vector.begin(), device_vector.end(), host_vector.begin(), queue
  24. );
  1. // 持有指向插件变量指针的变量
  2. boost::shared_ptr<my_plugin_api> plugin;
  3. plugin = dll::import<my_plugin_api>(
  4. full_path_to_library,
  5. name_of_symbol_to_import,
  6. dll::load_mode::append_decorations
  7. );

DLL也支持动态链接库的引用计数,以更好的控制已加载插件的生命周期、在插件卸载时执行回调函数和其他一些功能。

前文提到过,Boost 1.61也更新了许多现有程序库,包括Multiprecision(多倍精度数值库)、Optional(含无效值容器库)、Geometry(几何库)、Fusion(容器库)等等。

查看英文原文:https://www.infoq.com/news/2016/05/boost-1-61-released

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注