Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <boost/compute/algorithm/copy.hpp>
  5. #include <boost/compute/container/vector.hpp>
  6. #include <boost/compute/types/struct.hpp>
  7. #include <boost/compute/algorithm/transform.hpp>
  8.  
  9. namespace compute = boost::compute;
  10.  
  11. struct Unit{
  12.     bool center, left_up,
  13.         up, right_up,
  14.         right,right_down,
  15.         down, left_down,
  16.         left;
  17. };
  18.  
  19. BOOST_COMPUTE_ADAPT_STRUCT(Unit, Unit, (center, left_up, up, right_up, right, right_down, down, left_down, left))
  20.  
  21. int main(){
  22.     compute::device device = compute::system::default_device();
  23.     compute::context context(device);
  24.     compute::command_queue queue(context, device);
  25.  
  26.     BOOST_COMPUTE_FUNCTION(bool, testing, (Unit a),{
  27.             return false;
  28.     });
  29.     std::vector<Unit> t(1);
  30.     t.push_back(Unit{true, true, true, true, true, true, true, true, true});
  31.     compute::vector<Unit> dev_v(1, context);
  32.     compute::vector<bool> dev_o(1, context);
  33.  
  34.     compute::copy(
  35.             t.begin(), t.end(), dev_v.begin(), queue
  36.              );
  37.     std::vector<bool> host_v(1);
  38.     compute::transform(dev_v.begin(), dev_v.end(), dev_o.begin(), testing, queue);
  39.     compute::copy(
  40.             dev_o.begin(), dev_o.end(), host_v.begin(), queue
  41.             );
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement