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 template <typename T, std::size_t R, std::size_t C, MatrixLayout L,
122  Scope::Flag S = Scope::Flag::Subgroup,
125 
126 struct __spirv_TaskSequenceINTEL;
127 
128 } // namespace __spv
129 
130 #ifdef __SYCL_DEVICE_ONLY__
131 // OpenCL pipe types
132 template <typename dataT>
133 using __ocl_RPipeTy = __attribute__((pipe("read_only"))) const dataT;
134 template <typename dataT>
135 using __ocl_WPipeTy = __attribute__((pipe("write_only"))) const dataT;
136 
137 // OpenCL vector types
138 template <typename dataT, int dims>
139 using __ocl_vec_t = dataT __attribute__((ext_vector_type(dims)));
140 
141 // Struct representing layout of pipe storage
142 // TODO: rename to __spirv_ConstantPipeStorage
143 struct ConstantPipeStorage {
144  int32_t _PacketSize;
145  int32_t _PacketAlignment;
146  int32_t _Capacity;
147 };
148 
149 namespace sycl {
150 inline namespace _V1 {
151 namespace detail {
152 // Arbitrary precision integer type
153 template <int Bits> using ap_int = _BitInt(Bits);
154 } // namespace detail
155 } // namespace _V1
156 } // namespace sycl
157 #endif // __SYCL_DEVICE_ONLY__
158 
159 // This class does not have definition, it is only predeclared here.
160 // The pointers to this class objects can be passed to or returned from
161 // SPIRV built-in functions.
162 // Only in such cases the class is recognized as SPIRV type __ocl_event_t.
163 #ifndef __SYCL_DEVICE_ONLY__
164 typedef void *__ocl_event_t;
165 typedef void *__ocl_sampler_t;
166 // Adding only the datatypes that can be currently used in SYCL,
167 // as per SYCL spec 1.2.1
168 #define __SYCL_SPV_IMAGE_TYPE(NAME) typedef void *__ocl_##NAME##_t
169 
170 #define __SYCL_SPV_SAMPLED_AND_IMAGE_TYPE(NAME) \
171  __SYCL_SPV_IMAGE_TYPE(NAME); \
172  typedef void *__ocl_sampled_##NAME##_t
173 
182 __SYCL_SPV_IMAGE_TYPE(image1d_array_wo);
183 __SYCL_SPV_IMAGE_TYPE(image2d_array_wo);
184 
185 #undef __SYCL_SPV_IMAGE_TYPE
186 #undef __SYCL_SPV_SAMPLED_AND_IMAGE_TYPE
187 #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