summaryrefslogtreecommitdiff
path: root/modules/remote-sycl
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-05-13 09:57:49 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-05-13 09:57:49 +0200
commit6b9e221a0c439ce3ee9b728bc9ead8f5c2c82ceb (patch)
tree49d70b45f0aa65e8e872ff76deccebd6c1f92198 /modules/remote-sycl
parent0f8abfb2d48497e804d87e6e47a41c70e728901a (diff)
renamed to sycl since opencl does not support c++
Diffstat (limited to 'modules/remote-sycl')
-rw-r--r--modules/remote-sycl/.nix/derivation.nix34
-rw-r--r--modules/remote-sycl/SConstruct75
-rw-r--r--modules/remote-sycl/c++/SConscript38
-rw-r--r--modules/remote-sycl/c++/remote.hpp42
-rw-r--r--modules/remote-sycl/tests/SConscript31
-rw-r--r--modules/remote-sycl/tests/calculator.cpp7
6 files changed, 227 insertions, 0 deletions
diff --git a/modules/remote-sycl/.nix/derivation.nix b/modules/remote-sycl/.nix/derivation.nix
new file mode 100644
index 0000000..2d095df
--- /dev/null
+++ b/modules/remote-sycl/.nix/derivation.nix
@@ -0,0 +1,34 @@
+{ lib
+, stdenv
+, scons
+, clang-tools
+, version
+, forstio
+, opencl-clhpp
+}:
+
+let
+
+in stdenv.mkDerivation {
+ pname = "forstio-device-opencl";
+ inherit version;
+ src = ./..;
+
+ enableParallelBuilding = true;
+
+ nativeBuildInputs = [
+ scons
+ clang-tools
+ ];
+
+ buildInputs = [
+ forstio.core
+ forstio.codec
+ forstio.async
+ forstio.io
+ forstio.io_codec
+ opencl-clhpp
+ ];
+
+ outputs = ["out" "dev"];
+}
diff --git a/modules/remote-sycl/SConstruct b/modules/remote-sycl/SConstruct
new file mode 100644
index 0000000..a27e6d7
--- /dev/null
+++ b/modules/remote-sycl/SConstruct
@@ -0,0 +1,75 @@
+#!/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',
+ 'forstio-async',
+ 'forstio-io',
+ 'forstio-io_codec',
+ 'OpenCL'
+ ]
+);
+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-sycl/c++/SConscript b/modules/remote-sycl/c++/SConscript
new file mode 100644
index 0000000..e902c22
--- /dev/null
+++ b/modules/remote-sycl/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_opencl_env = env.Clone();
+
+dev_opencl_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
+dev_opencl_env.headers = sorted(glob.glob(dir_path + "/*.hpp"))
+
+env.sources += dev_opencl_env.sources;
+env.headers += dev_opencl_env.headers;
+
+## Shared lib
+objects_shared = []
+dev_opencl_env.add_source_files(objects_shared, dev_opencl_env.sources, shared=True);
+env.library_shared = dev_opencl_env.SharedLibrary('#build/forstio-remote-opencl', [objects_shared]);
+
+## Static lib
+objects_static = []
+dev_opencl_env.add_source_files(objects_static, dev_opencl_env.sources, shared=False);
+env.library_static = dev_opencl_env.StaticLibrary('#build/forstio-remote-opencl', [objects_static]);
+
+# Set Alias
+env.Alias('library_remote_opencl', [env.library_shared, env.library_static]);
+
+env.targets += ['library_remote_opencl'];
+
+# Install
+env.Install('$prefix/lib/', [env.library_shared, env.library_static]);
+env.Install('$prefix/include/forstio/remote/opencl/', [dev_opencl_env.headers]);
diff --git a/modules/remote-sycl/c++/remote.hpp b/modules/remote-sycl/c++/remote.hpp
new file mode 100644
index 0000000..3073b23
--- /dev/null
+++ b/modules/remote-sycl/c++/remote.hpp
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <forstio/io_codec/rpc.hpp>
+
+namespace saw {
+namespace rmt {
+struct OpenCl {};
+}
+
+template<>
+class remote<rmt::OpenCl> {
+private:
+ SAW_FORBID_COPY(remote);
+ SAW_FORBID_MOVE(remote);
+public:
+ remote(){}
+
+ /*
+ error_or<void> create_remote(){
+ return remote<rmt::OpenCl>{*this};
+ }
+ */
+};
+
+template<>
+struct remote_address<rmt::OpenCl> {
+private:
+ remote<rmt::OpenCl>* ctx_;
+
+ SAW_FORBID_COPY(remote_address);
+ SAW_FORBID_MOVE(remote_address);
+public:
+ remote_address(remote<rmt::OpenCl>& r_ctx):
+ ctx_{&r_ctx}
+ {}
+
+ /*
+ template<typename Iface>
+ error_or<void> foo();
+ */
+};
+}
diff --git a/modules/remote-sycl/tests/SConscript b/modules/remote-sycl/tests/SConscript
new file mode 100644
index 0000000..f8ffc92
--- /dev/null
+++ b/modules/remote-sycl/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'];
diff --git a/modules/remote-sycl/tests/calculator.cpp b/modules/remote-sycl/tests/calculator.cpp
new file mode 100644
index 0000000..9ee1583
--- /dev/null
+++ b/modules/remote-sycl/tests/calculator.cpp
@@ -0,0 +1,7 @@
+#include <forstio/test/suite.hpp>
+
+#include "../c++/remote.hpp"
+
+SAW_TEST("OpenCl Calculator"){
+
+}