This repository was archived by the owner on Jul 1, 2025. It is now read-only.
Commit bd69664
Add dynamic buffer support to OCL Backend (#3765)
Summary:
The OpenCL Backend uses a static memory allocation strategy of allocating a single large buffer and then using offsets into it, which is good for the general case, but doesn't allow us to get the most benefit out of Device Resident Tensors (when we'd like to leave an output on the device to be used as the input to another network). This PR adds a more dynamic mapping of device buffers to the OCL backend via OpenCL SubBuffers, which are similar to Glow TensorViews in that they provide access to a region without additional allocations.
There is no behavioural change in this PR, but it provides infrastructure to reference buffers outside of the range of the DeviceBuffer in the future, which we need to get DRT perf wins.
The immediate benefit is that I was able to simplify the OCL kernel code, deleting about 25% of kernels.cl.
Documentation: NFC
Pull Request resolved: #3765
Test Plan: tests in release and ASAN
Differential Revision: D18465407
Pulled By: nickgg
fbshipit-source-id: 1b5416c4f389885bae4d5e1533a65bef8ab601221 parent 334a712 commit bd69664
File tree
8 files changed
+232
-490
lines changed- .circleci
- lib/Backends/OpenCL
8 files changed
+232
-490
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
| 148 | + | |
150 | 149 | | |
151 | 150 | | |
152 | 151 | | |
| |||
242 | 241 | | |
243 | 242 | | |
244 | 243 | | |
245 | | - | |
246 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
247 | 248 | | |
248 | | - | |
| 249 | + | |
| 250 | + | |
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
| |||
269 | 271 | | |
270 | 272 | | |
271 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
272 | 280 | | |
273 | 281 | | |
274 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
59 | 81 | | |
60 | 82 | | |
61 | 83 | | |
| |||
356 | 378 | | |
357 | 379 | | |
358 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
359 | 390 | | |
360 | 391 | | |
361 | 392 | | |
| |||
376 | 407 | | |
377 | 408 | | |
378 | 409 | | |
| 410 | + | |
379 | 411 | | |
380 | 412 | | |
381 | 413 | | |
| |||
666 | 698 | | |
667 | 699 | | |
668 | 700 | | |
669 | | - | |
| 701 | + | |
670 | 702 | | |
671 | 703 | | |
672 | 704 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
101 | 104 | | |
102 | 105 | | |
103 | 106 | | |
| |||
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
123 | 134 | | |
124 | 135 | | |
125 | 136 | | |
| |||
0 commit comments