Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef GENERIC_SIMD
- #define GENERIC_SIMD
- #include "preprocessor.hpp"
- #include "set.hpp"
- #include "add.hpp"
- namespace simd
- {
- template <typename _Tx>
- class vec
- {
- public:
- using vec_t = _Tx;
- using type = vec_t;
- // Disable any implicit conversions
- explicit vec() = default;
- explicit vec(const vec_t& reg) : _vec(reg) {}
- explicit vec(const vec<vec_t>& copy) : _vec(copy._vec) {}
- explicit vec(vec<vec_t>&& move) : _vec(move._vec) {}
- vec<vec_t>& operator=(const vec<vec_t>& copy)
- {
- vec<vec_t> temp{};
- temp._vec = copy._vec;
- return temp;
- }
- // Allow copy assignment with vec_t
- vec<vec_t>& operator=(const vec_t& copy)
- {
- vec<vec_t> temp{};
- temp._vec = copy;
- return temp;
- }
- vec<vec_t>& operator=(vec<vec_t>&& move)
- {
- vec<vec_t> temp{};
- temp._vec = move._vec;
- return temp;
- }
- // Allow move assignment with vec_t
- vec<vec_t>& operator=(vec_t&& move)
- {
- vec<vec_t> temp{};
- temp._vec = move;
- return temp;
- }
- // 2d stencil specific operation
- void set(float value)
- {
- static_assert(std::is_same<vec_t, simd::float4>::value);
- simd::helper::set<vec_t>::compute(std::ref(_vec), std::ref(value));
- }
- // 2d stencil specific operation
- void add(vec<vec_t>& other)
- {
- static_assert(std::is_same<vec_t, simd::float4>::value);
- simd::helper::add<vec_t>::compute(std::ref(_vec), std::ref(other._vec));
- }
- vec<vec_t> operator+(vec<vec_t>& other)
- {
- static_assert(std::is_same<vec_t, simd::float4>::value);
- vec_t res = simd::helper::add<vec_t>::compute(std::ref(_vec), std::ref(other._vec));
- vec<vec_t> temp{ res };
- return std::move(temp);
- }
- // 2d stencil specific operation
- void multiply()
- {
- }
- // our stored simd float/double
- vec_t _vec;
- };
- }
- #endif // GENERIC_SIMD
Add Comment
Please, Sign In to add comment