#ifndef PFOR_PFOR_CONDITIONS_H #define PFOR_PFOR_CONDITIONS_H #include "mp/pack.h" namespace pfor { /** * @brief testing Bernstein's conditions on two expressions * * @param E0 an expression's information (I, W, R) where W and R are sets of written/read variables * @param E1 an expression's information * * @return true if the expressions depend on each other * * Bernstein's conditions for independance are : * - no intersection between modified variables (xW, yW) * - no intersection between read/modified variables (xR, yW) and (yR, xW) */ template struct ExpressionDepends; template struct ExpressionDepends, Pack> { static constexpr bool value = PackIntersects::value || PackIntersects::value || PackIntersects::value; }; template constexpr bool expressionDepends = ExpressionDepends::value; /** * @brief testing Bernstein's conditions between each expression of a pack with one expression * * @param C a cluster of expressions' information * @param T an expression's information * * @return true if any of the expressions from the cluster depends on the expression T */ template struct ClusterDepends; template struct ClusterDepends, T> { using next = ClusterDepends, T>; static constexpr bool value = ExpressionDepends::value || next::value; }; template struct ClusterDepends, T> { static constexpr bool value = false; }; template constexpr bool clusterDepends = ClusterDepends::value; } #endif