DPC++ Runtime
Runtime libraries for oneAPI DPC++
spirv_types.hpp
Go to the documentation of this file.
1 //===------------ spirv_types.hpp --- SPIRV types -------------------------===//
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 
9 #pragma once
10 
11 #include <sycl/detail/defines.hpp> // for __has_builtin
12 
13 #include <cstddef> // for size_t
14 #include <cstdint> // for uint32_t
15 
16 // TODO: include the header file with SPIR-V declarations from SPIRV-Headers
17 // project.
18 
19 // Declarations of enums below is aligned with corresponding declarations in
20 // SPIRV-Headers repo with a few exceptions:
21 // - base types changed from uint to uint32_t
22 // - spv namespace renamed to __spv
23 namespace __spv {
24 
25 struct Scope {
26 
27  enum Flag : uint32_t {
29  Device = 1,
30  Workgroup = 2,
31  Subgroup = 3,
33  };
34 
35  constexpr Scope(Flag flag) : flag_value(flag) {}
36 
37  constexpr operator uint32_t() const { return flag_value; }
38 
40 };
41 
42 struct StorageClass {
43  enum Flag : uint32_t {
45  Input = 1,
46  Uniform = 2,
47  Output = 3,
48  Workgroup = 4,
50  Private = 6,
51  Function = 7,
52  Generic = 8,
55  Image = 11,
61  RayPayloadKHR = 5338,
62  RayPayloadNV = 5338,
74  HostOnlyINTEL = 5937,
75  Max = 0x7fffffff,
76  };
77  constexpr StorageClass(Flag flag) : flag_value(flag) {}
78  constexpr operator uint32_t() const { return flag_value; }
80 };
81 
83 
84  enum Flag : uint32_t {
85  None = 0x0,
86  Acquire = 0x2,
87  Release = 0x4,
90  UniformMemory = 0x40,
92  WorkgroupMemory = 0x100,
95  ImageMemory = 0x800,
96  };
97 
98  constexpr MemorySemanticsMask(Flag flag) : flag_value(flag) {}
99 
100  constexpr operator uint32_t() const { return flag_value; }
101 
103 };
104 
105 enum class GroupOperation : uint32_t {
106  Reduce = 0,
107  InclusiveScan = 1,
108  ExclusiveScan = 2,
109  ClusteredReduce = 3,
110 };
111 
112 enum class MatrixLayout : uint32_t {
113  RowMajor = 0,
114  ColumnMajor = 1,
115  Packed = 2,
116  Dynamic = 3
117 };
118 
119 enum class MatrixUse : uint32_t { MatrixA = 0, MatrixB = 1, Accumulator = 2 };
120 
121 #ifdef __SPIRV_USE_COOPERATIVE_MATRIX
122 enum class MatrixOperands : uint32_t {
123  // SPV_KHR_cooperative_matrix operands
124  NoneKHR = 0,
125  MatrixASignedComponentsKHR = 0x1,
126  MatrixBSignedComponentsKHR = 0x2,
127  MatrixCSignedComponentsKHR = 0x4,
128  MatrixResultSignedComponentsKHR = 0x8,
129  SaturatingAccumulationKHR = 0x10,
130  // SPV_INTEL_joint_matrix operands
131  MatrixAAndBTF32ComponentsINTEL = 0x20,
132  MatrixAAndBBFloat16ComponentsINTEL = 0x40,
133  MatrixCBFloat16ComponentsINTEL = 0x80,
134  MatrixResultBFloat16ComponentsINTEL = 0x100
135 };
136 #endif // __SPIRV_USE_COOPERATIVE_MATRIX
137 
138 #ifndef __SPIRV_USE_COOPERATIVE_MATRIX
139 
140 template <typename T, std::size_t R, std::size_t C, MatrixLayout L,
141  Scope::Flag S = Scope::Flag::Subgroup,
144 #else
145 template <typename T, Scope::Flag S = Scope::Flag::Subgroup, std::size_t R = 1,
146  std::size_t C = 1, MatrixUse U = MatrixUse::MatrixA>
147 struct __spirv_CooperativeMatrixKHR;
148 #endif // __SPIRV_USE_COOPERATIVE_MATRIX
149 
150 struct __spirv_TaskSequenceINTEL;
151 
152 } // namespace __spv
153 
154 #ifdef __SYCL_DEVICE_ONLY__
155 // OpenCL pipe types
156 template <typename dataT>
157 using __ocl_RPipeTy = __attribute__((pipe("read_only"))) const dataT;
158 template <typename dataT>
159 using __ocl_WPipeTy = __attribute__((pipe("write_only"))) const dataT;
160 
161 // OpenCL vector types
162 template <typename dataT, int dims>
163 using __ocl_vec_t = dataT __attribute__((ext_vector_type(dims)));
164 
165 // Struct representing layout of pipe storage
166 // TODO: rename to __spirv_ConstantPipeStorage
167 struct ConstantPipeStorage {
168  int32_t _PacketSize;
169  int32_t _PacketAlignment;
170  int32_t _Capacity;
171 };
172 
173 namespace sycl {
174 inline namespace _V1 {
175 namespace detail {
176 // Arbitrary precision integer type
177 template <int Bits> using ap_int = _BitInt(Bits);
178 } // namespace detail
179 } // namespace _V1
180 } // namespace sycl
181 #endif // __SYCL_DEVICE_ONLY__
182 
183 // This class does not have definition, it is only predeclared here.
184 // The pointers to this class objects can be passed to or returned from
185 // SPIRV built-in functions.
186 // Only in such cases the class is recognized as SPIRV type __ocl_event_t.
187 #ifndef __SYCL_DEVICE_ONLY__
188 typedef void *__ocl_event_t;
189 typedef void *__ocl_sampler_t;
190 // Adding only the datatypes that can be currently used in SYCL,
191 // as per SYCL spec 1.2.1
192 #define __SYCL_SPV_IMAGE_TYPE(NAME) typedef void *__ocl_##NAME##_t
193 
194 #define __SYCL_SPV_SAMPLED_AND_IMAGE_TYPE(NAME) \
195  __SYCL_SPV_IMAGE_TYPE(NAME); \
196  typedef void *__ocl_sampled_##NAME##_t
197 
206 __SYCL_SPV_IMAGE_TYPE(image1d_array_wo);
207 __SYCL_SPV_IMAGE_TYPE(image2d_array_wo);
208 
209 #undef __SYCL_SPV_IMAGE_TYPE
210 #undef __SYCL_SPV_SAMPLED_AND_IMAGE_TYPE
211 #endif
__attribute__((always_inline)) auto invoke_simd(sycl
The invoke_simd free function invokes a SIMD function using all work-items in a sub_group.
ext::intel::pipe< name, dataT, min_capacity > pipe
Definition: pipes.hpp:18
constexpr mode_tag_t< access_mode::write > write_only
Definition: access.hpp:86
Definition: access.hpp:18
#define __SYCL_SPV_SAMPLED_AND_IMAGE_TYPE(NAME)
void * __ocl_event_t
#define __SYCL_SPV_IMAGE_TYPE(NAME)
void * __ocl_sampler_t
constexpr MemorySemanticsMask(Flag flag)
Definition: spirv_types.hpp:98
constexpr Scope(Flag flag)
Definition: spirv_types.hpp:35
constexpr StorageClass(Flag flag)
Definition: spirv_types.hpp:77