Skip to content

Commit 879566a

Browse files
committed
Apply comments
1 parent 69bdfde commit 879566a

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

sycl/doc/SpecializationConstants.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ and the user says
195195

196196
#### Compiler
197197

198-
##### The SpecConstant pass changes
198+
##### The SpecConstants pass
199199

200200
The SpecConstants pass in the post-link will have the following IR as input
201201
(`sret` conversion is omitted for clarity):
@@ -248,8 +248,8 @@ Besides, the SPIR-V specification does not allow `SpecID` decoration for
248248
composite spec constants, because its defined by its members instead.
249249

250250
`__spirv_SpecConstantComposite` is a new SPIR-V intrinsic, which represents
251-
composite specialization constant. Its arguments are LLVM IR valures
252-
corresponding to elements of composite type of the constant.
251+
composite specialization constant. Its arguments are LLVM IR values
252+
corresponding to elements of the composite constant.
253253

254254
##### LLVM -> SPIR-V translation
255255

@@ -263,7 +263,7 @@ Given the `__spirv_SpecConstantComposite` intrinsic calls produced by the
263263
define dso_local spir_func void @get(%struct.A* sret %ret.ptr) local_unnamed_addr #0 {
264264
; args are "ID" and "default value":
265265
%1 = tail call spir_func i32 @_Z20__spirv_SpecConstantii(i32 42, i32 0)
266-
%2 = tail call spir_func i32 @_Z20__spirv_SpecConstantif(i32 43, float 0.000000e+00)
266+
%2 = tail call spir_func float @_Z20__spirv_SpecConstantif(i32 43, float 0.000000e+00)
267267
%ret = tail call spir_func %struct.A @_Z29__spirv_SpecConstantCompositeif(%1, %2)
268268
store %struct.A %ret, %struct.A* %ret.ptr
269269
ret void
@@ -274,11 +274,11 @@ the translator will generate `OpSpecConstant` and `OpSpecConstantComposite`
274274
SPIR-V instructions with proper `SpecId` decorations:
275275

276276
```
277-
OpDecorate %i32 SpecId 42 ; ID
278-
OpDecorate %float SpecId 43 ; ID
279-
%i32 = OpSpecConstant %int.type 0 ; Default value
280-
%float = OpSpecConstant %float.type 0.0 ; Default value
281-
%struct = OpSpecConstantComposite %struct.type %i32 %float ; No ID, defined by its elements
277+
OpDecorate %i32 SpecId 42 ; ID of the 1st member
278+
OpDecorate %float SpecId 43 ; ID of the 2nd member
279+
%i32 = OpSpecConstant %int.type 0 ; 1st member with default value
280+
%float = OpSpecConstant %float.type 0.0 ; 2nd member with default value
281+
%struct = OpSpecConstantComposite %struct.type %i32 %float ; Composite doens't need IDs or default value
282282
%1 = OpTypeFunction %struct.type
283283
284284
%get = OpFunction %struct.type None %1
@@ -301,6 +301,15 @@ referenced by its symbolic ID. For example:
301301
MyConst_mangled [10,0,4],[11,4,4],[12,8,4],[13,12,4],[14,16,4]
302302
```
303303

304+
This tuple is needed, because at SYCL runtime level, composite constants are set
305+
by user as a single entity and we have to break it down to its members and set a
306+
value for each leaf as for a separate specialization constant. It contains the
307+
following data:
308+
- ID of composite constants leaf, i.e. ID of scalar spec constant
309+
- Offset from the beginning of composite, which points to the location of a
310+
scalar value within the composite
311+
- Size of the scalar value
312+
304313
#### SYCL runtime
305314

306315
First, when the runtime loads a binary it gets access to specialization

0 commit comments

Comments
 (0)