From 5fee9c698f5f1ebe6ef8bf07f5a75e04dab92681 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 9 Feb 2026 16:49:12 +0100 Subject: Add rar as dep and implement collision --- examples/poiseulle_2d_gpu/.nix/derivation.nix | 1 + .../poiseulle_particles_2d_gpu/.nix/derivation.nix | 5 ++-- examples/poiseulle_particles_2d_gpu/SConstruct | 4 +++- examples/poiseulle_particles_2d_gpu/sim.cpp | 28 +++++++++++++++++++++- 4 files changed, 34 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/poiseulle_2d_gpu/.nix/derivation.nix b/examples/poiseulle_2d_gpu/.nix/derivation.nix index 127243d..cc132ee 100644 --- a/examples/poiseulle_2d_gpu/.nix/derivation.nix +++ b/examples/poiseulle_2d_gpu/.nix/derivation.nix @@ -28,6 +28,7 @@ stdenv.mkDerivation { forstio.codec-unit forstio.remote forstio.codec-json + forstio.io adaptive-cpp kel.lbm.core # kel-lbm.sycl diff --git a/examples/poiseulle_particles_2d_gpu/.nix/derivation.nix b/examples/poiseulle_particles_2d_gpu/.nix/derivation.nix index e08f42a..517b6b8 100644 --- a/examples/poiseulle_particles_2d_gpu/.nix/derivation.nix +++ b/examples/poiseulle_particles_2d_gpu/.nix/derivation.nix @@ -26,8 +26,9 @@ stdenv.mkDerivation { forstio.async forstio.codec forstio.codec-unit - forstio.remote - forstio.remote-filesystem + forstio.io + forstio.remote + forstio.remote-filesystem forstio.codec-json adaptive-cpp kel.lbm.core diff --git a/examples/poiseulle_particles_2d_gpu/SConstruct b/examples/poiseulle_particles_2d_gpu/SConstruct index a7201cb..0611b67 100644 --- a/examples/poiseulle_particles_2d_gpu/SConstruct +++ b/examples/poiseulle_particles_2d_gpu/SConstruct @@ -57,7 +57,9 @@ env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[], '-Wextra' ], LIBS=[ - 'forstio-core' + 'forstio-core', + 'forstio-async', + 'forstio-io' ] ); env.__class__.add_source_files = add_kel_source_files diff --git a/examples/poiseulle_particles_2d_gpu/sim.cpp b/examples/poiseulle_particles_2d_gpu/sim.cpp index d14be91..42d8413 100644 --- a/examples/poiseulle_particles_2d_gpu/sim.cpp +++ b/examples/poiseulle_particles_2d_gpu/sim.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include @@ -36,6 +37,9 @@ using MacroStruct = Struct< Member, "velocity">, Member, "density"> >; + +// template +// using Particles = Particle< } template @@ -224,6 +228,22 @@ saw::error_or lbm_main(int argc, char** argv){ auto lbm_data_ptr = saw::heap>>(); auto lbm_macro_data_ptr = saw::heap>>(); + auto eo_aio = saw::setup_async_io(); + if(eo_aio.is_error()){ + return std::move(eo_aio.get_error()); + } + auto& aio = eo_aio.get_value(); + saw::wait_scope wait{aio.event_loop}; + + bool krun = true; + bool print_status = false; + aio.event_port.on_signal(saw::Signal::Terminate).then([&](){ + krun = false; + }).detach(); + aio.event_port.on_signal(saw::Signal::User1).then([&](){ + print_status = true; + }).detach(); + device dev; auto& sycl_q = dev.get_handle(); @@ -256,7 +276,7 @@ saw::error_or lbm_main(int argc, char** argv){ sycl_q.wait(); saw::data time_steps{4096ul}; - for(saw::data i{0u}; i < time_steps; ++i){ + for(saw::data i{0u}; i < time_steps and krun; ++i){ { std::string file_name = "tmp/t_"; file_name += std::to_string(i.get()); @@ -293,6 +313,12 @@ saw::error_or lbm_main(int argc, char** argv){ return eov; } } + + wait.poll(); + if(print_status){ + std::cout<<"Status: "<().get() * 100 / time_steps.get())<<"%"<