-
Notifications
You must be signed in to change notification settings - Fork 102
/
index.html
378 lines (367 loc) · 12.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../common-revealjs/css/reveal.css">
<link rel="stylesheet" href="../common-revealjs/css/theme/white.css">
<link rel="stylesheet" href="../common-revealjs/css/custom.css">
<script>
// This is needed when printing the slides to pdf
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? '../common-revealjs/css/print/pdf.css' : '../common-revealjs/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<script>
// This is used to display the static images on each slide,
// See global-images in this html file and custom.css
(function() {
if(window.addEventListener) {
window.addEventListener('load', () => {
let slides = document.getElementsByClassName("slide-background");
if (slides.length === 0) {
slides = document.getElementsByClassName("pdf-page")
}
// Insert global images on each slide
for(let i = 0, max = slides.length; i < max; i++) {
let cln = document.getElementById("global-images").cloneNode(true);
cln.removeAttribute("id");
slides[i].appendChild(cln);
}
// Remove top level global images
let elem = document.getElementById("global-images");
elem.parentElement.removeChild(elem);
}, false);
}
})();
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<div id="global-images" class="global-images">
<img src="../common-revealjs/images/sycl_academy.png" />
<img src="../common-revealjs/images/sycl_logo.png" />
<img src="../common-revealjs/images/trademarks.png" />
</div>
<!--Slide 1-->
<section class="hbox">
<div class="hbox" data-markdown>
## Device Discovery
</div>
</section>
<!--Slide 2-->
<section class="hbox" data-markdown>
## Learning Objectives
* Learn about the SYCL system topology and how to traverse it
* Learn how to query information about a platform or device
* Learn how to select a device; both manually and using device selectors
</section>
<!--Slide 3-->
<section>
<div class="hbox" data-markdown>
#### SYCL System Topology
</div>
<div class="container" data-markdown>
* A SYCL application can execute work across a range of different heterogeneous devices.
* The devices that are available in any given system are determined at runtime through topology discovery.
</div>
</section>
<!--Slide 4-->
<section>
<div class="hbox" data-markdown>
#### Platforms and devices
</div>
<div class="container" data-markdown>
* The SYCL runtime will discover a set of platforms that are available in the system.
* Each platform represents a backend implementation such as Intel OpenCL or Nvidia PTX.
* The SYCL runtime will also discover all the devices available for each of those platforms.
* CPU, GPU, FPGA, and other kinds of accelerators.
</div>
<div class="col" data-markdown>
![SYCL](../common-revealjs/images/devices-1.png "SYCL-Devices")
</div>
</section>
<!--Slide 5-->
<!--Slide 6-->
<section>
<div class="hbox" data-markdown>
#### Platform and device classes
</div>
<div class="container" data-markdown>
* Platforms and devices are represented by the `platform` and `device` classes respectively.
</div>
<div class="container">
<div class="col" data-markdown>
![SYCL](../common-revealjs/images/devices-1.png "SYCL-Devices")
</div>
</div>
<!--Slide 7-->
</section>
<section class="hbox">
<div class="hbox" data-markdown>
#### Querying the topology
</div>
<div class="hbox" data-markdown>
* In SYCL there are two ways to query a system’s topology.
* The topology can be manually queried and iterated over via APIs of the platform and device classes .
* The topology can be automatically queried and iterated over using a use specified heuristic by a device selector object.
</div>
</section>
<!--Slide 8-->
<section>
<div class="hbox" data-markdown>
#### Querying manually
</div>
<div class="container">
<div class="col-left-1">
<code><pre>
auto platforms = platform::get_platforms();
</code></pre>
</div>
<div class="col-right-1" data-markdown>
![SYCL](../common-revealjs/images/devices-5.png "SYCL-Devices")
</div>
</div>
<div class="smaller-size-font" data-markdown>
* The platform class provides the static function `get_platforms`.
* It retrieves a vector of all available platforms in the system.
</div>
</section>
<!--Slide 9-->
<section>
<div class="hbox" data-markdown>
#### Querying manually
</div>
<div class="container">
<div class="col-left-1">
<code><pre>
auto intelDevices = intelPlatform.get_devices();
</code></pre>
</div>
<div class="col-right-1" data-markdown>
![SYCL](../common-revealjs/images/devices-6.png "SYCL-Devices")
</div>
</div>
<div class="smaller-size-font" data-markdown>
* The platform class provides the member function
`get_devices` that returns a vector of all devices
associated with that platform.
</div>
</section>
<!--Slide 10-->
<section>
<div class="hbox" data-markdown>
#### Querying manually
</div>
<div class="container">
<div class="col-left-1">
<code><pre>
auto devices = device::get_devices();
</code></pre>
</div>
<div class="col-right-1" data-markdown>
![SYCL](../common-revealjs/images/devices-7.png "SYCL-Devices")
</div>
</div>
<div class="smaller-size-font" data-markdown>
* The device class also provides the static
function `get_devices` that returns a vector of all
available devices in the system.
</div>
</section>
<!--Slide 11-->
<section>
<div class="hbox" data-markdown>
#### Querying with a device selector
</div>
<div class="container">
<div class="col-left-1" data-markdown>
![Device Topology](../common-revealjs/images/topology-1.png "Device-Topology")
</div>
<div class="col-right-1" data-markdown>
* To simplify the process of traversing the system topology SYCL provides device selectors.
* A device selector is is a callable C++ object which defines a heuristic for scoring devices.
* SYCL provides a number of standard device selectors, e.g. `default_selector_v`, `gpu_selector_v`, etc.
* Users can also create their own device selectors.
</div>
</div>
</section>
<!--Slide 12-->
<section>
<div class="hbox" data-markdown>
#### Querying with a device selector
</div>
<div class="container">
<div class="col-left-1">
<code><pre>
auto gpuDevice = device(gpu_selector_v);
</code></pre>
</div>
<div class="col-right-1" data-markdown>
![Device Topology](../common-revealjs/images/topology-1.png "Device-Topology")
</div>
</div>
<div class="container" data-markdown>
* A device selector takes a parameter of type `const device &` and gives it a "score".
* Used to query all devices and return the one with the highest "score".
* A device with a negative score will never be chosen.
</div>
</section>
<!--Slide 13-->
<section>
<div class="hbox" data-markdown>
#### Querying the topology using a device selector
</div>
<div class="container">
<div class="col-left-1">
<code><pre>
auto chosenDevice = device();
auto chosenDevice = device(default_selector_v);
</code></pre>
</div>
<div class="col-right-1" data-markdown>
![Device Topology](../common-revealjs/images/topology-1.png "Device-Topology")
</div>
</div>
<div class="container" data-markdown>
* The `default_selector_v` is a standard device selector.
* Chooses a device based on an implementation defined heuristic.
* A default constructed device or platform will use this selector.
</div>
</section>
<!--Slide 14-->
<section>
<div class="hbox" data-markdown>
#### Creating a custom device selector
</div>
<div class="container">
<code><pre>
<mark>int my_gpu_selector(const device& dev) {</mark>
<mark>}</mark>
</code></pre>
</div>
<div class="hbox" data-markdown>
* A device selector can be any callable object.
* A device selector must have a function call operator which takes a reference to a device.
</div>
</section>
<!--Slide 15-->
<section>
<div class="hbox" data-markdown>
#### Creating a custom device selector
</div>
<div class="container">
<code><pre>
int my_gpu_selector(const device& dev) {
<mark>if (dev.is_gpu()){</mark>
<mark>return 1;</mark>
<mark>}</mark>
<mark>else {</mark>
<mark>return -1;</mark>
<mark>}</mark>
}
</code></pre>
</div>
<div class="hbox" data-markdown>
* The body of the function call operator defines the heuristic for selecting devices
* This is where you write the logic for scoring each device
</div>
</section>
<!--Slide 16-->
<section>
<div class="hbox" data-markdown>
#### Creating a custom device selector
</div>
<div class="container">
<code><pre>
int my_gpu_selector(const device& dev) {
if (dev.is_gpu()){
return 1;
}
else {
return -1;
}
}
int main(int argc, char *argv[]) {
<mark>auto gpuQueue = queue{my_gpu_selector};</mark>
}
</code></pre>
</div>
<div class="hbox" data-markdown>
* Now that there is a device selector that chooses a specific device we can use that to construct a queue.
</div>
</section>
<!--Slide 17-->
<section>
<div class="hbox" data-markdown>
#### Platform/device info
</div>
<div class="container">
<div class="col-left-1">
<code><pre>
auto plt = dev.get_platform();
auto platformName
= dev.get_info<info::device::name>();
</code></pre>
</div>
<div class="col-right-2" data-markdown>
![SYCL](../common-revealjs/images/topology-2.png "SYCL-Devices")
</div>
</div>
<div class="container" data-markdown>
* Information about platforms and devices can be queried using the template member function `get_info`.
* The info that you are querying is specified by the template parameter.
* You can also query a device for its associated platform with the `get_platform` member function.
</div>
</section>
<!--Slide 18-->
<section>
<div class="hbox" data-markdown>
#### Aspects
</div>
<div class="container">
<div class="col">
<code><pre>
bool supportsFp16 = dev.has(aspect::fp16);
</code></pre>
</div>
<div class="col" data-markdown>
* Capabilities of a device or platform are
represented by aspects.
* These can be queried via the `has` member
function.
</div>
</div>
</section>
<!--Slide 19-->
<section>
<div class="hbox" data-markdown>
## Questions
</div>
</section>
<!--Slide 20-->
<section>
<div class="hbox" data-markdown>
#### Exercise
</div>
<div class="container" data-markdown>
Code_Exercises/Device_Discovery/source
</div>
<div class="container" data-markdown>
Create your own device selector that chooses the device in your system that you would like to target.
</div>
</section>
</div>
</div>
<script src="../common-revealjs/js/reveal.js"></script>
<script src="../common-revealjs/plugin/markdown/marked.js"></script>
<script src="../common-revealjs/plugin/markdown/markdown.js"></script>
<script src="../common-revealjs/plugin/notes/notes.js"></script>
<script>
Reveal.initialize({mouseWheel: true, defaultNotes: true});
Reveal.configure({ slideNumber: true });
</script>
</body>
</html>