14#ifndef PLASK__PLASK_PARALLEL_H
15#define PLASK__PLASK_PARALLEL_H
17#include <plask/config.hpp>
28#if defined(OPENMP_FOUND) || defined(DOXYGEN)
53 inline operator bool()
const {
return true; }
57# define PLASK_OMP_PARALLEL \
58 if (plask::OmpEnabler omp_enabler{}) __pragma(omp parallel)
59# define PLASK_OMP_PARALLEL_FOR \
60 if (plask::OmpEnabler omp_enabler{}) __pragma(omp parallel for)
61# define PLASK_OMP_PARALLEL_FOR_1 \
62 if (plask::OmpEnabler omp_enabler{}) __pragma(omp parallel for schedule(dynamic,1))
64# define PLASK_OMP_PARALLEL \
65 if (plask::OmpEnabler omp_enabler{}) _Pragma("omp parallel")
66# define PLASK_OMP_PARALLEL_FOR \
67 if (plask::OmpEnabler omp_enabler{}) _Pragma("omp parallel for")
68# define PLASK_OMP_PARALLEL_FOR_1 \
69 if (plask::OmpEnabler omp_enabler{}) _Pragma("omp parallel for schedule(dynamic,1)")
82 virtual OmpLockState*
lock() = 0;
83 virtual void unlock(OmpLockState*) = 0;
92 ~OmpNestedLock() { omp_destroy_nest_lock(&lck); }
93 OmpLockState* lock()
override { omp_set_nest_lock(&lck);
return nullptr; }
94 void unlock(OmpLockState*)
override { omp_unset_nest_lock(&lck); }
103 ~OmpSingleLock() { omp_destroy_lock(&lck); }
104 OmpLockState* lock()
override { omp_set_lock(&lck);
return nullptr; }
105 void unlock(OmpLockState*)
override { omp_unset_lock(&lck); }
127 if (lock) lock->unlock(
state);
139 if (lock) lock->unlock(
state);
147# define PLASK_OMP_PARALLEL
148# define PLASK_OMP_PARALLEL_FOR
149# define PLASK_OMP_PARALLEL_FOR_1
164# define OmpNestedLock OmpLock
165# define OmpSingleLock OmpLock