MCPcopy Create free account
hub / github.com/BirolLab/abyss / iteratorMultithreading

Function iteratorMultithreading

RResolver/RUtils.h:16–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15template<typename IteratorT, typename FilterT, typename ActionT>
16void
17iteratorMultithreading(
18 const IteratorT& start,
19 const IteratorT& end,
20 const FilterT& filter,
21 const ActionT& action,
22 const int threads = 0)
23{
24#if _OPENMP
25 int threadsBefore = 1;
26 if (threads > 0) {
27 threadsBefore = omp_get_max_threads();
28 omp_set_num_threads(threads);
29 }
30#else
31 (void)threads;
32#endif
33 IteratorT it = start;
34 while (it != end) {
35#pragma omp parallel
36#pragma omp single
37 {
38#if _OPENMP
39 for (unsigned i = 0; i < MAX_SIMULTANEOUS_TASKS; i++)
40#endif
41 {
42 if (filter(*it)) {
43#pragma omp task firstprivate(it)
44 {
45 action(*it);
46 }
47 }
48 ++it;
49#if _OPENMP
50 if (it == end)
51 break;
52#endif
53 }
54 }
55 }
56#if _OPENMP
57 if (threads > 0) {
58 omp_set_num_threads(threadsBefore);
59 }
60#endif
61}
62
63void
64progressStart(const std::string& name, unsigned total);

Callers 2

resolveRepeatsFunction · 0.85
processGraphFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected