Skip to content

Commit 90d8cd1

Browse files
committed
Add cpp/ir snippets into FE section
1 parent ca7857d commit 90d8cd1

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

sycl/doc/design/MappingHostAddressesToDeviceEntities.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ of which approach is in use.
6767
## Common front-end part
6868

6969
DPC++ FE should support the following attribute:
70-
`[[__sycl_detail__::uniquely_identifiable_object(kind)]]`. This attribute accepts
70+
`[[__sycl_detail__::uniquely_identifiable_object(kind)]]`. The attribute accepts
7171
a string literal and should be applied to types (like `device_global` or
7272
`specialization_id`).
7373

@@ -83,6 +83,31 @@ things:
8383
contains the `kind` string passed via
8484
`[[__sycl_detail__::uniquely_identifiable_object(kind)]]` attribute
8585

86+
To illustrate, here is a SYCL code snippet:
87+
88+
```
89+
template <typename T>
90+
class
91+
// Note: the attribute usage will be guarded by macro to be only applied when
92+
// DPC++ compiler is used to avoid generating warnings. That is described
93+
// later in the doc
94+
[[__sycl_detail__::uniquely_identifiable_object("specialization_id")]]
95+
specialization_id {
96+
// ...
97+
};
98+
99+
specialization_id<int> spec_const(38);
100+
```
101+
102+
After processed by DPC++ compiler, it will result in the following LLVM IR:
103+
104+
```
105+
%class.specialization_id = type { i32 }
106+
@spec_const = dso_local global %class.specialization_id { i32 38 } #0
107+
108+
attributes #0 = { "sycl-unique-id"="string returned by __builtin_sycl_unique_id(spec_const)" "sycl-uid-kind"="specialization_id" }
109+
```
110+
86111
**TODO**: we have `[[__sycl_detail__::device_global]]` attribute documented in
87112
[device global design doc][device-global-design], which instructs front-end to
88113
emit some additional semantic checking. Shall we leave it in place or that

0 commit comments

Comments
 (0)