Commit 5259fd6
Fix explicit generic casts handling
Explicit generic casts allows user to check whether a particular generic
pointer is pointing either to global, local or private address space.
They are represented in OpenCL C as `to_global`, `to_local` or `to_private`
functions. Specification: https://man.opencl.org/addressSpaceQualifierFuncs.html
For example: `to_private` returns a pointer that points to a region in
the private address space if to_private can cast ptr to the private
address space. Otherwise it returns NULL.
These builtins are handled incorrectly if IGC decides to allocate private
memory in a global buffer (private memory is allocated in a global buffer
to minimize negative performance implications caused by dynamic generic
address space resolution), since in such case, there is no possibility
to distinguish between private and global pointer.
This change introduces the following logic:
1. Detect usage of explicit generic casts in a kernel.
2. If the casts are present:
a) Force tagging private pointers - to distinguish from global pointers
b) Clear tag for addrspacecasts from global to generic - since private
accesses may be statically resolved to global accesses when casting
back to named addresspace, generic pointer casted to global address
space may actually be a private pointer for which a tag has been set
in step a).1 parent 3130fd8 commit 5259fd6
File tree
6 files changed
+45
-5
lines changed- IGC/Compiler
- CISACodeGen
- Optimizer/OpenCLPasses/GenericAddressResolution
6 files changed
+45
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8649 | 8649 | | |
8650 | 8650 | | |
8651 | 8651 | | |
8652 | | - | |
| 8652 | + | |
| 8653 | + | |
| 8654 | + | |
| 8655 | + | |
| 8656 | + | |
| 8657 | + | |
8653 | 8658 | | |
8654 | | - | |
8655 | | - | |
8656 | 8659 | | |
8657 | 8660 | | |
8658 | 8661 | | |
| |||
8682 | 8685 | | |
8683 | 8686 | | |
8684 | 8687 | | |
8685 | | - | |
| 8688 | + | |
8686 | 8689 | | |
8687 | 8690 | | |
8688 | 8691 | | |
| |||
8697 | 8700 | | |
8698 | 8701 | | |
8699 | 8702 | | |
8700 | | - | |
| 8703 | + | |
| 8704 | + | |
| 8705 | + | |
8701 | 8706 | | |
8702 | 8707 | | |
8703 | 8708 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
114 | 124 | | |
115 | 125 | | |
116 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
241 | 251 | | |
242 | 252 | | |
243 | 253 | | |
| |||
308 | 318 | | |
309 | 319 | | |
310 | 320 | | |
| 321 | + | |
| 322 | + | |
311 | 323 | | |
312 | 324 | | |
313 | 325 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
664 | 669 | | |
665 | 670 | | |
666 | 671 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1027 | 1027 | | |
1028 | 1028 | | |
1029 | 1029 | | |
| 1030 | + | |
1030 | 1031 | | |
1031 | 1032 | | |
1032 | 1033 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
460 | 461 | | |
461 | 462 | | |
462 | 463 | | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
463 | 470 | | |
464 | 471 | | |
465 | 472 | | |
| |||
0 commit comments