#ifndef PFOR_PFOR_TRAITS_H #define PFOR_PFOR_TRAITS_H #include "algorithm.h" #include "clusters.h" #include "expression/traits.h" #include "range.h" namespace pfor { /** * @brief tests if the given expression can be run in parallel * * @param[in] Range ignored range (runtime information) * @param[in] E the expression * * @return true if the expression can be run in parallel */ template< typename Range, typename E, std::enable_if_t>* = nullptr > bool parallelTest(Range const&, E const&) { using Expressions = expr::SplitComma; return accumulate(true, std::logical_and{}); } /** * @brief tests if the given expression can be run in parallel given a range * * @param[in] begin the initial value of the index * @param[in] step the step of the index * @param[in] E the expression * * @return true if the expression can be run in parallel given (begin, step) */ template< typename E, typename RT, index::Value begin, index::Value step, std::enable_if_t>* = nullptr > bool parallelTest(TRangeCT const&, E const&) { using Expressions = PackForEach, GenSubstituteVariableInExpression::template type>; return accumulate(true, std::logical_and{}); } /** * @brief tests if the given expressions can be run in parallel, possibly given a range * * @param[in] Range possibly compile-time known information about the index values * @param[in] es a pack of expressions * * @return true if merged expressions can be run in parallel */ template< typename Range, typename... Es, std::enable_if_t>* = nullptr > bool parallelTest(Range const& range, Es const&... es) { return parallelTest(range, commaMerger(es...)); } } #endif