diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-09-17 10:06:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-17 10:06:21 +0200 |
| commit | 94799223495b9842bca67e1a6ecf611cec3ee771 (patch) | |
| tree | 435f5b6adb6889462640b1456e684360cd7e495f | |
| parent | 6789dd7d88a192e3f55b95798cb393e7d12f368a (diff) | |
| parent | fa4748e414e9494442f9bcde9c659d3951af19c0 (diff) | |
(SCL: v1.0.44) Merge pull request #1 from snu-systems-corp/dev
SCL: v1.0.44
| -rw-r--r-- | README.md | 10 | ||||
| -rw-r--r-- | dev/examples/fix/fix.cc | 2 | ||||
| -rw-r--r-- | dev/examples/opt/opt.cc | 2 | ||||
| -rw-r--r-- | dev/lib/core/error_handler.hpp | 4 | ||||
| -rw-r--r-- | dev/lib/fix/fix.hpp (renamed from dev/lib/fix/parser.hpp) | 0 | ||||
| -rw-r--r-- | dev/lib/io/print.hpp | 1 | ||||
| -rw-r--r-- | dev/lib/logic/opt.hpp | 17 | ||||
| -rw-r--r-- | dev/lib/net/url.hpp | 8 | ||||
| -rw-r--r-- | dev/lib/simd/basic_simd.hpp | 50 | ||||
| -rw-r--r-- | dev/lib/simd/simd.hpp | 60 | ||||
| -rw-r--r-- | dev/tests/fix_basic/fix_test.cc | 4 |
11 files changed, 146 insertions, 12 deletions
@@ -1,10 +1,10 @@ -# Open C++ Library +# SIMD C++ Library [](LICENSE) ## Brief: -A C++ library with additional modules for your C++ SDLC. +A C++ library with additional modules for your C++ SDLC. Based on the Open C++ Library. ## Requirements: @@ -21,10 +21,10 @@ A C++ library with additional modules for your C++ SDLC. int main(int argc, char** argv) { - auto opt = ocl::opt(ocl::eval_eq(50, 50)).expect("ocl::eval_eq, does not match!"); + auto opt = ocl::opt(ocl::eval_eq(50, 50)).try_or_throw("ocl::eval_eq, does not match!"); opt = ocl::opt(ocl::eval_eq(50, 40)); - opt.expect("this time it doesn't."); - + opt.try_or_throw("this time it doesn't."); + return EXIT_SUCCESS; } ``` diff --git a/dev/examples/fix/fix.cc b/dev/examples/fix/fix.cc index e3d669b..ec6668a 100644 --- a/dev/examples/fix/fix.cc +++ b/dev/examples/fix/fix.cc @@ -5,7 +5,7 @@ */ #include <lib/net/modem.hpp> -#include <lib/fix/parser.hpp> +#include <lib/fix/fix.hpp> #include <iostream> #include <unistd.h> #include <sys/socket.h> diff --git a/dev/examples/opt/opt.cc b/dev/examples/opt/opt.cc index b34f2c7..8a74fa2 100644 --- a/dev/examples/opt/opt.cc +++ b/dev/examples/opt/opt.cc @@ -38,7 +38,7 @@ int main(int argc, char** argv) ocl::io::println("Testing data..."); auto opt = do_some("Ohio", "Ohio"); - opt.expect("Checksum failed, Ohio isn't Ohio!"); + opt.try_or_throw("Checksum failed, Ohio isn't Ohio!"); return 0; 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 diff --git a/dev/tests/fix_basic/fix_test.cc b/dev/tests/fix_basic/fix_test.cc index bdde392..1c80716 100644 --- a/dev/tests/fix_basic/fix_test.cc +++ b/dev/tests/fix_basic/fix_test.cc @@ -5,7 +5,7 @@ * Copyright 2025, Amlal El Mahrouss */ -#include <lib/fix/parser.hpp> +#include <lib/fix/fix.hpp> #include <gtest/gtest.h> TEST(FIXTest, BasicFIXUsage) @@ -15,4 +15,4 @@ TEST(FIXTest, BasicFIXUsage) EXPECT_EQ(fix.magic_, ocl::fix::detail::begin_fix()); EXPECT_TRUE(fix.is_valid()); -}
\ No newline at end of file +} |
