diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-19 13:35:25 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-19 13:35:25 +0100 |
| commit | 8b3ade73997e9f87f1232b9dc9af35969e6f50dd (patch) | |
| tree | 832f62951389ffc5f5a593a57cc6d41e3da759ab /examples/heterogeneous_computing | |
| parent | 4fd241a9405124d9ac66fe7417bf628273a3762f (diff) | |
| download | libs-lbm-8b3ade73997e9f87f1232b9dc9af35969e6f50dd.tar.gz | |
Rewriting parts to handle different ghost layers
Diffstat (limited to 'examples/heterogeneous_computing')
| -rw-r--r-- | examples/heterogeneous_computing/SConscript | 2 | ||||
| -rw-r--r-- | examples/heterogeneous_computing/heterogeneous_computing.cpp | 36 | ||||
| -rw-r--r-- | examples/heterogeneous_computing/sim.cpp | 96 |
3 files changed, 97 insertions, 37 deletions
diff --git a/examples/heterogeneous_computing/SConscript b/examples/heterogeneous_computing/SConscript index 1e52d88..226185b 100644 --- a/examples/heterogeneous_computing/SConscript +++ b/examples/heterogeneous_computing/SConscript @@ -22,7 +22,7 @@ env.headers += examples_env.headers; # Cavity2D examples_objects = []; -examples_env.add_source_files(examples_objects, ['heterogeneous_computing.cpp'], shared=False); +examples_env.add_source_files(examples_objects, ['sim.cpp'], shared=False); examples_env.heterogeneous_computing = examples_env.Program('#bin/heterogeneous_computing', [examples_objects]); # Set Alias diff --git a/examples/heterogeneous_computing/heterogeneous_computing.cpp b/examples/heterogeneous_computing/heterogeneous_computing.cpp deleted file mode 100644 index 8a79354..0000000 --- a/examples/heterogeneous_computing/heterogeneous_computing.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include <forstio/error.hpp> -#include <iostream> - - -namespace kel { -namespace lbm { -namespace sch { -using namespace saw::schema; -using KelConfig = Struct< - Member<String,"resolution"> ->; -} -} - -saw::error_or<void> lbm_main(int argc, char** argv){ - return saw::make_void(); -} -} - -int main(int argc, char** argv){ - auto eov = kel::lbm_main(argc, argv); - if(eov.is_error()){ - auto& err = eov.get_error(); - auto err_msg = err.get_message(); - std::cerr<<"[Error]: "<<err.get_category(); - - if(not err_msg.empty()){ - std::cerr<<" - "<<err_msg; - } - std::cerr<<std::endl; - - return err.get_id(); - } - - return 0; -} diff --git a/examples/heterogeneous_computing/sim.cpp b/examples/heterogeneous_computing/sim.cpp new file mode 100644 index 0000000..d074ad8 --- /dev/null +++ b/examples/heterogeneous_computing/sim.cpp @@ -0,0 +1,96 @@ +#include <forstio/error.hpp> +#include <iostream> + +#include <kel/lbm/lbm.hpp> + +namespace kel { +namespace lbm { +namespace sch { +using namespace saw::schema; + +/** + * struct lbm_data { + * std::array<std::array<float,9>, 64u*64u> dfs; + * std::array<uint8_t, 64u*64u> info; + * }; + * + * which leads to the form + * + * template<uint64_t Dim, uint64_t Size> + * struct lbm_data { + * std::array<std::array<float,9>, Size*Size> dfs; + * std::array<uint8_t, Size*Size> info; + * }; + * + * which transferred into sycl requires us to go to + * + * template<uint64_t Dim, uint64_t Size> + * struct lbm_sycl_data { + * std::array<float,9>* dfs; + * uint8_t* info; + * }; + * + * in data form on host + * + * template<uint64_t Dim, uint64_t Size> + * using LbmData = Struct< + * Member<FixedArray<FixedArray<Float32,9u>, Size*Size>, "dfs">, + * Member<FixedArray<UInt8, Size*Size>, "info"> + * >; + * + * If we specialize the encode::Sycl<Encoding> data type, then we get + * With a helper class we can copy single values back and forth and the whole block is guaranteed + * to be allocated. And this one can be dynamic while the host definition might be compile time. + * + * template<...> + * class data<LbmData<...>,encode::Sycl<Encoding>> final { + * saw::data<sch::FixedArray<sch::UInt64,Dim>> meta; + * saw::data<FixedArray<Float32u,9>>* dfs; + * saw::data<UInt8>* info; + * }; + */ + +template<typename T, typename Desc> +using CellStruct = Struct< + Member<Chunk<FixedArray<T,Desc::Q>,Desc::D, "dfs">, + Member<FixedArray<T,Desc::Q>, "dfs_old">, + Member<UInt8, "info"> +>; + +} +template<typename T, typename Desc> +saw::error_or<void> simulate(int argc, char** argv, + const saw::data<sch::FixedArray<sch::UInt64,Desc::D>>& meta +{ + constexpr auto cell_size = sizeof(saw::data<sch::CellStruct<T,Desc>>); + + auto lbm_data = saw::heap<saw::data<sch::Chunk<CellStruct<>,Desc::D, 64u>>>{meta}; + + return saw::make_void(); +} + +} + +saw::error_or<void> lbm_main(int argc, char** argv){ + using namespace lbm; + return simulate<sch::Float64,sch::D2Q9>(argc, argv); +} +} + +int main(int argc, char** argv){ + auto eov = kel::lbm_main(argc, argv); + if(eov.is_error()){ + auto& err = eov.get_error(); + auto err_msg = err.get_message(); + std::cerr<<"[Error]: "<<err.get_category(); + + if(not err_msg.empty()){ + std::cerr<<" - "<<err_msg; + } + std::cerr<<std::endl; + + return err.get_id(); + } + + return 0; +} |
