summaryrefslogtreecommitdiffhomepage
path: root/dev/lib
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-09-17 10:06:21 +0200
committerGitHub <noreply@github.com>2025-09-17 10:06:21 +0200
commit94799223495b9842bca67e1a6ecf611cec3ee771 (patch)
tree435f5b6adb6889462640b1456e684360cd7e495f /dev/lib
parent6789dd7d88a192e3f55b95798cb393e7d12f368a (diff)
parentfa4748e414e9494442f9bcde9c659d3951af19c0 (diff)
(SCL: v1.0.44) Merge pull request #1 from snu-systems-corp/dev
SCL: v1.0.44
Diffstat (limited to 'dev/lib')
-rw-r--r--dev/lib/core/error_handler.hpp4
-rw-r--r--dev/lib/fix/fix.hpp (renamed from dev/lib/fix/parser.hpp)0
-rw-r--r--dev/lib/io/print.hpp1
-rw-r--r--dev/lib/logic/opt.hpp17
-rw-r--r--dev/lib/net/url.hpp8
-rw-r--r--dev/lib/simd/basic_simd.hpp50
-rw-r--r--dev/lib/simd/simd.hpp60
7 files changed, 137 insertions, 3 deletions
diff --git a/dev/lib/core/error_handler.hpp b/dev/lib/core/error_handler.hpp
index 593e54a..1a1515d 100644
--- a/dev/lib/core/error_handler.hpp
+++ b/dev/lib/core/error_handler.hpp
@@ -9,6 +9,7 @@
#define _OCL_ERROR_HANDLER_HPP
#include <lib/core/includes.hpp>
+#include <lib/io/print.hpp>
#include <stdexcept>
namespace ocl
@@ -25,11 +26,12 @@ namespace ocl
virtual void operator()(const std::basic_string<char>& msg)
{
- ((void)msg);
+ ocl::io::print(msg);
}
};
using standard_error_handler = basic_error_handler;
+ using error_handler_type = basic_error_handler;
} // namespace ocl
#endif // ifndef _OCL_ERROR_HANDLER_HPP
diff --git a/dev/lib/fix/parser.hpp b/dev/lib/fix/fix.hpp
index 723506e..723506e 100644
--- a/dev/lib/fix/parser.hpp
+++ b/dev/lib/fix/fix.hpp
diff --git a/dev/lib/io/print.hpp b/dev/lib/io/print.hpp
index 4b32ddb..307c06f 100644
--- a/dev/lib/io/print.hpp
+++ b/dev/lib/io/print.hpp
@@ -35,6 +35,7 @@ namespace ocl::io
inline void println(T... fmt) noexcept
{
print(fmt...);
+ print();
}
} // namespace ocl::io
diff --git a/dev/lib/logic/opt.hpp b/dev/lib/logic/opt.hpp
index 442756c..137460c 100644
--- a/dev/lib/logic/opt.hpp
+++ b/dev/lib/logic/opt.hpp
@@ -20,6 +20,7 @@ namespace ocl
count = err - okay + 1,
};
+ template <typename char_type = char>
struct opt final
{
explicit opt(const return_type& return_type)
@@ -27,11 +28,23 @@ namespace ocl
{
}
- opt& expect(const char* input)
+ template <typename ErrorHandler>
+ opt& try_or_handle(const char_type* input)
{
if (m_ret == return_type::err)
{
- throw std::runtime_error(input);
+ ErrorHandler handler;
+ handler(input ? input : "");
+ }
+
+ return *this;
+ }
+
+ opt& try_or_throw(const char_type* input)
+ {
+ if (m_ret == return_type::err)
+ {
+ throw std::runtime_error(input ? input : "");
}
return *this;
diff --git a/dev/lib/net/url.hpp b/dev/lib/net/url.hpp
index ff6aebe..7263a52 100644
--- a/dev/lib/net/url.hpp
+++ b/dev/lib/net/url.hpp
@@ -61,4 +61,12 @@ namespace ocl::net
return ss_.size() > 0;
}
};
+
+ enum class protocol
+ {
+ http,
+ https,
+ mailto,
+ bad
+ };
} // namespace ocl::net
diff --git a/dev/lib/simd/basic_simd.hpp b/dev/lib/simd/basic_simd.hpp
new file mode 100644
index 0000000..d748d0c
--- /dev/null
+++ b/dev/lib/simd/basic_simd.hpp
@@ -0,0 +1,50 @@
+/*
+ * File: simd/basic_simd.hpp
+ * Purpose: Basic SIMD backend C++ library.
+ * Author: Amlal El Mahrouss (founder@snu.systems)
+ * Copyright 2025, Amlal El Mahrouss, and SNU Systems, Corp, licensed under the BSL 1.0 license.
+ */
+
+#pragma once
+
+#include <lib/core/includes.hpp>
+#include <cmath>
+
+#ifdef __x86_64__
+#include <immintrin.h>
+
+using simd_type = __m256;
+#endif
+
+#ifdef __aarch64__
+#include <arm_neon.h>
+
+using simd_type = float32x4_t;
+#endif
+
+namespace ocl::snu::simd
+{
+ struct basic_simd_backend final
+ {
+ struct simd_traits final
+ {
+ simd_type __val;
+
+ private:
+ static bool bad;
+ friend class basic_simd_backend;
+ };
+
+ using register_type = simd_traits;
+
+ const bool& is_bad() noexcept
+ {
+ return register_type::bad;
+ }
+
+ std::basic_string<char> isa()
+ {
+ return "basic-backend";
+ }
+ };
+} // namespace ocl::snu::simd
diff --git a/dev/lib/simd/simd.hpp b/dev/lib/simd/simd.hpp
new file mode 100644
index 0000000..779d020
--- /dev/null
+++ b/dev/lib/simd/simd.hpp
@@ -0,0 +1,60 @@
+/*
+ * File: simd/simd.hpp
+ * Purpose: SIMD C++ library.
+ * Author: Amlal El Mahrouss (founder@snu.systems)
+ * Copyright 2025, Amlal El Mahrouss, and SNU Systems, Corp, licensed under the BSL 1.0 license.
+ */
+
+#pragma once
+
+#include <lib/core/includes.hpp>
+
+/// @author Amlal El Mahrouss
+/// @brief Basic SIMD processor.
+
+namespace ocl::snu::simd
+{
+ template <typename backend_type>
+ class basic_simd_processor
+ {
+ private:
+ backend_type processor_;
+
+ enum opcode
+ {
+ bad,
+ add,
+ mul,
+ div,
+ };
+
+ public:
+ basic_simd_processor() = default;
+ virtual ~basic_simd_processor() = default;
+
+ basic_simd_processor& operator=(const basic_simd_processor&) = delete;
+ basic_simd_processor(const basic_simd_processor&) = delete;
+
+ typename backend_type::register_type& call(const opcode& op, typename backend_type::register_type& lhs, typename backend_type::register_type& rhs)
+ {
+ switch (op)
+ {
+ case add:
+ return processor_.add(lhs, rhs);
+ case mul:
+ return processor_.mul(lhs, rhs);
+ case div:
+ return processor_.div(lhs, rhs);
+ default:
+ break;
+ }
+
+ return processor_.is_bad();
+ }
+
+ std::basic_string<char> isa()
+ {
+ return processor_.isa();
+ }
+ };
+} // namespace ocl::snu::simd