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 
12 
13 #include <cstddef>
14 #include <cstdint>
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 };
110 
111 enum class MatrixLayout : uint32_t {
112  RowMajor = 0,
113  ColumnMajor = 1,
114  PackedA = 2,
115  PackedB = 3,
116  Unused = 4
117 };
118 
119 enum class MatrixUse : uint32_t { MatrixA = 0, MatrixB = 1, Accumulator = 2 };
120 
121 #if (SYCL_EXT_ONEAPI_MATRIX_VERSION > 1)
122 template <typename T, std::size_t R, std::size_t C, MatrixLayout L,
123  Scope::Flag S = Scope::Flag::Subgroup,
125 struct __spirv_JointMatrixINTEL;
126 #else
127 template <typename T, std::size_t R, std::size_t C, MatrixLayout L,
128  Scope::Flag S = Scope::Flag::Subgroup>
130 #endif // SYCL_EXT_ONEAPI_MATRIX_VERSION
131 
132 } // namespace __spv
133 
134 #ifdef __SYCL_DEVICE_ONLY__
135 // OpenCL pipe types
136 template <typename dataT>
137 using __ocl_RPipeTy = __attribute__((pipe("read_only"))) const dataT;
138 template <typename dataT>
139 using __ocl_WPipeTy = __attribute__((pipe("write_only"))) const dataT;
140 
141 // OpenCL vector types
142 template <typename dataT, int dims>
143 using __ocl_vec_t = dataT __attribute__((ext_vector_type(dims)));
144 
145 // Struct representing layout of pipe storage
146 // TODO: rename to __spirv_ConstantPipeStorage
147 struct ConstantPipeStorage {
148  int32_t _PacketSize;
149  int32_t _PacketAlignment;
150  int32_t _Capacity;
151 };
152 
153 namespace sycl {
155 namespace detail {
156 // Arbitrary precision integer type
157 template <int Bits> using ap_int = _BitInt(Bits);
158 } // namespace detail
159 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
160 } // namespace sycl
161 #endif // __SYCL_DEVICE_ONLY__
162 
163 // This class does not have definition, it is only predeclared here.
164 // The pointers to this class objects can be passed to or returned from
165 // SPIRV built-in functions.
166 // Only in such cases the class is recognized as SPIRV type __ocl_event_t.
167 #ifndef __SYCL_DEVICE_ONLY__
168 typedef void* __ocl_event_t;
169 typedef void* __ocl_sampler_t;
170 // Adding only the datatypes that can be currently used in SYCL,
171 // as per SYCL spec 1.2.1
172 #define __SYCL_SPV_IMAGE_TYPE(NAME) typedef void *__ocl_##NAME##_t
173 
174 #define __SYCL_SPV_SAMPLED_AND_IMAGE_TYPE(NAME) \
175  __SYCL_SPV_IMAGE_TYPE(NAME); \
176  typedef void *__ocl_sampled_##NAME##_t
177 
186 __SYCL_SPV_IMAGE_TYPE(image1d_array_wo);
187 __SYCL_SPV_IMAGE_TYPE(image2d_array_wo);
188 
189 #undef __SYCL_SPV_IMAGE_TYPE
190 #undef __SYCL_SPV_SAMPLED_AND_IMAGE_TYPE
191 #endif
#define __SYCL_INLINE_VER_NAMESPACE(X)
__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:16
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
#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