From c0549d71b2109f10c1238db8b22362e7826ba61b Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 5 Jul 2026 15:59:23 +0200 Subject: Just rename from lib to modules --- modules/core/c++/memory.hpp | 82 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 modules/core/c++/memory.hpp (limited to 'modules/core/c++/memory.hpp') diff --git a/modules/core/c++/memory.hpp b/modules/core/c++/memory.hpp new file mode 100644 index 0000000..e97c7fc --- /dev/null +++ b/modules/core/c++/memory.hpp @@ -0,0 +1,82 @@ +#pragma once + +#include "common.hpp" +#include "chunk.hpp" + +namespace kel { +namespace lbm { + +namespace impl { + +template +struct memory_size_helper; + +template +struct memory_size_helper> { + static constexpr uint64_t bytes = N; +}; + +template +struct memory_size_helper> { + static constexpr uint64_t bytes = saw::ct_multiply::value * memory_size_helper::bytes; +}; + +template +struct memory_size_helper> { + static constexpr uint64_t bytes = saw::ct_multiply::value * memory_size_helper::bytes; +}; + +template +struct memory_size_helper> { + static constexpr uint64_t bytes = memory_size_helper::InnerSchema>::bytes; +}; + +template +struct memory_size_helper> { + + template + static constexpr uint64_t apply_i() { + if constexpr ( i < sizeof...(Members) ){ + using M_I = typename saw::parameter_pack_type::type; + return apply_i() + memory_size_helper::bytes; + } + return 0u; + } + + static constexpr uint64_t bytes = apply_i<0u>(); +}; + +template +class memory_estimate_helper final { +private: + + template + static void apply_i(saw::data& bytes){ + + if constexpr ( i < sizeof...(T)){ + using T_I = typename saw::parameter_pack_type::type; + + bytes.set(bytes.get() + memory_size_helper::bytes); + + apply_i(bytes); + } + } + +public: + + static void apply(saw::data& bytes){ + apply_i<0u>(bytes); + } +}; +} + +template +saw::data memory_estimate(){ + saw::data bytes; + + impl::memory_estimate_helper::apply(bytes); + + return bytes; +} +} +} -- cgit v1.2.3