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 #include <sycl/half_type.hpp> // for half
13 
14 #include <cstddef> // for size_t
15 #include <cstdint> // for uint32_t
16 
17 // TODO: include the header file with SPIR-V declarations from SPIRV-Headers
18 // project.
19 
20 // Declarations of enums below is aligned with corresponding declarations in
21 // SPIRV-Headers repo with a few exceptions:
22 // - base types changed from uint to uint32_t
23 // - spv namespace renamed to __spv
24 namespace __spv {
25 
26 struct Scope {
27 
28  enum Flag : uint32_t {
30  Device = 1,
31  Workgroup = 2,
32  Subgroup = 3,
34  };
35 
36  constexpr Scope(Flag flag) : flag_value(flag) {}
37 
38  constexpr operator uint32_t() const { return flag_value; }
39 
41 };
42 
43 struct StorageClass {
44  enum Flag : uint32_t {
46  Input = 1,
47  Uniform = 2,
48  Output = 3,
49  Workgroup = 4,
51  Private = 6,
52  Function = 7,
53  Generic = 8,
56  Image = 11,
62  RayPayloadKHR = 5338,
63  RayPayloadNV = 5338,
75  HostOnlyINTEL = 5937,
76  Max = 0x7fffffff,
77  };
78  constexpr StorageClass(Flag flag) : flag_value(flag) {}
79  constexpr operator uint32_t() const { return flag_value; }
81 };
82 
84 
85  enum Flag : uint32_t {
86  None = 0x0,
87  Acquire = 0x2,
88  Release = 0x4,
91  UniformMemory = 0x40,
93  WorkgroupMemory = 0x100,
96  ImageMemory = 0x800,
97  };
98 
99  constexpr MemorySemanticsMask(Flag flag) : flag_value(flag) {}
100 
101  constexpr operator uint32_t() const { return flag_value; }
102 
104 };
105 
106 enum class GroupOperation : uint32_t {
107  Reduce = 0,
108  InclusiveScan = 1,
109  ExclusiveScan = 2,
110  ClusteredReduce = 3,
111 };
112 
113 enum class MatrixLayout : uint32_t {
114  RowMajor = 0,
115  ColumnMajor = 1,
116  Packed = 2,
117  Dynamic = 3
118 };
119 
120 enum class MatrixUse : uint32_t { MatrixA = 0, MatrixB = 1, Accumulator = 2 };
121 
122 template <typename T, std::size_t R, std::size_t C, MatrixLayout L,
123  Scope::Flag S = Scope::Flag::Subgroup,
126 
127 } // namespace __spv
128 
129 #ifdef __SYCL_DEVICE_ONLY__
130 // OpenCL pipe types
131 template <typename dataT>
132 using __ocl_RPipeTy = __attribute__((pipe("read_only"))) const dataT;
133 template <typename dataT>
134 using __ocl_WPipeTy = __attribute__((pipe("write_only"))) const dataT;
135 
136 // OpenCL vector types
137 template <typename dataT, int dims>
138 using __ocl_vec_t = dataT __attribute__((ext_vector_type(dims)));
139 
140 // Struct representing layout of pipe storage
141 // TODO: rename to __spirv_ConstantPipeStorage
142 struct ConstantPipeStorage {
143  int32_t _PacketSize;
144  int32_t _PacketAlignment;
145  int32_t _Capacity;
146 };
147 
148 namespace sycl {
149 inline namespace _V1 {
150 namespace detail {
151 // Arbitrary precision integer type
152 template <int Bits> using ap_int = _BitInt(Bits);
153 } // namespace detail
154 } // namespace _V1
155 } // namespace sycl
156 #endif // __SYCL_DEVICE_ONLY__
157 
158 // This class does not have definition, it is only predeclared here.
159 // The pointers to this class objects can be passed to or returned from
160 // SPIRV built-in functions.
161 // Only in such cases the class is recognized as SPIRV type __ocl_event_t.
162 #ifndef __SYCL_DEVICE_ONLY__
163 typedef void *__ocl_event_t;
164 typedef void *__ocl_sampler_t;
165 // Adding only the datatypes that can be currently used in SYCL,
166 // as per SYCL spec 1.2.1
167 #define __SYCL_SPV_IMAGE_TYPE(NAME) typedef void *__ocl_##NAME##_t
168 
169 #define __SYCL_SPV_SAMPLED_AND_IMAGE_TYPE(NAME) \
170  __SYCL_SPV_IMAGE_TYPE(NAME); \
171  typedef void *__ocl_sampled_##NAME##_t
172 
181 __SYCL_SPV_IMAGE_TYPE(image1d_array_wo);
182 __SYCL_SPV_IMAGE_TYPE(image2d_array_wo);
183 
184 #undef __SYCL_SPV_IMAGE_TYPE
185 #undef __SYCL_SPV_SAMPLED_AND_IMAGE_TYPE
186 #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:99
constexpr Scope(Flag flag)
Definition: spirv_types.hpp:36
constexpr StorageClass(Flag flag)
Definition: spirv_types.hpp:78