37 if(n <= std::size_t(0))
43#if !defined(FEAT_HAVE_OMP)
46 for(std::size_t i = 0u; i < n; ++i)
50 const std::size_t max_threads(omp_get_max_threads());
51 if(n < 10u*max_threads)
55 for(std::size_t i = 0u; i < n; ++i)
61 std::vector<T_> vo(max_threads+1u, T_(0));
64 FEAT_PRAGMA_OMP(parallel shared(vo))
66 const std::size_t num_threads(omp_get_num_threads());
67 const std::size_t thread_id(omp_get_thread_num());
70 const std::size_t i0 = (n * thread_id) / num_threads;
71 const std::size_t i1 = (n * (thread_id+1u)) / num_threads;
75 for(std::size_t i = i0; i < i1; ++i)
84 FEAT_PRAGMA_OMP(barrier)
87 FEAT_PRAGMA_OMP(master)
89 for(std::size_t i = 1u; i < num_threads; ++i)
96 FEAT_PRAGMA_OMP(barrier)
100 for(std::size_t i = i0; i < i1; ++i)
124 template<
typename T_>
127 if(n <= std::size_t(0))
133#if !defined(FEAT_HAVE_OMP)
136 for(std::size_t i = 0u; i < n; ++i)
144 const std::size_t max_threads(omp_get_max_threads());
145 if(n < 10u*max_threads)
149 for(std::size_t i = 0u; i < n; ++i)
159 std::vector<T_> vo(max_threads+1u, T_(0));
162 FEAT_PRAGMA_OMP(parallel shared(vo))
164 const std::size_t num_threads(omp_get_num_threads());
165 const std::size_t thread_id(omp_get_thread_num());
168 const std::size_t i0 = (n * thread_id) / num_threads;
169 const std::size_t i1 = (n * (thread_id+1u)) / num_threads;
173 for(std::size_t i = i0; i < i1; ++i)
181 vo[thread_id+1u] = k;
184 FEAT_PRAGMA_OMP(barrier)
187 FEAT_PRAGMA_OMP(master)
189 for(std::size_t i = 1u; i < num_threads; ++i)
196 FEAT_PRAGMA_OMP(barrier)
200 for(std::size_t i = i0; i < i1; ++i)
#define XASSERT(expr)
Assertion macro definition.
void feat_omp_ex_scan(std::size_t n, const T_ x[], T_ y[])
Computes an OpenMP-parallel exclusive scan a.k.a. a prefix sum of an array, i.e.
void feat_omp_in_scan(std::size_t n, const T_ x[], T_ y[])
Computes an OpenMP-parallel inclusive scan a.k.a. a prefix sum of an array, i.e.