Advertisement
froleyks

phast.hpp<2>

Feb 20th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1.       const unsigned trees_per_thread = num_trees / num_threads;
  2.       const unsigned more_work_limit =
  3.           num_trees - trees_per_thread * num_threads;
  4.       std::vector<std::thread> workers;
  5.       workers.reserve(num_threads);
  6.       for (unsigned id = 0; id < num_threads; ++id) {
  7.         workers.emplace_back([this, id, &ch, &starts, &distances,
  8.                               trees_per_thread, more_work_limit]() {
  9.           const unsigned begin =
  10.               trees_per_thread * id + more_work_limit -
  11.               (id < more_work_limit ? (more_work_limit - id) : 0);
  12.           const unsigned end =
  13.               trees_per_thread * (id + 1) + more_work_limit -
  14.               ((id + 1) < more_work_limit ? (more_work_limit - (id + 1)) : 0);
  15.           for (unsigned index = begin; index < end; ++index) {
  16.             forward_search_init(ch, ((unsigned *)&starts)[index], distances,
  17.                                 index);
  18.           }
  19.         });
  20.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement