Skip to content

Commit 3b97d3c

Browse files
committed
review comments #2
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent c14a67b commit 3b97d3c

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ a SYCL object that encapsulates a corresponding Level-Zero object:
8787
|-------------|:------------|
8888
|``` make<platform>(ze_driver_handle_t);```|Constructs a SYCL platform instance from a Level-Zero ```ze_driver_handle_t```.|
8989
|``` 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.|
9191
|``` 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.|
9292
|``` 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.|
9393
@@ -96,11 +96,17 @@ NOTE: We shall consider adding other interoperability as needed, if possible.
9696
### 4.4 Level-Zero handles' ownership and thread-safety
9797
9898
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
100100
some interoparability API supports overriding this behavior and keep the ownership in the application.
101101
Use this enumeration for explicit specification of the ownership:
102102
``` 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
104110
```
105111
106112
#### 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
110116
The application must not use the Level-Zero handle after the last host copy of the SYCL object is destroyed (
111117
as described in the core SYCL specification under "Common reference semantics"), and the application must not
112118
destroy the Level-Zero handle itself.
113-
114-
#### 4.4.2 SYCL runtime assumes ownership (default)
115119

116-
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)
123121

124122
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```.
128134

129135
#### 4.4.4 Considerations for multi-threaded environment
130136

@@ -137,5 +143,5 @@ the application should not attempt further direct use of those handles.
137143
|Rev|Date|Author|Changes|
138144
|-------------|:------------|:------------|:------------|
139145
|1|2021-01-26|Sergey Maslov|Initial public working draft
140-
|2|2021-02-21|Sergey Maslov|Introduced explicit ownership for context
146+
|2|2021-02-22|Sergey Maslov|Introduced explicit ownership for context
141147

sycl/include/CL/sycl/backend/level_zero.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ namespace level_zero {
5555
// be explicit about the ownership of the native handles used in the
5656
// interop functions below.
5757
//
58-
enum ownership { transfer, keep };
58+
enum class ownership { transfer, keep };
5959

6060
// Implementation of various "make" functions resides in libsycl.so and thus
6161
// their interface needs to be backend agnostic.

0 commit comments

Comments
 (0)