@@ -17,7 +17,7 @@ ordinal number. This complicates the design, as the compiler
17
17
18
18
Simple source code example:
19
19
20
- ``` cpp
20
+ ```
21
21
class MyInt32Const;
22
22
...
23
23
sycl::program p(q.get_context());
@@ -46,7 +46,7 @@ primitive numeric types. POD types support is described further in the document.
46
46
47
47
Key ` spec_constant::get() ` function implementation for the device code:
48
48
49
- ```cpp
49
+ ```
50
50
template <typename T, typename ID = T> class spec_constant {
51
51
...
52
52
public:
@@ -87,7 +87,7 @@ After this pass the sycl-post-link tool will output the
87
87
attaching this info to the device binary image via the offload wrapper tool as
88
88
a property set:
89
89
90
- ``` cpp
90
+ ```
91
91
struct pi_device_binary_struct {
92
92
...
93
93
// Array of preperty sets; e.g. specialization constants symbol-int ID map is
@@ -112,7 +112,7 @@ the value of a spec constant.
112
112
113
113
Given the ` __spirv_SpecConstant ` intrinsic calls produced by the
114
114
` SpecConstants ` pass:
115
- ```cpp
115
+ ```
116
116
; Function Attrs: alwaysinline
117
117
define dso_local spir_func i32 @get() local_unnamed_addr #0 {
118
118
; args are "ID" and "default value":
@@ -124,7 +124,7 @@ define dso_local spir_func i32 @get() local_unnamed_addr #0 {
124
124
the translator will generate ` OpSpecConstant ` SPIR-V instructions with proper
125
125
` SpecId ` decorations:
126
126
127
- ``` cpp
127
+ ```
128
128
OpDecorate %i32 SpecId 42 ; ID
129
129
%i32 = OpSpecConstant %int 0 ; Default value
130
130
%1 = OpTypeFunction %int
@@ -152,7 +152,7 @@ unaware of the clang-specific built-ins.
152
152
Before JIT-ing a program, the runtime "flushes" the spec constants: it iterates
153
153
through the value map and invokes the
154
154
155
- ```cpp
155
+ ```
156
156
pi_result piextProgramSetSpecializationConstant(pi_program prog,
157
157
pi_uint32 spec_id,
158
158
size_t spec_size,
@@ -167,7 +167,7 @@ Plugin Interface function for each entry, taking the `spec_id` from the ID map.
167
167
168
168
Say, the POD type is
169
169
170
- ```cpp
170
+ ```
171
171
struct A {
172
172
int x;
173
173
float y;
@@ -181,7 +181,7 @@ struct POD {
181
181
182
182
and the user says
183
183
184
- ``` cpp
184
+ ```
185
185
POD gold{
186
186
{
187
187
{ goldi, goldf },
@@ -199,7 +199,7 @@ and the user says
199
199
200
200
- The SpecConstants pass in the post-link will have the following IR as input (` sret ` conversion is omitted for clarity):
201
201
202
- ```cpp
202
+ ```
203
203
%spec_const = call %struct.POD __sycl_getCompositeSpecConstantValue<POD type mangling> ("MyConst_mangled")
204
204
```
205
205
@@ -214,7 +214,7 @@ where `__sycl_getCompositeSpecConstantValue` is a new "intrinsic"
214
214
specialization constant's type (` %struct.POD ` ), the pass will traverse its leaf
215
215
fields and generate 5 "primitive" spec constants using already existing SPIR-V intrinsic:
216
216
217
- ``` cpp
217
+ ```
218
218
%gold_POD_a0x = call i32 __spirv_SpecConstant(i32 10, i32 0)
219
219
%gold_POD_a0y = call float __spirv_SpecConstant(i32 11, float 0)
220
220
%gold_POD_a1x = call i32 __spirv_SpecConstant(i32 12, i32 0)
@@ -224,7 +224,7 @@ where `__sycl_getCompositeSpecConstantValue` is a new "intrinsic"
224
224
225
225
And 1 "composite"
226
226
227
- ```cpp
227
+ ```
228
228
%gold_POD = call %struct.POD __spirvCompositeSpecConstant<POD type mangling>(i32 10, i32 11, i32 12, i32 13, i32 14)
229
229
```
230
230
@@ -244,15 +244,15 @@ passed to the runtime. Also, for a composite specialization constant there is
244
244
no ID map entry within the meta information, and the composite constant is
245
245
referenced by its symbolic ID. For example:
246
246
247
- ``` cpp
247
+ ```
248
248
MyConst_mangled [10,int,0,4],[11,float,4,4],[12,int,8,4],[13,float,12,4],[14,int,16,4]
249
249
```
250
250
251
251
#### LLVMIR-\> SPIR-V translator
252
252
253
253
The translator aims to create the following code (pseudo-code)
254
254
255
- ``` cpp
255
+ ```
256
256
%gold_POD_a0x = OpSpecConstant(0) [SpecId = 10]
257
257
%gold_POD_a0y = OpSpecConstant(0.0f) [SpecId = 11]
258
258
%gold_POD_a1x = OpSpecConstant(0) [SpecId = 12]
0 commit comments