summaryrefslogtreecommitdiff
path: root/modules/core
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core')
-rw-r--r--modules/core/c++/abstract/alloc.hpp9
-rw-r--r--modules/core/c++/abstract/data.hpp53
-rw-r--r--modules/core/c++/abstract/encode.hpp9
-rw-r--r--modules/core/c++/abstract/schema.hpp60
-rw-r--r--modules/core/c++/abstract/string_literal.hpp61
-rw-r--r--modules/core/c++/abstract/stringify_schema.hpp51
-rw-r--r--modules/core/c++/hlbm.hpp20
7 files changed, 212 insertions, 51 deletions
diff --git a/modules/core/c++/abstract/alloc.hpp b/modules/core/c++/abstract/alloc.hpp
new file mode 100644
index 0000000..b15e737
--- /dev/null
+++ b/modules/core/c++/abstract/alloc.hpp
@@ -0,0 +1,9 @@
+#pragma once
+
+namespace kel {
+namespace lbm {
+namespace all {
+struct Native {};
+}
+}
+}
diff --git a/modules/core/c++/abstract/data.hpp b/modules/core/c++/abstract/data.hpp
index ed23268..f1ae5a7 100644
--- a/modules/core/c++/abstract/data.hpp
+++ b/modules/core/c++/abstract/data.hpp
@@ -1,52 +1,19 @@
#pragma once
-#include "templates.hpp"
+#include "schema.hpp"
+#include "encode.hpp"
namespace kel {
-namespace sch {
-struct Void {};
-
-struct UnsignedInteger {};
-struct SignedInteger {};
-struct FloatingPoint {};
-
-template<typename StorageT, typename InterfaceT>
-struct MixedPrecision {
- using Meta = Void;
- using StorageType = StorageT;
- using InterfaceType = InterfaceT;
-};
-
-template<typename PrimType, uint64_t N>
-struct Primitive {
- using Meta = Void;
- using Type = PrimType;
- static constexpr uint64_t Bytes = N;
-};
-
-template<typename T, uint64_t... Dims>
-struct FixedArray {
- using Meta = Void;
- using Inner = T;
- static constexpr std::array<uint64_t,sizeof...(Dims)> Dimensions{Dims...};
+namespace lbm {
+template<typename Schema, typename Encode = enc::Native>
+class data final {};
+
+template<typename T, uint64_t N>
+class data<sch::Primitive<T,N>,Encode> final {
+private:
+public:
};
-template<typename T, uint64_t Dims>
-struct Array {
- using Meta = FixedArray<UInt64,Dims>;
- using Inner = T;
- static constexpr std::array<uint64_t,sizeof...(Dims)> Dimensions{Dims};
-};
-
-template<typename... T>
-struct Tuple {
-};
}
-
-template<typename Sch>
-struct schema {
- using Type = Sch;
-};
-
}
diff --git a/modules/core/c++/abstract/encode.hpp b/modules/core/c++/abstract/encode.hpp
new file mode 100644
index 0000000..64aef4a
--- /dev/null
+++ b/modules/core/c++/abstract/encode.hpp
@@ -0,0 +1,9 @@
+#pragma once
+
+namespace kel {
+namespace lbm {
+namespace enc {
+struct Native {};
+}
+}
+}
diff --git a/modules/core/c++/abstract/schema.hpp b/modules/core/c++/abstract/schema.hpp
new file mode 100644
index 0000000..8305005
--- /dev/null
+++ b/modules/core/c++/abstract/schema.hpp
@@ -0,0 +1,60 @@
+#pragma once
+
+#include "string_literal.hpp"
+#include "templates.hpp"
+
+namespace kel {
+namespace sch {
+struct Void {};
+
+struct UnsignedInteger {};
+struct SignedInteger {};
+struct FloatingPoint {};
+
+template<typename StorageT, typename InterfaceT>
+struct MixedPrecision {
+ using Meta = Void;
+ using StorageType = StorageT;
+ using InterfaceType = InterfaceT;
+};
+
+template<typename PrimType, uint64_t N>
+struct Primitive {
+ using Meta = Void;
+ using StorageType = PrimType;
+ using InterfaceType = PrimType;
+ static constexpr uint64_t Bytes = N;
+};
+
+template<typename T, uint64_t... Dims>
+struct FixedArray {
+ using Meta = Void;
+ using Inner = T;
+ static constexpr std::array<uint64_t,sizeof...(Dims)> Dimensions{Dims...};
+};
+
+template<typename T, uint64_t Dims>
+struct Array {
+ using Meta = FixedArray<UInt64,Dims>;
+ using Inner = T;
+ static constexpr std::array<uint64_t,sizeof...(Dims)> Dimensions{Dims};
+};
+
+template<typename... T>
+struct Tuple {
+};
+
+template<typename Value, string_literal Key>
+struct Member {};
+
+template<typename... SL>
+struct Struct {};
+
+}
+
+template<typename Sch>
+struct schema {
+ using Type = Sch;
+};
+
+}
diff --git a/modules/core/c++/abstract/string_literal.hpp b/modules/core/c++/abstract/string_literal.hpp
new file mode 100644
index 0000000..51e58c8
--- /dev/null
+++ b/modules/core/c++/abstract/string_literal.hpp
@@ -0,0 +1,61 @@
+#pragma once
+
+#include <array>
+#include <string_view>
+
+namespace kel {
+namespace lbm {
+/**
+ * Helper object which creates a templated string from the provided string
+ * literal. It guarantees compile time uniqueness and thus allows using strings
+ * in template parameters.
+ */
+template <class CharT, size_t N> class string_literal {
+public:
+ static_assert(N > 0, "string_literal needs a null terminator");
+
+ constexpr string_literal(const CharT (&input)[N]) noexcept {
+ for (size_t i = 0; i < N; ++i) {
+ data[i] = input[i];
+ }
+ }
+
+ std::array<CharT, N> data{};
+
+ constexpr std::string_view view() const noexcept {
+ return std::string_view{data.data()};
+ }
+
+ constexpr bool
+ operator==(const string_literal<CharT, N> &) const noexcept = default;
+
+ template <class CharTR, size_t NR>
+ constexpr bool
+ operator==(const string_literal<CharTR, NR> &) const noexcept {
+ return false;
+ }
+
+ template<size_t NR>
+ constexpr string_literal<CharT, N+NR-1> operator+(const string_literal<CharT, NR>& rhs) const noexcept {
+ CharT sum[N+NR-1];
+
+ // The weird i+1 happens due to needing to skip the '\0' terminator
+ for(size_t i = 0; (i+1) < N; ++i){
+ sum[i] = data[i];
+ }
+ for(size_t i = 0; i < NR; ++i){
+ sum[i+N-1] = rhs.data[i];
+ }
+
+ return string_literal<CharT, N+NR-1>{sum};
+ }
+
+
+};
+
+template <typename T, T... Chars>
+constexpr string_literal<T, sizeof...(Chars) + 1u> operator""_sl() {
+ return string_literal<T, sizeof...(Chars) + 1u>{{Chars..., '\0'}};
+}
+}
+}
diff --git a/modules/core/c++/abstract/stringify_schema.hpp b/modules/core/c++/abstract/stringify_schema.hpp
new file mode 100644
index 0000000..866bc7e
--- /dev/null
+++ b/modules/core/c++/abstract/stringify_schema.hpp
@@ -0,0 +1,51 @@
+#pragma once
+
+#include "schema.hpp"
+
+namespace kel {
+namespace lbm {
+namespace impl {
+template<class T>
+struct schema_to_string_helper {
+ static_assert(always_false<T>, "schema_to_string_helper specialization not handled.");
+
+ static constexpr string_literal apply(){
+ return {};
+ }
+};
+
+template<>
+struct schema_to_string_helper<sch::SignedInteger> final {
+ static constexpr string_literal apply(){
+ return "SignedInteger";
+ }
+};
+
+template<>
+struct schema_to_string_helper<sch::UnsignedInteger> final {
+ static constexpr string_literal apply(){
+ return "UnsignedInteger";
+ }
+};
+
+template<>
+struct schema_to_string_helper<sch::FloatingPoint> final {
+ static constexpr string_literal apply(){
+ return "FloatingPoint";
+ }
+};
+
+template<typename T, uint64_t N>
+struct schema_to_string_helper<sch::Primitive<T,N>> final {
+ static constexpr string_literal apply(){
+ return "Primitive<"+schema_to_string_helper<T>::apply()+","+N+">";
+ }
+};
+}
+
+template<class T>
+struct schema_to_string{
+ static constexpr std::string_view value = impl::schema_to_string_helper<T>::apply().view();
+};
+}
+}
diff --git a/modules/core/c++/hlbm.hpp b/modules/core/c++/hlbm.hpp
index eccc2cd..1c625bb 100644
--- a/modules/core/c++/hlbm.hpp
+++ b/modules/core/c++/hlbm.hpp
@@ -103,16 +103,13 @@ public:
template<typename T, typename Desc, typename Encode>
class component<T, Desc, cmpt::HlbmParticle, Encode> final {
private:
+/*
template<typename CellFieldSchema, typename MacroFieldSchema, typename ParticleSchema, uint64_t i>
void apply_i(const saw::data<CellFieldSchema, Encode>& field, const saw::data<MacroFieldSchema,Encode>& macros, const saw::data<ParticleSchema,Encode>& part_groups, saw::data<sch::FixedArray<sch::UInt64,1u>> index, saw::data<sch::UInt64> time_step) const {
// if constexpr ( i < )
- }
+ }
+*/
public:
- /*
- template<typename CellFieldSchema, typename MacroFieldSchema, typename ParticleSchema, uint64_t i>
- void apply_i()
- */
-
template<typename CellFieldSchema, typename MacroFieldSchema, typename ParticleSchema>
void apply(const saw::data<CellFieldSchema, Encode>& field, const saw::data<MacroFieldSchema,Encode>& macros, const saw::data<ParticleSchema,Encode>& part_group, saw::data<sch::FixedArray<sch::UInt64,1u>> index, saw::data<sch::UInt64> time_step) const {
/// Figure out how to access the particle list
@@ -125,7 +122,7 @@ public:
auto& mvel = macros.template get<"velocity">();
{
auto& parts = part_spheroid_group.template get<"particles">();
- auto parts_size = parts.dims().at({0u});
+ auto parts_size = parts.meta().at({0u});
auto& pi = parts.at(index);
auto& pirb = pi.template get<"rigid_body">();
@@ -134,7 +131,14 @@ public:
saw::data<sch::FixedArray<sch::UInt64,Desc::D>> start;
saw::data<sch::FixedArray<sch::UInt64,Desc::D>> stop;
- auto aabb = particle_aabb<ParticleSchema>::calculate(part_spheroid_group,index,mvel.meta());
+ auto eo_aabb = particle_aabb<typename ParticleSchema::ValueType>::calculate(part_spheroid_group,index,mvel.meta());
+ if(eo_aabb.is_error()){
+ std::cerr<<"Prepping error"<<std::endl;
+ std::cerr<<eo_aabb.get_error().get_category()<<std::endl;
+ return;
+ }
+ auto& aabb = eo_aabb.get_value();
+
/// Ok, I iterate over the space which covers our particle? So lower bounds to upper bounds
start = aabb.template get<"a">();
stop = aabb.template get<"b">();