42#ifndef UFO_EXECUTION_EXECUTION_HPP
43#define UFO_EXECUTION_EXECUTION_HPP
50#if defined(UFO_PAR_STL)
55#if defined(UFO_PAR_GCD)
56#include <dispatch/dispatch.h>
62#if defined(UFO_PAR_TBB)
63#include <oneapi/tbb.h>
67#if defined(UFO_PAR_OMP)
77enum class ExecutionMode : std::uint32_t {
85enum class ExecutionBackend : std::uint32_t {
88#if defined(UFO_PAR_STL)
94#if defined(UFO_PAR_GCD)
100#if defined(UFO_PAR_TBB)
106#if defined(UFO_PAR_OMP)
112 ALL = STL | GCD | TBB | OMP
115[[nodiscard]]
constexpr ExecutionMode operator|(ExecutionMode lhs,
116 ExecutionMode rhs)
noexcept
118 return ExecutionMode(std::to_underlying(lhs) | std::to_underlying(rhs));
121[[nodiscard]]
constexpr ExecutionMode operator&(ExecutionMode lhs,
122 ExecutionMode rhs)
noexcept
124 return ExecutionMode(std::to_underlying(lhs) & std::to_underlying(rhs));
127[[nodiscard]]
constexpr ExecutionBackend operator|(ExecutionBackend lhs,
128 ExecutionBackend rhs)
noexcept
130 return ExecutionBackend(std::to_underlying(lhs) | std::to_underlying(rhs));
133[[nodiscard]]
constexpr ExecutionBackend operator&(ExecutionBackend lhs,
134 ExecutionBackend rhs)
noexcept
136 return ExecutionBackend(std::to_underlying(lhs) & std::to_underlying(rhs));
140template <detail::ExecutionMode Policy, detail::ExecutionBackend Backend>
142 static constexpr detail::ExecutionMode
const policy = Policy;
143 static constexpr detail::ExecutionBackend
const backend = Backend;
210template <detail::ExecutionMode Policy, detail::ExecutionBackend Backend>
211 requires(detail::ExecutionBackend::NONE != Backend &&
212 detail::ExecutionMode::NONE != Policy)
217constexpr inline bool is_execution_policy_v =
221constexpr inline bool is_seq_v =
222 detail::ExecutionMode::NONE !=
223 (detail::ExecutionMode::SEQ & std::remove_cvref_t<T>::policy);
226constexpr inline bool is_unseq_v =
227 detail::ExecutionMode::NONE !=
228 (detail::ExecutionMode::UNSEQ & std::remove_cvref_t<T>::policy);
231constexpr inline bool is_par_v =
232 detail::ExecutionMode::NONE !=
233 (detail::ExecutionMode::PAR & std::remove_cvref_t<T>::policy);
236constexpr inline bool is_par_unseq_v =
237 detail::ExecutionMode::NONE !=
238 (detail::ExecutionMode::PAR_UNSEQ & std::remove_cvref_t<T>::policy);
241constexpr inline bool is_stl_v =
242 detail::ExecutionBackend::NONE !=
243 (detail::ExecutionBackend::STL & std::remove_cvref_t<T>::backend);
246constexpr inline bool is_gcd_v =
247 detail::ExecutionBackend::NONE !=
248 (detail::ExecutionBackend::GCD & std::remove_cvref_t<T>::backend);
251constexpr inline bool is_tbb_v =
252 detail::ExecutionBackend::NONE !=
253 (detail::ExecutionBackend::TBB & std::remove_cvref_t<T>::backend);
256constexpr inline bool is_omp_v =
257 detail::ExecutionBackend::NONE !=
258 (detail::ExecutionBackend::OMP & std::remove_cvref_t<T>::backend);
291constexpr inline sequenced_policy seq{};
293constexpr inline parallel_policy par{};
294constexpr inline parallel_unsequenced_policy par_unseq{};
295constexpr inline gcd_sequenced_policy gcd_seq{};
296constexpr inline gcd_unsequenced_policy gcd_unseq{};
297constexpr inline gcd_parallel_policy gcd_par{};
298constexpr inline gcd_parallel_unsequenced_policy gcd_par_unseq{};
299constexpr inline tbb_sequenced_policy tbb_seq{};
300constexpr inline tbb_unsequenced_policy tbb_unseq{};
301constexpr inline tbb_parallel_policy tbb_par{};
302constexpr inline tbb_parallel_unsequenced_policy tbb_par_unseq{};
303constexpr inline omp_sequenced_policy omp_seq{};
304constexpr inline omp_unsequenced_policy omp_unseq{};
305constexpr inline omp_parallel_policy omp_par{};
306constexpr inline omp_parallel_unsequenced_policy omp_par_unseq{};
308template <ExecutionPolicy T>
309[[nodiscard]]
constexpr auto toSTL([[maybe_unused]] T&& policy)
311#if defined(UFO_PAR_STL)
312 if constexpr (is_stl_v<T>) {
313 if constexpr (is_seq_v<T>) {
314 return std::execution::seq;
315 }
else if constexpr (is_unseq_v<T>) {
316 return std::execution::unseq;
317 }
else if constexpr (is_par_v<T>) {
318 return std::execution::par;
319 }
else if constexpr (is_par_unseq_v<T>) {
320 return std::execution::par_unseq;
All vision-related classes and functions.