summaryrefslogtreecommitdiffhomepage
path: root/dev/lib/simd/basic_simd.hpp
blob: 97d0399ec90221d604872cf483f839d7145b96be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 scl::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 scl::snu::simd