summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix25
-rw-r--r--modules/codec/c++/rpc.hpp4
-rw-r--r--modules/codec/c++/schema.hpp8
-rw-r--r--modules/remote-opencl/.nix/derivation.nix29
-rw-r--r--modules/remote-opencl/SConstruct71
-rw-r--r--modules/remote-opencl/c++/SConscript38
-rw-r--r--modules/remote-opencl/c++/device.hpp14
-rw-r--r--modules/remote-opencl/c++/remote.hpp40
-rw-r--r--modules/remote-opencl/c++/rpc.hpp44
-rw-r--r--modules/remote-opencl/tests/SConscript31
10 files changed, 294 insertions, 10 deletions
diff --git a/default.nix b/default.nix
index f6a372b..ef36e43 100644
--- a/default.nix
+++ b/default.nix
@@ -63,7 +63,14 @@ in rec {
inherit forstio;
inherit stdenv;
inherit clang-tools;
- };
+ };
+
+ remote-opencl = pkgs.callPackage modules/remote-opencl/.nix/derivation.nix {
+ inherit version;
+ inherit forstio;
+ inherit stdenv;
+ inherit clang-tools;
+ };
tools = pkgs.callPackage modules/tools/.nix/derivation.nix {
inherit version;
@@ -75,7 +82,7 @@ in rec {
};
};
- all = pkgs.symlinkJoin {
+ stable = pkgs.symlinkJoin {
name = "forstio-${version}";
paths = [
forstio.core
@@ -85,6 +92,16 @@ in rec {
forstio.codec-netcdf
forstio.io
forstio.io-tls
- ];
- };
+ ];
+ };
+
+ unstable = pkgs.symlinkJoin {
+ name = "forstio-unstable-${version}";
+ paths = [
+ forstio.remote-opencl
+ # forstio.codec-minecraft
+ ];
+ };
+
+
}
diff --git a/modules/codec/c++/rpc.hpp b/modules/codec/c++/rpc.hpp
index 6b606e2..5f29f6e 100644
--- a/modules/codec/c++/rpc.hpp
+++ b/modules/codec/c++/rpc.hpp
@@ -3,7 +3,7 @@
namespace saw {
/**
- *
+ * Representing data on the remote
*/
template<typename T, typename Remote>
class remote_data {
@@ -75,7 +75,7 @@ class remote_address {
* Reference Backend structure
*/
template<typename T>
-class remote_api {
+class remote {
static_assert(always_false<T>, "Type of backend not supported");
/**
diff --git a/modules/codec/c++/schema.hpp b/modules/codec/c++/schema.hpp
index 3d20c10..5a2f440 100644
--- a/modules/codec/c++/schema.hpp
+++ b/modules/codec/c++/schema.hpp
@@ -5,6 +5,10 @@
#include <forstio/string_literal.hpp>
namespace saw {
+template <class T> struct is_primitive {
+ constexpr static bool value = false;
+};
+
namespace schema {
// NOLINTBEGIN
template <typename T, string_literal Literal> struct Member {
@@ -262,10 +266,6 @@ template <class T, size_t Dim> struct is_array<schema::Array<T,Dim>> {
constexpr static bool value = true;
};
-template <class T> struct is_primitive {
- constexpr static bool value = false;
-};
-
template <typename T, size_t N> struct is_primitive<schema::Primitive<T,N>> {
constexpr static bool value = true;
};
diff --git a/modules/remote-opencl/.nix/derivation.nix b/modules/remote-opencl/.nix/derivation.nix
new file mode 100644
index 0000000..564a27f
--- /dev/null
+++ b/modules/remote-opencl/.nix/derivation.nix
@@ -0,0 +1,29 @@
+{ lib
+, stdenv
+, scons
+, clang-tools
+, version
+, forstio
+}:
+
+let
+
+in stdenv.mkDerivation {
+ pname = "forstio-device-opencl";
+ inherit version;
+ src = ./..;
+
+ enableParallelBuilding = true;
+
+ nativeBuildInputs = [
+ scons
+ clang-tools
+ ];
+
+ buildInputs = [
+ forstio.core
+ forstio.codec
+ ];
+
+ outputs = ["out" "dev"];
+}
diff --git a/modules/remote-opencl/SConstruct b/modules/remote-opencl/SConstruct
new file mode 100644
index 0000000..c5b2bb4
--- /dev/null
+++ b/modules/remote-opencl/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-opencl/c++/SConscript b/modules/remote-opencl/c++/SConscript
new file mode 100644
index 0000000..b66ce79
--- /dev/null
+++ b/modules/remote-opencl/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-opencl/c++/device.hpp b/modules/remote-opencl/c++/device.hpp
new file mode 100644
index 0000000..7176004
--- /dev/null
+++ b/modules/remote-opencl/c++/device.hpp
@@ -0,0 +1,14 @@
+#pragma once
+
+namespace saw {
+namespace rmt {
+struct OpenCl{};
+}
+template<typename T>
+struct backend;
+
+struct backend<dev::Hip> {
+};
+
+
+}
diff --git a/modules/remote-opencl/c++/remote.hpp b/modules/remote-opencl/c++/remote.hpp
new file mode 100644
index 0000000..4ece821
--- /dev/null
+++ b/modules/remote-opencl/c++/remote.hpp
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <CL/cl.hpp>
+
+namespace saw {
+namespace rmt {
+struct OpenCl {};
+}
+
+template<>
+class remote_api<rmt::OpenCl> {
+private:
+ SAW_FORBID_COPY(remote_ctx);
+ SAW_FORBID_MOVE(remote_ctx);
+public:
+ remote_api(){}
+
+ error_or<void> create_remote(){
+ return remote<rmt::OpenCl>{*this};
+ }
+};
+
+template<>
+struct remote<rmt::OpenCl> {
+private:
+ remote_ctx<rmt::OpenCl>* ctx_;
+
+ SAW_FORBID_COPY(remote);
+ SAW_FORBID_MOVE(remote);
+public:
+ remote(remote_ctx<rmt::OpenCl>& r_ctx):
+ ctx_{&r_ctx}
+ {}
+
+ /*
+ template<typename Iface>
+ error_or<void> foo();
+ */
+};
+}
diff --git a/modules/remote-opencl/c++/rpc.hpp b/modules/remote-opencl/c++/rpc.hpp
new file mode 100644
index 0000000..bddb60d
--- /dev/null
+++ b/modules/remote-opencl/c++/rpc.hpp
@@ -0,0 +1,44 @@
+#pragma once
+
+namespace saw {
+namespace rmt {
+struct DeviceKokkos {};
+}
+
+template<>
+class remote<rmt::DeviceKokkos> {
+private:
+public:
+ template<typename Iface>
+ error_or<rpc_client<rmt::DeviceKokkos, Iface>> connect(){
+ return make_error<err::not_implemented>();
+ }
+};
+
+error_or<remote<rmt::DeviceKokkos>> create_remote(){
+ auto rc = hipInit(0);
+
+ return make_error<err::not_implemented>();
+}
+
+template<typename Iface>
+class rpc_client<rmt::DeviceKokkos, Iface> {
+public:
+ template<typename... T>
+ struct request {
+ std::tuple<id<T>...> ids;
+
+ error_or<data<schema::Tuple<T...>>> wait();
+ };
+};
+
+template<typename Iface>
+class rpc_server<rmt::DeviceKokkos, Iface> {
+private:
+ /**
+ * Needs a variant ptr of all possible return types
+ */
+ struct data_storage {
+ };
+};
+}
diff --git a/modules/remote-opencl/tests/SConscript b/modules/remote-opencl/tests/SConscript
new file mode 100644
index 0000000..f8ffc92
--- /dev/null
+++ b/modules/remote-opencl/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'];