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: sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md
+22-16Lines changed: 22 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,7 @@ a SYCL object that encapsulates a corresponding Level-Zero object:
87
87
|-------------|:------------|
88
88
|``` make<platform>(ze_driver_handle_t);```|Constructs a SYCL platform instance from a Level-Zero ```ze_driver_handle_t```.|
89
89
|``` make<device>(const platform &, ze_device_handle_t);```|Constructs a SYCL device instance from a Level-Zero ```ze_device_handle_t```. The platform argument gives a SYCL platform, encapsulating a Level-Zero driver supporting the passed Level-Zero device.|
90
-
|``` make<context>(const vector_class<device> &, ze_context_handle_t, ownership = transfer);```| Constructs a SYCL context instance from a Level-Zero ```ze_context_handle_t```. The context is created against the devices passed in. There must be at least one device given and all the devices must be from the same SYCL platform and thus from the same Level-Zero driver. The ```ownership``` argument specifies if SYCL RT should take ownership of the passed native handle. The default behavior is to transfer the ownership to SYCL RT. See section 4.4 for details.|
90
+
|``` make<context>(const vector_class<device> &, ze_context_handle_t, ownership = transfer);```| Constructs a SYCL context instance from a Level-Zero ```ze_context_handle_t```. The context is created against the devices passed in. There must be at least one device given and all the devices must be from the same SYCL platform and thus from the same Level-Zero driver. The ```ownership``` argument specifies if the SYCL runtime should take ownership of the passed native handle. The default behavior is to transfer the ownership to the SYCL runtime. See section 4.4 for details.|
91
91
|``` make<queue>(const context &, ze_command_queue_handle_t);```| Constructs a SYCL queue instance from a Level-Zero ```ze_command_queue_handle_t```. The context argument must be a valid SYCL context encapsulating a Level-Zero context. The queue is attached to the first device in the passed SYCL context.|
92
92
|``` make<program>(const context &, ze_module_handle_t);```| Constructs a SYCL program instance from a Level-Zero ```ze_module_handle_t```. The context argument must be a valid SYCL context encapsulating a Level-Zero context. The Level-Zero module must be fully linked (i.e. not require further linking through [```zeModuleDynamicLink```](https://spec.oneapi.com/level-zero/latest/core/api.html?highlight=zemoduledynamiclink#_CPPv419zeModuleDynamicLink8uint32_tP18ze_module_handle_tP28ze_module_build_log_handle_t)), and thus the SYCL program is created in the "linked" state.|
93
93
@@ -96,11 +96,17 @@ NOTE: We shall consider adding other interoperability as needed, if possible.
96
96
### 4.4 Level-Zero handles' ownership and thread-safety
97
97
98
98
The Level-Zero runtime doesn't do reference-counting of its objects, so it is crucial to adhere to these
99
-
practices of how Level-Zero handles are manged. By default, the ownership us transferred to SYCL RT, but
99
+
practices of how Level-Zero handles are managed. By default, the ownership is transferred to the SYCL runtime, but
100
100
some interoparability API supports overriding this behavior and keep the ownership in the application.
101
101
Use this enumeration for explicit specification of the ownership:
102
102
``` C++
103
-
enum ownership { transfer, keep };
103
+
namespace sycl {
104
+
namespace level_zero {
105
+
106
+
enum class ownership { transfer, keep };
107
+
108
+
} // namesace level_zero
109
+
} // namespace sycl
104
110
```
105
111
106
112
#### 4.4.1 SYCL runtime takes ownership (default)
@@ -110,21 +116,21 @@ the SYCL runtime takes ownership of the Level-Zero handle, if no explicit ```own
110
116
The application must not use the Level-Zero handle after the last host copy of the SYCL object is destroyed (
111
117
as described in the core SYCL specification under "Common reference semantics"), and the application must not
The application may call the ```get_native<T>()``` member function of a SYCL object to retrieve the underlying Level-Zero handle,
117
-
however, the SYCL runtime continues to retain ownership of this handle, unless SYCL object was created with interoperability API that asked
118
-
to keep the ownership by the application with ```ownership::keep```. The application must not use this handle after the last host copy of
119
-
the SYCL object is destroyed (as described in the core SYCL specification under "Common reference semantics"), and the application must
120
-
not destroy the Level-Zero handle.
121
-
122
-
#### 4.4.3 Application keeps ownership (explicit)
120
+
#### 4.4.2 Application keeps ownership (explicit)
123
121
124
122
If SYCL object is created with an interoperability API explicitly asking to keep the native handle ownership in the application with
125
-
```ownership::keep``` then SYCL RT does not take the ownership and will not destroy the Level-Zero handle at the destruction of the SYCL object.
126
-
Application is responsible for destroying the native handle when it no longer needs it, but not earlier than the SYCL object created with that
127
-
handle is EOL.
123
+
```ownership::keep``` then the SYCL runtime does not take the ownership and will not destroy the Level-Zero handle at the destruction of the SYCL object.
124
+
The application is responsible for destroying the native handle when it no longer needs it, but it must not destroy the
125
+
handle before the last host copy of the SYCL object is destroyed (as described in the core SYCL specification under
126
+
"Common reference semantics").
127
+
128
+
#### 4.4.3 Obtaining native handle does not change ownership
129
+
130
+
The application may call the ```get_native<T>()``` member function of a SYCL object to retrieve the underlying Level-Zero handle.
131
+
Doing so does not change the ownership of the the Level-Zero handle. Therefore, the application may not use this
132
+
handle after the last host copy of the SYCL object is destroyed (as described in the core SYCL specification under
133
+
"Common reference semantics") unless the SYCL object was created by the application with ```ownership::keep```.
128
134
129
135
#### 4.4.4 Considerations for multi-threaded environment
130
136
@@ -137,5 +143,5 @@ the application should not attempt further direct use of those handles.
0 commit comments