19 namespace __ESIMD_DNS {
21 template <
typename BaseTy,
typename EltTy>
struct compute_format_type;
23 template <
typename Ty,
int N,
typename EltTy>
struct compute_format_type_impl {
24 static constexpr
int Size =
sizeof(Ty) * N /
sizeof(EltTy);
25 static constexpr
int Stride = 1;
26 using type = region1d_t<EltTy, Size, Stride>;
29 template <
typename Ty,
int N,
typename EltTy,
30 template <
typename,
int>
class SimdT>
31 struct compute_format_type<SimdT<Ty, N>, EltTy>
32 : compute_format_type_impl<Ty, N, EltTy> {};
34 template <
typename BaseTy,
typename RegionTy,
typename EltTy>
35 struct compute_format_type<simd_view<BaseTy, RegionTy>, EltTy> {
36 using ShapeTy =
typename shape_type<RegionTy>::type;
37 static constexpr
int Size = ShapeTy::Size_in_bytes /
sizeof(EltTy);
38 static constexpr
int Stride = 1;
39 using type = region1d_t<EltTy, Size, Stride>;
42 template <
typename Ty,
typename EltTy>
43 using compute_format_type_t =
typename compute_format_type<Ty, EltTy>::type;
46 template <
typename BaseTy,
typename EltTy,
int Height,
int W
idth>
47 struct compute_format_type_2d;
49 template <
typename Ty,
int N,
typename EltTy,
int Height,
int W
idth>
50 struct compute_format_type_2d_impl {
51 static constexpr
int Prod =
sizeof(Ty) * N /
sizeof(EltTy);
52 static_assert(Prod == Width * Height,
"size mismatch");
54 static constexpr
int SizeX = Width;
55 static constexpr
int StrideX = 1;
56 static constexpr
int SizeY = Height;
57 static constexpr
int StrideY = 1;
58 using type = region2d_t<EltTy, SizeY, StrideY, SizeX, StrideX>;
61 template <
typename Ty,
int N,
typename EltTy,
int Height,
int Width,
62 template <
typename,
int>
class SimdT>
63 struct compute_format_type_2d<SimdT<Ty, N>, EltTy, Height, Width>
64 : compute_format_type_2d_impl<Ty, N, EltTy, Height, Width> {};
66 template <
typename BaseTy,
typename RegionTy,
typename EltTy,
int Height,
68 struct compute_format_type_2d<simd_view<BaseTy, RegionTy>, EltTy, Height,
70 using ShapeTy =
typename shape_type<RegionTy>::type;
71 static constexpr
int Prod = ShapeTy::Size_in_bytes /
sizeof(EltTy);
72 static_assert(Prod == Width * Height,
"size mismatch");
74 static constexpr
int SizeX = Width;
75 static constexpr
int StrideX = 1;
76 static constexpr
int SizeY = Height;
77 static constexpr
int StrideY = 1;
78 using type = region2d_t<EltTy, SizeY, StrideY, SizeX, StrideX>;
81 template <
typename Ty,
typename EltTy,
int Height,
int W
idth>
82 using compute_format_type_2d_t =
83 typename compute_format_type_2d<Ty, EltTy, Height, Width>::type;