Skip to content

Commit fc2faf3

Browse files
committed
Add description for spec_const_integration
1 parent e88f402 commit fc2faf3

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

sycl/doc/SYCL2020-SpecializationConstants.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ inline const char *get_spec_constant_symbolic_ID<id_float>() {
840840
} //namespace sycl
841841
} // __SYCL_INLINE_NAMESPACE(cl)
842842
843-
// get_spec_constant_symbolic_ID
843+
// Detailed description of this header is provided below in corresponding RT section
844844
#include <CL/sycl/detail/spec_const_integration.hpp>
845845
```
846846

@@ -939,6 +939,7 @@ namespace sycl {
939939
}
940940
}
941941
942+
#include <CL/sycl/detail/spec_const_integration.hpp>
942943
```
943944

944945
### DPC++ runtime
@@ -1002,6 +1003,28 @@ In order to properly set default values of specialization constants,
10021003
is used to either fully or partially initialize the buffer with specialization
10031004
constant values.
10041005

1006+
#### sycl/detail/spec_const_integration.hpp header file
1007+
1008+
DPC++ RT needs to have access to a mapping between `specialization_id` variables
1009+
and corresponding unique symbolic IDs used by the compiler. As already stated
1010+
above, we use integration footer for that by providing template specializations
1011+
of `get_spec_constant_symbolic_ID` function template.
1012+
1013+
The tricky thing here, is that C++ specification states the following:
1014+
1015+
> Specialization must be declared before the first use that would cause implicit
1016+
> instantiation, in every translation unit where such use occurs.
1017+
>
1018+
> [cppreference][cppreference-template-specialization]
1019+
1020+
[cppreference-template-specialization]: https://en.cppreference.com/w/cpp/language/template_specialization
1021+
1022+
That means that all users of `get_spec_constant_symbolic_ID` has to appear
1023+
*after* we defined all `get_spec_constant_symbolic_ID` template specializations.
1024+
1025+
`sycl/detail/spec_const/integration.hpp` header file is intended to be a
1026+
location for such methods/classes/functions.
1027+
10051028
### SPIRV-LLVM-Translator
10061029

10071030
Given the `__spirv_SpecConstant` intrinsic calls produced by the

0 commit comments

Comments
 (0)