This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 4th, 2012  |  syntax: C++  |  size: 0.44 KB  |  views: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //TBB
  2. auto worker = [&] (tbb::blocked_range<int> range) {
  3.  
  4.         //allocate memory here, which do_stuff() needs
  5.        
  6.         auto do_stuff = [&] (...)  { ... };
  7.  
  8.         for(auto i = range.begin(); i != range.end(); ++i) {
  9.                 container[i] = do_stuff(i); // just some example
  10.         }
  11.  
  12. }
  13.  
  14. tbb::parallel_for(tbb::blocked_range<int>(0, 1000), worker);
  15.  
  16. //PPL
  17.  
  18. auto worker = [&] (int i) {
  19.  
  20.         container[i] = do_stuff(i);
  21.  
  22. }
  23.  
  24. ppl::parallel_for(0, 1000, worker);
clone this paste RAW Paste Data