diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-21 10:57:58 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-21 10:57:58 +0100 |
| commit | ec90ff981b016800a964135f049c9be53ba98615 (patch) | |
| tree | 6e702cdf5fb178f5275915b32fcb1c715c8339c8 | |
| parent | 952940c3487856447bb80c819b61483b8028d027 (diff) | |
| download | libs-lbm-ec90ff981b016800a964135f049c9be53ba98615.tar.gz | |
More sycl things
| -rw-r--r-- | lib/core/tests/chunk.cpp | 2 | ||||
| -rw-r--r-- | lib/sycl/.nix/derivation.nix | 2 | ||||
| -rw-r--r-- | lib/sycl/SConstruct | 80 | ||||
| -rw-r--r-- | lib/sycl/c++/SConscript | 32 | ||||
| -rw-r--r-- | lib/sycl/c++/data.hpp | 6 | ||||
| -rw-r--r-- | lib/sycl/tests/SConscript | 32 | ||||
| -rw-r--r-- | lib/sycl/tests/data.cpp | 6 |
7 files changed, 156 insertions, 4 deletions
diff --git a/lib/core/tests/chunk.cpp b/lib/core/tests/chunk.cpp index a9d1748..008d4c6 100644 --- a/lib/core/tests/chunk.cpp +++ b/lib/core/tests/chunk.cpp @@ -34,7 +34,7 @@ SAW_TEST("Chunk Ghost size 3"){ SAW_EXPECT((std::is_same_v<TestChunk::InnerSchema,TestArray>), "Types are not identical"); } -SAW_TEST("Chunk setup"){ +SAW_TEST("Chunk 2D setup"){ using namespace kel; using TestChunk = lbm::sch::Chunk<sch::Float32, 1u, 2u, 2u>; diff --git a/lib/sycl/.nix/derivation.nix b/lib/sycl/.nix/derivation.nix index 02032ba..4422739 100644 --- a/lib/sycl/.nix/derivation.nix +++ b/lib/sycl/.nix/derivation.nix @@ -26,7 +26,7 @@ stdenv.mkDerivation { forstio.codec-unit forstio.codec-json forstio.remote - forstio.remote-sycl + #forstio.remote-sycl kel.lbm.core adaptive-cpp ]; diff --git a/lib/sycl/SConstruct b/lib/sycl/SConstruct new file mode 100644 index 0000000..f8bfbcb --- /dev/null +++ b/lib/sycl/SConstruct @@ -0,0 +1,80 @@ +#!/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=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[], + CPPDEFINES=['SAW_UNIX'], + CXX = ['syclcc-clang'], + CXXFLAGS=[ + '-std=c++20', + '-g', + '-O3', + '-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('c++/SConscript') +SConscript('tests/SConscript') + +env.Alias('cdb', env.cdb); +env.Alias('all', [env.targets]); +env.Default('all'); + +env.Alias('install', '$prefix') diff --git a/lib/sycl/c++/SConscript b/lib/sycl/c++/SConscript new file mode 100644 index 0000000..85a078f --- /dev/null +++ b/lib/sycl/c++/SConscript @@ -0,0 +1,32 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +core_env = env.Clone(); + +core_env.sources = sorted(glob.glob(dir_path + "/*.cpp")); +core_env.headers = sorted(glob.glob(dir_path + "/*.hpp")); + +core_env.particle_headers = sorted(glob.glob(dir_path + "/particle/*.hpp")); +core_env.particle_geometry_headers = sorted(glob.glob(dir_path + "/particle/geometry/*.hpp")); + +env.sources += core_env.sources; +env.headers += core_env.headers; + +## Static lib +objects = [] +core_env.add_source_files(objects, core_env.sources, shared=False); +env.library_static = core_env.StaticLibrary('#build/kel-lbm', [objects]); + +env.Install('$prefix/lib/', env.library_static); +env.Install('$prefix/include/kel/lbm/', core_env.headers); +env.Install('$prefix/include/kel/lbm/particle/', core_env.particle_headers); +env.Install('$prefix/include/kel/lbm/particle/geometry/', core_env.particle_geometry_headers); diff --git a/lib/sycl/c++/data.hpp b/lib/sycl/c++/data.hpp index bba52d6..44bc5dc 100644 --- a/lib/sycl/c++/data.hpp +++ b/lib/sycl/c++/data.hpp @@ -18,11 +18,11 @@ struct struct_has_only_equal_dimension_array{}; } namespace saw { -template<uint64_t... Meta, typename... Sch, string_literal... Keys, typename Encode> +template<uint64_t Ghost, uint64_t... Meta, typename... Sch, string_literal... Keys, typename Encode> class data<schema::Struct<schema::Member<schema::Chunk<Sch,Ghost,Meta...>, Keys>...>, kel::lbm::encode::Sycl<Encode>> final { public: static constexpr data<schema::FixedArray meta = {{Meta...}}; - using StorageT = std::tuple<data<Members::Type::InnerSchema,Encode>*...>; + using StorageT = std::tuple<data<Sch,Encode>*...>; private: /** @@ -81,6 +81,8 @@ struct sycl_malloc_struct_helper<sch::Struct<Members...>, Encode> final { if constexpr (i < sizeof...(Members)){ using M = typename saw::parameter_pack_type<i,Members...>::type; auto& ptr = std::get<i>(storage); + + ptr = sycl::malloc_device<M::ValueType::InnerSchema>(,q); return allocate_on_device_member<i+1u>(storage,q); diff --git a/lib/sycl/tests/SConscript b/lib/sycl/tests/SConscript new file mode 100644 index 0000000..d1b381e --- /dev/null +++ b/lib/sycl/tests/SConscript @@ -0,0 +1,32 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +test_cases_env = env.Clone(); + +test_cases_env.Append(LIBS=['forstio-test']); + +test_cases_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) +test_cases_env.headers = sorted(glob.glob(dir_path + "/*.hpp")) + +env.sources += test_cases_env.sources; +env.headers += test_cases_env.headers; + +objects_static = [] +test_cases_env.add_source_files(objects_static, test_cases_env.sources, shared=False); +test_cases_env.program = test_cases_env.Program('#bin/tests', [objects_static]); +# , env.library_static]); + +# Set Alias +env.Alias('test', test_cases_env.program); +env.Alias('check', test_cases_env.program); + +env.targets += ['test','check']; diff --git a/lib/sycl/tests/data.cpp b/lib/sycl/tests/data.cpp new file mode 100644 index 0000000..e57a1e3 --- /dev/null +++ b/lib/sycl/tests/data.cpp @@ -0,0 +1,6 @@ +#include <forstio/test/suite.hpp> + + +SAW_TEST("Sycl Dummy"){ + +} |
