Advertisement
HellFinger

boost set_intersection

Apr 23rd, 2022
835
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //g++ boostset.cpp -o bs -O2
  2. #include <boost/compute/system.hpp>
  3. #include <boost/compute/algorithm/set_intersection.hpp>
  4. #include <boost/compute/container/vector.hpp>
  5. #include "stdc++.h"
  6.  
  7.  
  8.  
  9. int main(){
  10.  
  11.  
  12.     boost::compute::device device = boost::compute::system::default_device();
  13.     boost::compute::context context(device);
  14.     boost::compute::command_queue queue(context, device);
  15.  
  16.     std::vector<uint32_t> a;
  17.     std::vector<uint32_t> b;
  18.     boost::compute::vector<uint32_t> c;
  19.  
  20.     a.push_back(4);
  21.     a.push_back(5);
  22.     a.push_back(6);
  23.     a.push_back(7);
  24.  
  25.  
  26.     b.push_back(4);
  27.     b.push_back(5);
  28.     b.push_back(6);
  29.     b.push_back(9);
  30.  
  31.  
  32.     boost::compute::vector<uint32_t> aBoost(context);
  33.     boost::compute::vector<uint32_t> bBoost(context);
  34.  
  35.     boost::compute::copy(
  36.         a.begin(), a.end(), aBoost.begin(), queue
  37.     );
  38.  
  39.     boost::compute::copy(
  40.         b.begin(), b.end(), bBoost.begin(), queue
  41.     );
  42.  
  43.     boost::compute::set_intersection(aBoost.begin(), aBoost.end(), bBoost.begin(), bBoost.end(), c.begin(), queue);
  44.  
  45.     queue.finish();
  46.  
  47.  
  48.     std::cout << "Working fine\n";
  49.     return 0;
  50. }
Advertisement
RAW Paste Data Copied
Advertisement