From e821d617802ebbfff756844e4d9720342fc78a4e Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 13 Nov 2026 14:12:49 +0100 Subject: Swarm POC --- examples/particles_gpu/.nix/derivation.nix | 37 -------- examples/particles_gpu/SConscript | 34 -------- examples/particles_gpu/SConstruct | 82 ----------------- examples/particles_gpu/particles_gpu.cpp | 136 ----------------------------- 4 files changed, 289 deletions(-) delete mode 100644 examples/particles_gpu/.nix/derivation.nix delete mode 100644 examples/particles_gpu/SConscript delete mode 100644 examples/particles_gpu/SConstruct delete mode 100644 examples/particles_gpu/particles_gpu.cpp (limited to 'examples/particles_gpu') diff --git a/examples/particles_gpu/.nix/derivation.nix b/examples/particles_gpu/.nix/derivation.nix deleted file mode 100644 index 6ab8825..0000000 --- a/examples/particles_gpu/.nix/derivation.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ lib -, stdenv -, scons -, clang-tools -, forstio -, python3 -, pname -, version -, kel -, adaptive-cpp -}: - -stdenv.mkDerivation { - pname = pname + "-examples-" + "particles"; - inherit version; - src = ./..; - - nativeBuildInputs = [ - scons - clang-tools - python3 - ]; - - buildInputs = [ - forstio.core - forstio.async - forstio.codec - forstio.codec-unit - forstio.codec-json - kel.lbm.core - adaptive-cpp - ]; - - preferLocalBuild = true; - - outputs = [ "out" "dev" ]; -} diff --git a/examples/particles_gpu/SConscript b/examples/particles_gpu/SConscript deleted file mode 100644 index f22fdf2..0000000 --- a/examples/particles_gpu/SConscript +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/false - -import os -import os.path -import glob - - -Import('env') - -dir_path = Dir('.').abspath - -# Environment for base library -examples_env = env.Clone(); -examples_env['CXX'] = 'syclcc-clang'; -examples_env['CXXFLAGS'] += ['-O3']; - -examples_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) -examples_env.headers = sorted(glob.glob(dir_path + "/*.hpp")) - -env.sources += examples_env.sources; -env.headers += examples_env.headers; - -# Cavity2D -examples_objects = []; -examples_env.add_source_files(examples_objects, ['particles_gpu.cpp'], shared=False); -examples_env.particles_gpu = examples_env.Program('#bin/particles_gpu', [examples_objects]); - -# Set Alias -env.examples = [ - examples_env.particles_gpu -]; -env.Alias('examples', env.examples); -env.targets += ['examples']; -env.Install('$prefix/bin/', env.examples); diff --git a/examples/particles_gpu/SConstruct b/examples/particles_gpu/SConstruct deleted file mode 100644 index fe206e1..0000000 --- a/examples/particles_gpu/SConstruct +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -import os.path -import glob -import re - - -if sys.version_info < (3,): - def isbasestring(s): - return isinstance(s,basestring) -else: - def isbasestring(s): - return isinstance(s, (str,bytes)) - -def add_kel_source_files(self, sources, filetype, lib_env=None, shared=False, target_post=""): - - if isbasestring(filetype): - dir_path = self.Dir('.').abspath - filetype = sorted(glob.glob(dir_path+"/"+filetype)) - - for path in filetype: - target_name = re.sub( r'(.*?)(\.cpp|\.c\+\+)', r'\1' + target_post, path ) - if shared: - target_name+='.os' - sources.append( self.SharedObject( target=target_name, source=path ) ) - else: - target_name+='.o' - sources.append( self.StaticObject( target=target_name, source=path ) ) - pass - -def isAbsolutePath(key, dirname, env): - assert os.path.isabs(dirname), "%r must have absolute path syntax" % (key,) - -env_vars = Variables( - args=ARGUMENTS -) - -env_vars.Add('prefix', - help='Installation target location of build results and headers', - default='/usr/local/', - validator=isAbsolutePath -) - -env_vars.Add('build_examples', - help='If examples should be built', - default="true" -) - -env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[], - CPPDEFINES=['SAW_UNIX'], - CXXFLAGS=[ - '-std=c++20', - '-g', - '-Wall', - '-Wextra', - '-isystem', 'AdaptiveCpp' - ], - LIBS=[ - 'forstio-core', - 'acpp-rt', - 'omp' - ] -); -env.__class__.add_source_files = add_kel_source_files -env.Tool('compilation_db'); -env.cdb = env.CompilationDatabase('compile_commands.json'); - -env.objects = []; -env.sources = []; -env.headers = []; -env.targets = []; - -Export('env') -SConscript('SConscript') - -env.Alias('cdb', env.cdb); -env.Alias('all', [env.targets]); -env.Default('all'); - -env.Alias('install', '$prefix') diff --git a/examples/particles_gpu/particles_gpu.cpp b/examples/particles_gpu/particles_gpu.cpp deleted file mode 100644 index 94ec5f1..0000000 --- a/examples/particles_gpu/particles_gpu.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include -#include - - -#include -#include - -namespace kel{ -namespace lbm { -namespace sch { -} -} - -kel::lbm::error_or lbm_main(int argc, char** argv){ - (void) argc; - (void) argv; - - using namespace lbm; - using namespace acpp; - - kel::lbm::data>> particles{1024u}; - - for(kel::lbm::data i{0u}; i < kel::lbm::data{32u}; ++i){ - for(kel::lbm::data j{0u}; j < kel::lbm::data{32u}; ++j){ - - auto& part = particles.at(i*32ul+j); - auto& body = part.template get<"rigid_body">(); - - auto& pos = body.template get<"position">(); - auto& old_pos = body.template get<"position_old">(); - auto& acceleration = body.template get<"acceleration">(); - auto& p_rad = part.template get<"collision">().template get<"radius">(); - // Scalar base, so the value goes through the element rather than a - // braced whole-unit assignment. - p_rad.at({}).set(0.4f); - - if(j.get() % 2u == 0) acceleration.at({{1u}}) = {-9.81}; - - pos.at({{0u}}) = {i.template cast_to()+0.5f}; - pos.at({{1u}}) = {j.template cast_to()+64.0f}; - - old_pos = pos; - } - } - - // A timestep is a lattice time, which makes (pos - pos_old)/time_step a - // velocity rather than an unlabelled vector. - kel::lbm::data>> time_step; - time_step.at({}).set(0.05f); - - for(kel::lbm::data dt{0u}; dt < kel::lbm::data{32ul}; ++dt){ - // Do Verlet Step - for(kel::lbm::data i{0u}; i < particles.size(); ++i){ - auto& part_i = particles.at(i); - - verlet_step_lambda(part_i,time_step); - auto& body_i = part_i.template get<"rigid_body">(); - auto& acc_i = body_i.template get<"acceleration">(); - - acc_i.at({{0u}}) = 0.0; - acc_i.at({{1u}}) = -9.81; - } - - // - for(kel::lbm::data i{0u}; i < particles.size(); ++i){ - auto& part_i = particles.at(i); - auto& body_i = part_i.template get<"rigid_body">(); - auto& pos_i = body_i.template get<"position">(); - auto& pos_old_i = body_i.template get<"position_old">(); - /** - * Test against other particles - */ - for(kel::lbm::data j{i+1ul}; j < particles.size(); ++j){ - auto& part_j = particles.at(j); - auto& body_j = part_j.template get<"rigid_body">(); - auto& pos_j = body_j.template get<"position">(); - auto& pos_old_j = body_j.template get<"position_old">(); - - auto res = broadphase_collision_distance_squared(part_i, part_j); - if(res.first){ - //std::cout<<"Collision"<= 40 ){ - auto pos_i_0 = pos_i.at({{0u}}); - pos_i.at({{0u}}) = pos_old_i.at({{0u}}); - pos_old_i.at({{0u}}) = pos_i_0; - } - if(pos_i.at({{1u}}).get() <= 0 ){ - auto pos_i_1 = pos_i.at({{1u}}); - pos_i.at({{1u}}) = pos_old_i.at({{1u}}); - pos_old_i.at({{1u}}) = pos_i_1; - } - } - auto& pos = particles.at({0u}).template get<"rigid_body">().template get<"position">(); - - std::cout< 0u){ - std::cerr<<" - "<