From c59aeef2e0c86ec3f0f34ce77c205f3ef0b034cc Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 8 Nov 2026 22:04:06 +0100 Subject: Abstract move. Forstio independence --- examples/cavity_2d_gpu/cavity_2d_gpu.cpp | 61 ++++++++++++++++---------------- 1 file changed, 30 insertions(+), 31 deletions(-) (limited to 'examples/cavity_2d_gpu/cavity_2d_gpu.cpp') diff --git a/examples/cavity_2d_gpu/cavity_2d_gpu.cpp b/examples/cavity_2d_gpu/cavity_2d_gpu.cpp index fe44baf..ab1ab40 100644 --- a/examples/cavity_2d_gpu/cavity_2d_gpu.cpp +++ b/examples/cavity_2d_gpu/cavity_2d_gpu.cpp @@ -12,7 +12,6 @@ namespace kel { namespace lbm { namespace sch { -using namespace saw::schema; /** * Basic distribution function @@ -71,9 +70,9 @@ class df_cell_view, Encode> { public: using Schema = sch::Cell; private: - std::array::type>*, QN> view_; + std::array::type>*, QN> view_; public: - df_cell_view(const std::array::type>*, QN>& view): + df_cell_view(const std::array::type>*, QN>& view): view_{view} {} }; @@ -89,11 +88,11 @@ struct MovingWall {}; template class component { public: - std::array::type, Desc::D> lid_vel; + std::array::type, Desc::D> lid_vel; public: void apply( - saw::data>& dfs + kel::lbm::data>& dfs ){ using dfi = df_info; @@ -113,15 +112,15 @@ constexpr size_t dim_y = 128; template void set_geometry( - saw::data>* info_field + kel::lbm::data>* info_field ){ using namespace kel::lbm; using namespace acpp; - saw::data> meta{{dim_x,dim_y}}; + kel::lbm::data> meta{{dim_x,dim_y}}; /** * Set ghost */ - iterate_over([&](const saw::data>& index){ + iterate_over([&](const kel::lbm::data>& index){ size_t i = index.at({0u}).get() * dim_x + index.at({1u}).get(); auto& info = info_field[i]; @@ -132,7 +131,7 @@ void set_geometry( /** * Set wall */ - iterate_over([&](const saw::data>& index){ + iterate_over([&](const kel::lbm::data>& index){ size_t i = index.at({0u}).get() * dim_x + index.at({1u}).get(); auto& info = info_field[i]; @@ -143,7 +142,7 @@ void set_geometry( /** * Set fluid */ - iterate_over([&](const saw::data>& index){ + iterate_over([&](const kel::lbm::data>& index){ size_t i = index.at({0u}).get() * dim_x + index.at({1u}).get(); auto& info = info_field[i]; @@ -154,7 +153,7 @@ void set_geometry( /** * Set top lid */ - iterate_over([&](const saw::data>& index){ + iterate_over([&](const kel::lbm::data>& index){ size_t i = index.at({0u}).get() * dim_x + index.at({1u}).get(); auto& info = info_field[i]; info({0u}).set(3u); @@ -164,27 +163,27 @@ void set_geometry( template void set_initial_conditions( - saw::data>* info_field, - saw::data>* dfs_field, - saw::data>* dfs_old_field + kel::lbm::data>* info_field, + kel::lbm::data>* dfs_field, + kel::lbm::data>* dfs_old_field ){ using namespace kel::lbm; using namespace acpp; - saw::data rho{1.0}; - saw::data> vel{{0.0,0.0}}; + kel::lbm::data rho{1.0}; + kel::lbm::data> vel{{0.0,0.0}}; auto eq = equilibrium(rho, vel); - saw::data> meta{{dim_x,dim_y}}; + kel::lbm::data> meta{{dim_x,dim_y}}; /** * Set distribution */ - iterate_over([&](const saw::data>& index){ + iterate_over([&](const kel::lbm::data>& index){ size_t i = index.at({0u}).get() * dim_x + index.at({1u}).get(); auto& dfs = dfs_field[i]; auto& dfs_old = dfs_old_field[i]; - for(saw::data k = 0; k < saw::data{Desc::Q}; ++k){ + for(kel::lbm::data k = 0; k < kel::lbm::data{Desc::Q}; ++k){ dfs(k) = eq.at(k); dfs_old(k) = eq.at(k); } @@ -194,9 +193,9 @@ void set_initial_conditions( template void lbm_step( - saw::data>* info_r, - saw::data>* dfs_r, - saw::data>* dfs_r_old, + kel::lbm::data>* info_r, + kel::lbm::data>* dfs_r, + kel::lbm::data>* dfs_r_old, bool is_even, uint64_t time_step, acpp::sycl::queue& sycl_q @@ -207,7 +206,7 @@ void lbm_step( using dfi = df_info; //component coll{0.59}; - constexpr saw::data frequency{1.0 / 0.59}; + constexpr kel::lbm::data frequency{1.0 / 0.59}; //component bb; component bb_lid; bb_lid.lid_vel = {0.1, 0.0}; @@ -243,8 +242,8 @@ void lbm_step( // coll.apply(latt_acc, {i, j}, time_step); auto& dfs_old = is_even ? dfs_r_old[acc_id] : dfs_r[acc_id]; - saw::data rho; - saw::data> vel; + kel::lbm::data rho; + kel::lbm::data> vel; compute_rho_u(dfs_old,rho,vel); auto eq = equilibrium(rho,vel); @@ -302,7 +301,7 @@ int main(){ using namespace kel::lbm; using namespace acpp; - saw::data> meta{{dim_x, dim_y}}; + kel::lbm::data> meta{{dim_x, dim_y}}; constexpr size_t dim_size = dim_x * dim_y; converter conv{ @@ -324,9 +323,9 @@ int main(){ constexpr size_t num_cells = dim_x * dim_y; // Allocate USM shared memory for your main data - auto* info = sycl::malloc_shared>>(num_cells, sycl_q); - auto* dfs = sycl::malloc_shared>>(num_cells, sycl_q); - auto* dfs_old = sycl::malloc_shared>>(num_cells, sycl_q); + auto* info = sycl::malloc_shared>>(num_cells, sycl_q); + auto* dfs = sycl::malloc_shared>>(num_cells, sycl_q); + auto* dfs_old = sycl::malloc_shared>>(num_cells, sycl_q); /** * Set meta information describing what this cell is @@ -347,7 +346,7 @@ int main(){ uint64_t print_every = 256u; uint64_t file_no = 0u; - saw::data,sch::D2Q9::D>> macros{meta}; + kel::lbm::data,sch::D2Q9::D>> macros{meta}; std::cout<<"Start"<(info, dfs, dfs_old, even_step, i, sycl_q); if(i % 1024u == 0u){ sycl_q.wait(); - iterate_over([&](const saw::data>& index){ + iterate_over([&](const kel::lbm::data>& index){ size_t j = index.at({0u}).get() * dim_x + index.at({1u}).get(); auto dfs_field = even_step ? dfs_old : dfs; -- cgit v1.3.1