diff options
Diffstat (limited to 'tangle/LLBM/operator.h')
-rw-r--r-- | tangle/LLBM/operator.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tangle/LLBM/operator.h b/tangle/LLBM/operator.h new file mode 100644 index 0000000..6fb80e6 --- /dev/null +++ b/tangle/LLBM/operator.h @@ -0,0 +1,27 @@ +#pragma once + +#include <tuple> + +template <typename OPERATOR, typename... ARGS> +struct Operator { + bool* const mask; + const std::tuple<ARGS...> config; + + Operator(OPERATOR, DeviceBuffer<bool>& m, ARGS... args): + mask(m.device()), + config(args...) { } + + template <typename DESCRIPTOR, typename T, typename S> + __device__ bool apply(DESCRIPTOR d, S f_curr[DESCRIPTOR::q], S f_next[DESCRIPTOR::q], std::size_t gid) const { + if (mask[gid]) { + std::apply([](auto... args) { OPERATOR::template apply<T,S>(args...); }, + std::tuple_cat(std::make_tuple(d, f_curr, f_next, gid), config)); + return true; + } else { + return false; + } + } +}; + +template <typename OPERATOR, typename... ARGS> +Operator(OPERATOR, DeviceBuffer<bool>&, ARGS... args) -> Operator<OPERATOR,std::remove_reference_t<ARGS>...>; |