30 return omp_get_thread_num();
43 std::atomic<bool> failed{
false};
44 std::exception_ptr error;
45#pragma omp parallel for schedule(dynamic, 8)
46 for (
Index i = 0; i < n; ++i) {
47 if (failed.load(std::memory_order_relaxed))
continue;
49 body(i, omp_get_thread_num());
51#pragma omp critical(hpfem_parallel_for_error)
53 if (!failed.exchange(
true)) error = std::current_exception();
57 if (error) std::rethrow_exception(error);
59 for (
Index i = 0; i < n; ++i) body(i, 0);
Definition axisymmetric_estimator.hpp:39
void set_num_threads(int threads) noexcept
int num_threads() noexcept
Number of threads a parallel loop uses (1 without OpenMP).
void parallel_for(Index n, Body &&body)
Definition parallel.hpp:41
std::int64_t Index
global indices (DoFs, entities)
Definition types.hpp:17
int thread_index() noexcept
Index of the calling thread inside a parallel loop, 0 outside.
Definition parallel.hpp:28
bool has_openmp() noexcept
True if the library was built with OpenMP.