summaryrefslogtreecommitdiff
path: root/lib/core/c++
diff options
context:
space:
mode:
Diffstat (limited to 'lib/core/c++')
-rw-r--r--lib/core/c++/common.hpp1
-rw-r--r--lib/core/c++/memory.hpp20
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/core/c++/common.hpp b/lib/core/c++/common.hpp
index 5f7129f..280d953 100644
--- a/lib/core/c++/common.hpp
+++ b/lib/core/c++/common.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <forstio/codec/data.hpp>
+#include <forstio/codec/math.hpp>
namespace kel {
namespace lbm {
diff --git a/lib/core/c++/memory.hpp b/lib/core/c++/memory.hpp
index b6a089e..e97c7fc 100644
--- a/lib/core/c++/memory.hpp
+++ b/lib/core/c++/memory.hpp
@@ -21,11 +21,31 @@ struct memory_size_helper<sch::FixedArray<Sch,N...>> {
static constexpr uint64_t bytes = saw::ct_multiply<uint64_t,N...>::value * memory_size_helper<Sch>::bytes;
};
+template<typename Sch, uint64_t... N>
+struct memory_size_helper<sch::Tensor<Sch,N...>> {
+ static constexpr uint64_t bytes = saw::ct_multiply<uint64_t,N...>::value * memory_size_helper<Sch>::bytes;
+};
+
template<typename Sch, uint64_t Ghost, uint64_t... N>
struct memory_size_helper<sch::Chunk<Sch,Ghost,N...>> {
static constexpr uint64_t bytes = memory_size_helper<typename sch::Chunk<Sch,Ghost,N...>::InnerSchema>::bytes;
};
+template<typename... Members>
+struct memory_size_helper<sch::Struct<Members...>> {
+
+ template<uint64_t i>
+ static constexpr uint64_t apply_i() {
+ if constexpr ( i < sizeof...(Members) ){
+ using M_I = typename saw::parameter_pack_type<i,Members...>::type;
+ return apply_i<i+1u>() + memory_size_helper<typename M_I::ValueType>::bytes;
+ }
+ return 0u;
+ }
+
+ static constexpr uint64_t bytes = apply_i<0u>();
+};
+
template<typename... T>
class memory_estimate_helper final {
private: