From 5c9e64112e1f710e99790db4814eb2f0031dec34 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 12 Jul 2026 22:38:58 +0200 Subject: Adding poc ideas --- poc/mixed_precision/sim.cpp | 24 ++++++++++++++++++++++++ poc/triangle_stream/sim.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 poc/mixed_precision/sim.cpp create mode 100644 poc/triangle_stream/sim.cpp (limited to 'poc') diff --git a/poc/mixed_precision/sim.cpp b/poc/mixed_precision/sim.cpp new file mode 100644 index 0000000..c96d7d0 --- /dev/null +++ b/poc/mixed_precision/sim.cpp @@ -0,0 +1,24 @@ +void init(){ +} + +saw::error_or kmain(int argc, char** argv){ + using namespace kel; + + return saw::make_void(); +} + +int main(int argc, char** argv){ + auto eov = kmain(argc,argv); + if(eov.is_error()){ + auto& err = eov.get_error(); + + std::cerr<<"[Error]: "< kmain(int argc, char** argv){ + using namespace kel; + + return saw::make_void(); +} + +int main(int argc, char** argv){ + auto eov = kmain(argc,argv); + if(eov.is_error()){ + auto& err = eov.get_error(); + + std::cerr<<"[Error]: "< Date: Mon, 13 Jul 2026 15:04:22 +0200 Subject: poc work --- poc/triangle_stream/.nix/derivation.nix | 41 +++++++++++++++++ poc/triangle_stream/SConscript | 34 ++++++++++++++ poc/triangle_stream/SConstruct | 81 +++++++++++++++++++++++++++++++++ poc/triangle_stream/sim.cpp | 60 +++++++++++++++++++++++- 4 files changed, 214 insertions(+), 2 deletions(-) create mode 100644 poc/triangle_stream/.nix/derivation.nix create mode 100644 poc/triangle_stream/SConscript create mode 100644 poc/triangle_stream/SConstruct (limited to 'poc') diff --git a/poc/triangle_stream/.nix/derivation.nix b/poc/triangle_stream/.nix/derivation.nix new file mode 100644 index 0000000..c86fc0b --- /dev/null +++ b/poc/triangle_stream/.nix/derivation.nix @@ -0,0 +1,41 @@ +{ lib +, stdenv +, scons +, clang-tools +, forstio +, python3 +, pname +, version +, adaptive-cpp +, kel +}: + +stdenv.mkDerivation { + pname = pname + "-poc-" + "triangle_stream"; + inherit version; + src = ./..; + + nativeBuildInputs = [ + scons + clang-tools + python3 + ]; + + buildInputs = [ + forstio.core + forstio.async + forstio.codec + forstio.codec-unit + forstio.io + forstio.remote + forstio.remote-filesystem + forstio.codec-json + adaptive-cpp + kel.lbm.core + kel.lbm.sycl + ]; + + preferLocalBuild = true; + + outputs = [ "out" "dev" ]; +} diff --git a/poc/triangle_stream/SConscript b/poc/triangle_stream/SConscript new file mode 100644 index 0000000..992fc60 --- /dev/null +++ b/poc/triangle_stream/SConscript @@ -0,0 +1,34 @@ +#!/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, ['sim.cpp'], shared=False); +examples_env.poiseulle_2d_gpu = examples_env.Program('#bin/kel_lbm_triangle_stream', [examples_objects]); + +# Set Alias +env.examples = [ + examples_env.poiseulle_2d_gpu +]; +env.Alias('examples', env.examples); +env.targets += ['examples']; +env.Install('$prefix/bin/', env.examples); diff --git a/poc/triangle_stream/SConstruct b/poc/triangle_stream/SConstruct new file mode 100644 index 0000000..0611b67 --- /dev/null +++ b/poc/triangle_stream/SConstruct @@ -0,0 +1,81 @@ +#!/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' + ], + LIBS=[ + 'forstio-core', + 'forstio-async', + 'forstio-io' + ] +); +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/poc/triangle_stream/sim.cpp b/poc/triangle_stream/sim.cpp index c96d7d0..36986e4 100644 --- a/poc/triangle_stream/sim.cpp +++ b/poc/triangle_stream/sim.cpp @@ -1,14 +1,70 @@ +#include + +namespace kel { +namespace lbm { + +constexpr uint64_t dim_y = 256ul; +constexpr uint64_t dim_x = dim_y * 20ul; + +namespace sch { +using namespace saw::schema; + +using InfoChunk = Chunk; + +template +using DfChunk = Chunk, 1u, dim_x, dim_y>; + +template +using ScalarChunk = Chunk, 0u, dim_x, dim_y>; + +template +using VectorChunk = Chunk, 0u, dim_x, dim_y>; + +template +using ChunkStruct = Struct< + Member, + Member, "dfs">, + Member, "dfs_old"> +>; + +template +using VelChunk = Chunk, 0u, dim_x, dim_y>; + +template +using RhoChunk = Chunk, 0u, dim_x, dim_y>; + +template +using MacroStruct = Struct< + Member, "velocity">, + Member, "density"> +>; + +//template +//using ParticleArray = Array< +// Particle +//>; +} + +template void init(){ } +template saw::error_or kmain(int argc, char** argv){ - using namespace kel; + using dfi = df_info; + + (void) argc; + (void) argv; return saw::make_void(); } +} +} + int main(int argc, char** argv){ - auto eov = kmain(argc,argv); + using namespace kel::lbm; + auto eov = kmain(argc,argv); if(eov.is_error()){ auto& err = eov.get_error(); -- cgit v1.2.3