From 4ec94c97879aafef15f7663135745e4ba61e62cf Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 17 May 2021 00:15:33 +0200 Subject: Extract first public LiterateLB version --- tangle/LLBM/operator.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tangle/LLBM/operator.h (limited to 'tangle/LLBM/operator.h') 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 + +template +struct Operator { + bool* const mask; + const std::tuple config; + + Operator(OPERATOR, DeviceBuffer& m, ARGS... args): + mask(m.device()), + config(args...) { } + + template + __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(args...); }, + std::tuple_cat(std::make_tuple(d, f_curr, f_next, gid), config)); + return true; + } else { + return false; + } + } +}; + +template +Operator(OPERATOR, DeviceBuffer&, ARGS... args) -> Operator...>; -- cgit v1.2.3