You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: scripts/core/PROG.rst
+27-21
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,26 @@
10
10
Programming Guide
11
11
========================
12
12
13
+
Adapters
14
+
========
15
+
16
+
The top level abstraction in the unified runtime is the adapter handle. It owns
17
+
the platform handles as well as any backend specific global state, for instance
18
+
if a backend has global setup/teardown type entry-points these will typically
19
+
be tied to the adapter handle's constructor and destructor.
20
+
21
+
Adapter handles are reference counted via ${x}AdapterRetain and
22
+
${x}AdapterRelease. Once their reference count reaches zero any objects
23
+
associated with the adapter in question should be considered invalid. Calling
24
+
${x}AdapterGet after any adapter handle's reference count has reached zero will
25
+
result in undefined behavior. An adapter handle's reference count may be
26
+
changed by the adapter itself.
27
+
28
+
Adapter implementers should ensure the adapter handle is dynamically allocated
29
+
rather than having a static or global lifetime. Due to how destructor order
30
+
works for static and global objects this is the only way to ensure the adapter
31
+
handle stays alive as long as its reference count remains above zero.
32
+
13
33
Platforms and Devices
14
34
======================
15
35
@@ -31,6 +51,7 @@ A platform object represents a collection of physical devices in the system acce
31
51
- More than one platform may be available in the system. For example, one platform may support two GPUs from one vendor, another platform supports a GPU from a different vendor, and finally a different platform may support an FPGA.
32
52
- Platform objects are read-only, global constructs. i.e. multiple calls to ${x}PlatformGet will return identical platform handles.
33
53
- A platform handle is primarily used during device discovery and during creation and management of contexts.
54
+
- Platform handles are not reference counted, they are owned by the adapter handle and their lifetime is tied to the adapter handle's reference count.
34
55
35
56
Device
36
57
------
@@ -41,6 +62,7 @@ A device object represents a physical device in the system that supports the pla
41
62
- Device objects are read-only, global constructs. i.e. multiple calls to ${x}DeviceGet will return identical device handles.
42
63
- A device handle is primarily used during creation and management of resources that are specific to a device.
43
64
- Device may expose sub-devices that allow finer-grained control of physical or logical partitions of a device.
65
+
- Device handles are not reference counted, they are owned by their respective platform handles, whose lifetime is in turn tied to the associated adapter handle.
44
66
45
67
The following diagram illustrates the relationship between the platform, device, context and other objects described in this document.
0 commit comments