DPC++ Runtime
Runtime libraries for oneAPI DPC++
type_format.hpp
Go to the documentation of this file.
1 //==-------------- types.hpp - DPC++ Explicit SIMD API ---------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 // Meta-functions to compute compile-time element type of a simd_view resulting
9 // from format operations.
10 //===----------------------------------------------------------------------===//
11 
12 #pragma once
13 
15 
17 
19 namespace __ESIMD_DNS {
20 
21 template <typename BaseTy, typename EltTy> struct compute_format_type;
22 
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>;
27 };
28 
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> {};
33 
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>;
40 };
41 
42 template <typename Ty, typename EltTy>
43 using compute_format_type_t = typename compute_format_type<Ty, EltTy>::type;
44 
45 // Compute the simd_view type of a 2D format operation.
46 template <typename BaseTy, typename EltTy, int Height, int Width>
47 struct compute_format_type_2d;
48 
49 template <typename Ty, int N, typename EltTy, int Height, int Width>
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");
53 
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>;
59 };
60 
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> {};
65 
66 template <typename BaseTy, typename RegionTy, typename EltTy, int Height,
67  int Width>
68 struct compute_format_type_2d<simd_view<BaseTy, RegionTy>, EltTy, Height,
69  Width> {
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");
73 
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>;
79 };
80 
81 template <typename Ty, typename EltTy, int Height, int Width>
82 using compute_format_type_2d_t =
83  typename compute_format_type_2d<Ty, EltTy, Height, Width>::type;
84 
85 } // namespace __ESIMD_DNS
86 } // __SYCL_INLINE_NAMESPACE(cl)
87 
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
types.hpp
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12