From 6f2cabfa4311eb71d70ec03a0a46b9ab55fd0820 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 28 Jan 2024 16:03:29 +0100 Subject: device-hip, remote-kokkos: Moving to kokkos. Easier to manage --- modules/device-hip/.nix/derivation.nix | 30 ------------- modules/device-hip/SConstruct | 71 ------------------------------- modules/device-hip/c++/SConscript | 38 ----------------- modules/device-hip/c++/rpc.hpp | 47 -------------------- modules/device-hip/tests/SConscript | 31 -------------- modules/remote-kokkos/.nix/derivation.nix | 30 +++++++++++++ modules/remote-kokkos/SConstruct | 71 +++++++++++++++++++++++++++++++ modules/remote-kokkos/c++/SConscript | 38 +++++++++++++++++ modules/remote-kokkos/c++/device.hpp | 14 ++++++ modules/remote-kokkos/c++/remote.hpp | 48 +++++++++++++++++++++ modules/remote-kokkos/c++/rpc.hpp | 47 ++++++++++++++++++++ modules/remote-kokkos/tests/SConscript | 31 ++++++++++++++ 12 files changed, 279 insertions(+), 217 deletions(-) delete mode 100644 modules/device-hip/.nix/derivation.nix delete mode 100644 modules/device-hip/SConstruct delete mode 100644 modules/device-hip/c++/SConscript delete mode 100644 modules/device-hip/c++/rpc.hpp delete mode 100644 modules/device-hip/tests/SConscript create mode 100644 modules/remote-kokkos/.nix/derivation.nix create mode 100644 modules/remote-kokkos/SConstruct create mode 100644 modules/remote-kokkos/c++/SConscript create mode 100644 modules/remote-kokkos/c++/device.hpp create mode 100644 modules/remote-kokkos/c++/remote.hpp create mode 100644 modules/remote-kokkos/c++/rpc.hpp create mode 100644 modules/remote-kokkos/tests/SConscript diff --git a/modules/device-hip/.nix/derivation.nix b/modules/device-hip/.nix/derivation.nix deleted file mode 100644 index dc9cd94..0000000 --- a/modules/device-hip/.nix/derivation.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ lib -, stdenv -, scons -, clang-tools -, version -, forstio -}: - -let - -in stdenv.mkDerivation { - pname = "forstio-device-hip"; - inherit version; - src = ./..; - - enableParallelBuilding = true; - - nativeBuildInputs = [ - scons - clang-tools - ]; - - buildInputs = [ - forstio.core - forstio.async - forstio.codec - ]; - - outputs = ["out" "dev"]; -} diff --git a/modules/device-hip/SConstruct b/modules/device-hip/SConstruct deleted file mode 100644 index c5b2bb4..0000000 --- a/modules/device-hip/SConstruct +++ /dev/null @@ -1,71 +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=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[], - CPPDEFINES=['SAW_UNIX'], - CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'], - LIBS=[ - 'forstio-core' - 'forstio-codec' - ] -); -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/modules/device-hip/c++/SConscript b/modules/device-hip/c++/SConscript deleted file mode 100644 index b66ce79..0000000 --- a/modules/device-hip/c++/SConscript +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/false - -import os -import os.path -import glob - - -Import('env') - -dir_path = Dir('.').abspath - -# Environment for base library -dev_hip_env = env.Clone(); - -dev_hip_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) -dev_hip_env.headers = sorted(glob.glob(dir_path + "/*.hpp")) - -env.sources += dev_hip_env.sources; -env.headers += dev_hip_env.headers; - -## Shared lib -objects_shared = [] -dev_hip_env.add_source_files(objects_shared, dev_hip_env.sources, shared=True); -env.library_shared = dev_hip_env.SharedLibrary('#build/forstio-device-hip', [objects_shared]); - -## Static lib -objects_static = [] -dev_hip_env.add_source_files(objects_static, dev_hip_env.sources, shared=False); -env.library_static = dev_hip_env.StaticLibrary('#build/forstio-device-hip', [objects_static]); - -# Set Alias -env.Alias('library_device-hip', [env.library_shared, env.library_static]); - -env.targets += ['library_device-hip']; - -# Install -env.Install('$prefix/lib/', [env.library_shared, env.library_static]); -env.Install('$prefix/include/forstio/device/hip/', [dev_hip_env.headers]); diff --git a/modules/device-hip/c++/rpc.hpp b/modules/device-hip/c++/rpc.hpp deleted file mode 100644 index 5bce553..0000000 --- a/modules/device-hip/c++/rpc.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include - -namespace saw { -namespace rmt { -struct DeviceHip {}; -} - -template<> -class remote { -private: -public: - template - error_or> connect(){ - return make_error(); - } -}; - -error_or> create_remote(){ - auto rc = hipInit(0); - - return make_error(); -} - -template -class rpc_client { -public: - template - struct request { - std::tuple...> ids; - - error_or>> wait(); - }; -}; - -template -class rpc_server { -private: - /** - * Needs a variant ptr of all possible return types - */ - struct data_storage { - }; - -}; -} diff --git a/modules/device-hip/tests/SConscript b/modules/device-hip/tests/SConscript deleted file mode 100644 index f8ffc92..0000000 --- a/modules/device-hip/tests/SConscript +++ /dev/null @@ -1,31 +0,0 @@ -#!/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/modules/remote-kokkos/.nix/derivation.nix b/modules/remote-kokkos/.nix/derivation.nix new file mode 100644 index 0000000..dc9cd94 --- /dev/null +++ b/modules/remote-kokkos/.nix/derivation.nix @@ -0,0 +1,30 @@ +{ lib +, stdenv +, scons +, clang-tools +, version +, forstio +}: + +let + +in stdenv.mkDerivation { + pname = "forstio-device-hip"; + inherit version; + src = ./..; + + enableParallelBuilding = true; + + nativeBuildInputs = [ + scons + clang-tools + ]; + + buildInputs = [ + forstio.core + forstio.async + forstio.codec + ]; + + outputs = ["out" "dev"]; +} diff --git a/modules/remote-kokkos/SConstruct b/modules/remote-kokkos/SConstruct new file mode 100644 index 0000000..c5b2bb4 --- /dev/null +++ b/modules/remote-kokkos/SConstruct @@ -0,0 +1,71 @@ +#!/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'], + CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'], + LIBS=[ + 'forstio-core' + 'forstio-codec' + ] +); +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/modules/remote-kokkos/c++/SConscript b/modules/remote-kokkos/c++/SConscript new file mode 100644 index 0000000..b66ce79 --- /dev/null +++ b/modules/remote-kokkos/c++/SConscript @@ -0,0 +1,38 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +dev_hip_env = env.Clone(); + +dev_hip_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) +dev_hip_env.headers = sorted(glob.glob(dir_path + "/*.hpp")) + +env.sources += dev_hip_env.sources; +env.headers += dev_hip_env.headers; + +## Shared lib +objects_shared = [] +dev_hip_env.add_source_files(objects_shared, dev_hip_env.sources, shared=True); +env.library_shared = dev_hip_env.SharedLibrary('#build/forstio-device-hip', [objects_shared]); + +## Static lib +objects_static = [] +dev_hip_env.add_source_files(objects_static, dev_hip_env.sources, shared=False); +env.library_static = dev_hip_env.StaticLibrary('#build/forstio-device-hip', [objects_static]); + +# Set Alias +env.Alias('library_device-hip', [env.library_shared, env.library_static]); + +env.targets += ['library_device-hip']; + +# Install +env.Install('$prefix/lib/', [env.library_shared, env.library_static]); +env.Install('$prefix/include/forstio/device/hip/', [dev_hip_env.headers]); diff --git a/modules/remote-kokkos/c++/device.hpp b/modules/remote-kokkos/c++/device.hpp new file mode 100644 index 0000000..6c84fe1 --- /dev/null +++ b/modules/remote-kokkos/c++/device.hpp @@ -0,0 +1,14 @@ +#pragma once + +namespace saw { +namespace dev { +struct Hip {}; +} +template +struct backend; + +struct backend { +}; + + +} diff --git a/modules/remote-kokkos/c++/remote.hpp b/modules/remote-kokkos/c++/remote.hpp new file mode 100644 index 0000000..549b9ec --- /dev/null +++ b/modules/remote-kokkos/c++/remote.hpp @@ -0,0 +1,48 @@ +#pragma once + +#include + +namespace saw { +namespace rmt { +struct Kokkos {}; +} + +template +struct remote; + +template +struct remote_ctx; + +template<> +class remote_ctx { +private: + Kokkos::ScopeGuard guard_; + + SAW_FORBID_COPY(remote_ctx); + SAW_FORBID_MOVE(remote_ctx); +public: + remote_ctx(Kokkos::InitializationSettings init_settings): + guard_{std::move(init_settings)} + {} + + error_or create_remote(){ + return remote{*this}; + } +}; + +template<> +struct remote { +private: + remote_ctx* ctx_; + + SAW_FORBID_COPY(remote); + SAW_FORBID_MOVE(remote); +public: + remote(remote_ctx& r_ctx): + ctx_{&r_ctx} + {} + + template + error +}; +} diff --git a/modules/remote-kokkos/c++/rpc.hpp b/modules/remote-kokkos/c++/rpc.hpp new file mode 100644 index 0000000..5bce553 --- /dev/null +++ b/modules/remote-kokkos/c++/rpc.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include + +namespace saw { +namespace rmt { +struct DeviceHip {}; +} + +template<> +class remote { +private: +public: + template + error_or> connect(){ + return make_error(); + } +}; + +error_or> create_remote(){ + auto rc = hipInit(0); + + return make_error(); +} + +template +class rpc_client { +public: + template + struct request { + std::tuple...> ids; + + error_or>> wait(); + }; +}; + +template +class rpc_server { +private: + /** + * Needs a variant ptr of all possible return types + */ + struct data_storage { + }; + +}; +} diff --git a/modules/remote-kokkos/tests/SConscript b/modules/remote-kokkos/tests/SConscript new file mode 100644 index 0000000..f8ffc92 --- /dev/null +++ b/modules/remote-kokkos/tests/SConscript @@ -0,0 +1,31 @@ +#!/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']; -- cgit v1.2.3