diff options
Diffstat (limited to 'dev/lib/simd/simd.hpp')
| -rw-r--r-- | dev/lib/simd/simd.hpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/dev/lib/simd/simd.hpp b/dev/lib/simd/simd.hpp new file mode 100644 index 0000000..e571b23 --- /dev/null +++ b/dev/lib/simd/simd.hpp @@ -0,0 +1,60 @@ +/* + * File: simd/simd.hpp + * Purpose: SIMD C++ library. + * Author: Amlal El Mahrouss (amlal@nekernel.org) + * Copyright 2025, Amlal El Mahrouss, 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 |
