Skip to content

Commit 3840543

Browse files
authored
add specific memory and semaphore enums for CL_DEVICE_HANDLE_LIST_KHR (#956)
* add specific memory and semaphore enums for CL_DEVICE_HANDLE_LIST_KHR * remove CL_DEVICE_HANDLE_LIST_KHR * remove CL_DEVICE_HANDLE_LIST_END_KHR too
1 parent 86019d4 commit 3840543

4 files changed

+71
-66
lines changed

ext/cl_khr_external_memory.asciidoc

+16-16
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ Other related extensions define specific external memory types that may be impor
3030
[cols="1,1,3",options="header",]
3131
|====
3232
| *Date* | *Version* | *Description*
33-
| 2023-05-04 | 0.9.1 | {CL_DEVICE_HANDLE_LIST_KHR} cannot be specified without an external memory handle (provisional).
33+
| 2023-08-01 | 0.9.2 | Changed device handle list enum to the memory-specific {CL_MEM_DEVICE_HANDLE_LIST_KHR} (provisional).
34+
| 2023-05-04 | 0.9.1 | Clarified device handle list enum cannot be specified without an external memory handle (provisional).
3435
| 2021-09-10 | 0.9.0 | Initial version (provisional).
3536
|====
3637

@@ -113,8 +114,8 @@ New properties accepted as _properties_ to {clCreateBufferWithProperties} and {c
113114

114115
[source]
115116
----
116-
CL_DEVICE_HANDLE_LIST_KHR 0x2051
117-
CL_DEVICE_HANDLE_LIST_END_KHR 0
117+
CL_MEM_DEVICE_HANDLE_LIST_KHR 0x2051
118+
CL_MEM_DEVICE_HANDLE_LIST_END_KHR 0
118119
----
119120

120121
New return values from {clGetEventInfo} when _param_name_ is {CL_EVENT_COMMAND_TYPE}:
@@ -192,28 +193,28 @@ Following new properties are added to the list of supported properties by {clCre
192193
[width="100%",cols="<33%,<17%,<50%",options="header"]
193194
|====
194195
| Property | Property Value | Description
195-
| {CL_DEVICE_HANDLE_LIST_KHR}
196+
| {CL_MEM_DEVICE_HANDLE_LIST_KHR}
196197
| {cl_device_id_TYPE}[]
197-
| Specifies the list of OpenCL devices (terminated with {CL_DEVICE_HANDLE_LIST_END_KHR}) to associate with the external memory handle.
198+
| Specifies the list of OpenCL devices (terminated with {CL_MEM_DEVICE_HANDLE_LIST_END_KHR}) to associate with the external memory handle.
198199
|====
199200

200-
If {CL_DEVICE_HANDLE_LIST_KHR} is not specified as part of _properties_, the memory object created by {clCreateBufferWithProperties} or {clCreateImageWithProperties} is by default accessible to all devices in the _context_.
201+
If {CL_MEM_DEVICE_HANDLE_LIST_KHR} is not specified as part of _properties_, the memory object created by {clCreateBufferWithProperties} or {clCreateImageWithProperties} is by default accessible to all devices in the _context_.
201202

202203
The properties used to create a buffer or image from an external memory handle are described by related extensions.
203204
When a buffer or image is created from an external memory handle, the _flags_ used to specify usage information for the buffer or image must not include {CL_MEM_USE_HOST_PTR}, {CL_MEM_ALLOC_HOST_PTR}, or {CL_MEM_COPY_HOST_PTR}, and the _host_ptr_ argument must be `NULL`.
204205

205206
Add to the list of error conditions for {clCreateBufferWithProperties} and {clCreateImageWithProperties}:
206207

207208
* {CL_INVALID_DEVICE}
208-
** if a device identified by the property {CL_DEVICE_HANDLE_LIST_KHR} is not a valid device or is not associated with _context_, or
209-
** if a device identified by property {CL_DEVICE_HANDLE_LIST_KHR} cannot import the requested external memory object type, or
210-
** if {CL_DEVICE_HANDLE_LIST_KHR} is not specified as part of _properties_ and one or more devices in _context_ cannot import the requested external memory object type.
209+
** if a device identified by the property {CL_MEM_DEVICE_HANDLE_LIST_KHR} is not a valid device or is not associated with _context_, or
210+
** if a device identified by property {CL_MEM_DEVICE_HANDLE_LIST_KHR} cannot import the requested external memory object type, or
211+
** if {CL_MEM_DEVICE_HANDLE_LIST_KHR} is not specified as part of _properties_ and one or more devices in _context_ cannot import the requested external memory object type.
211212
* {CL_INVALID_VALUE}
212213
** if _properties_ includes a supported external memory handle and _flags_ includes {CL_MEM_USE_HOST_PTR}, {CL_MEM_ALLOC_HOST_PTR}, or {CL_MEM_COPY_HOST_PTR}.
213214
* {CL_INVALID_HOST_PTR}
214215
** if _properties_ includes a supported external memory handle and _host_ptr_ is not `NULL`.
215216
* {CL_INVALID_PROPERTY}
216-
** if _properties_ does not include a supported external memory handle and {CL_DEVICE_HANDLE_LIST_KHR} is specified as part of _properties_.
217+
** if _properties_ does not include a supported external memory handle and {CL_MEM_DEVICE_HANDLE_LIST_KHR} is specified as part of _properties_.
217218

218219
Add images created from an external memory handle to the description of `image_row_pitch` and `image_slice_pitch` for {cl_image_desc_TYPE}:
219220

@@ -288,7 +289,7 @@ Otherwise, it returns one of the following errors:
288289
* {CL_INVALID_MEM_OBJECT} if any of the memory objects in _mem_objects_ is not a valid OpenCL memory object created using an external memory handle.
289290
* {CL_INVALID_COMMAND_QUEUE}
290291
** if _command_queue_ is not a valid command-queue, or
291-
** if device associated with _command_queue_ is not one of the devices specified by {CL_DEVICE_HANDLE_LIST_KHR} at the time of creating one or more of _mem_objects_, or
292+
** if device associated with _command_queue_ is not one of the devices specified by {CL_MEM_DEVICE_HANDLE_LIST_KHR} at the time of creating one or more of _mem_objects_, or
292293
** if one or more of _mem_objects_ belong to a context that does not contain a device associated with _command_queue_.
293294
* {CL_INVALID_EVENT_WAIT_LIST}
294295
** if _event_wait_list_ is `NULL` and _num_events_in_wait_list_ is not 0, or
@@ -333,7 +334,7 @@ Otherwise, it returns one of the following errors:
333334
* {CL_INVALID_MEM_OBJECT} if any of the memory objects in _mem_objects_ is not a valid OpenCL memory object created using an external memory handle.
334335
* {CL_INVALID_COMMAND_QUEUE}
335336
** if _command_queue_ is not a valid command-queue, or
336-
** if device associated with _command_queue_ is not one of the devices specified by {CL_DEVICE_HANDLE_LIST_KHR} at the time of creating one or more of _mem_objects_, or
337+
** if device associated with _command_queue_ is not one of the devices specified by {CL_MEM_DEVICE_HANDLE_LIST_KHR} at the time of creating one or more of _mem_objects_, or
337338
** if one or more of _mem_objects_ belong to a context that does not contain a device associated with _command_queue_.
338339
* {CL_INVALID_EVENT_WAIT_LIST}
339340
** if _event_wait_list_ is `NULL` and _num_events_in_wait_list_ is not 0, or
@@ -461,13 +462,12 @@ image_desc.num_mip_levels = 1;
461462
image_desc.num_samples = 0;
462463
image_desc.buffer = NULL;
463464
464-
cl_mem_properties_khr extMemProperties[] =
465-
{
465+
cl_mem_properties_khr extMemProperties[] = {
466466
(cl_mem_properties_khr)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR,
467467
(cl_mem_properties_khr)fd,
468-
(cl_mem_properties_khr)CL_DEVICE_HANDLE_LIST_KHR,
468+
(cl_mem_properties_khr)CL_MEM_DEVICE_HANDLE_LIST_KHR,
469469
(cl_mem_properties_khr)devices[0],
470-
CL_DEVICE_HANDLE_LIST_END_KHR,
470+
CL_MEM_DEVICE_HANDLE_LIST_END_KHR,
471471
0
472472
};
473473

ext/cl_khr_external_semaphore.asciidoc

+23-23
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ Following new properties are added to the list of possible supported properties
217217

218218
Add to the list of error conditions for {clCreateSemaphoreWithPropertiesKHR}:
219219

220-
* {CL_INVALID_DEVICE} if one or more devices identified by properties {CL_DEVICE_HANDLE_LIST_KHR} can not import the requested external semaphore handle type.
220+
* {CL_INVALID_DEVICE} if one or more devices identified by properties {CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR} can not import the requested external semaphore handle type.
221221

222222
{clCreateSemaphoreWithPropertiesKHR} may return a NULL value on some implementations if _sema_props_ does not contain an external semaphore handle type to import.
223223
Such implementations are required to return a valid semaphore when a supported external memory handle type and valid external semaphore handle is specified.
@@ -472,18 +472,18 @@ clCreateContext(..., 2, devices, ...);
472472
// from the other API.
473473
int fd = getFdForExternalSemaphore();
474474
475-
// Create clSema of type cl_semaphore_khr usable only on devices[1]
475+
// Create clSema of type cl_semaphore_khr usable only on device 1
476476
// assuming the semaphore was imported from the same device.
477-
478-
cl_semaphore_properties_khr sema_props[] =
479-
{(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR,
480-
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR,
481-
(cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR,
482-
(cl_semaphore_properties_khr)fd,
483-
(cl_semaphore_properties_khr)CL_DEVICE_HANDLE_LIST_KHR,
484-
(cl_semaphore_properties_khr)devices[1], CL_DEVICE_HANDLE_LIST_END_KHR,
485-
0};
486-
477+
cl_semaphore_properties_khr sema_props[] = {
478+
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR,
479+
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR,
480+
(cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR,
481+
(cl_semaphore_properties_khr)fd,
482+
(cl_semaphore_properties_khr)CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR,
483+
(cl_semaphore_properties_khr)devices[1],
484+
CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR,
485+
0
486+
};
487487
488488
int errcode_ret = 0;
489489
cl_semaphore_khr clSema = clCreateSemaphoreWithPropertiesKHR(context,
@@ -546,16 +546,17 @@ clGetDeviceIDs(..., &devices, &deviceCount);
546546
clCreateContext(..., 2, devices, ...);
547547
548548
// Create clSema of type cl_semaphore_khr usable only on device 1
549-
cl_semaphore_properties_khr sema_props[] =
550-
{(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR,
551-
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR,
552-
(cl_semaphore_properties_khr)CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR,
553-
(cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR,
554-
CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR,
555-
(cl_semaphore_properties_khr)CL_DEVICE_HANDLE_LIST_KHR,
556-
(cl_semaphore_properties_khr)devices[1],
557-
CL_DEVICE_HANDLE_LIST_END_KHR,
558-
0};
549+
cl_semaphore_properties_khr sema_props[] = {
550+
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR,
551+
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR,
552+
(cl_semaphore_properties_khr)CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR,
553+
(cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR,
554+
CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR,
555+
(cl_semaphore_properties_khr)CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR,
556+
(cl_semaphore_properties_khr)devices[1],
557+
CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR,
558+
0
559+
};
559560
560561
int errcode_ret = 0;
561562
cl_semaphore_khr clSema = clCreateSemaphoreWithPropertiesKHR(context,
@@ -606,7 +607,6 @@ while (true) {
606607
/*event*/ NULL);
607608
608609
// (not shown) Launch work in the other API that waits on 'clSema'
609-
610610
}
611611
----
612612
--

ext/cl_khr_semaphore.asciidoc

+22-20
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ In particular, this extension defines:
3737
[cols="1,1,3",options="header",]
3838
|====
3939
| *Date* | *Version* | *Description*
40+
| 2023-08-01 | 0.9.1 | Changed device handle list enum to the semaphore-specific {CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR} (provisional).
4041
| 2021-09-10 | 0.9.0 | Initial version (provisional).
4142
|====
4243

@@ -154,16 +155,16 @@ CL_SEMAPHORE_PROPERTIES_KHR 0x203B
154155
CL_SEMAPHORE_PAYLOAD_KHR 0x203C
155156
----
156157

157-
// TODO: We don't need an enum assigned for CL_DEVICE_HANDLE_LIST_END_KHR and should just use 0.
158-
// TODO: Do we need to define CL_DEVICE_HANDLE_LIST here or should it be in the external semaphore spec instead?
158+
// TODO: We don't need an enum assigned for CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR and should just use 0.
159+
// TODO: Do we need to define CL_SEMAPHORE_DEVICE_HANDLE_LIST here or should it be in the external semaphore spec instead?
159160

160161
New attributes that can be passed as part of {cl_semaphore_info_khr_TYPE} or {cl_semaphore_properties_khr_TYPE}:
161162

162163
[source]
163164
----
164165
CL_SEMAPHORE_TYPE_KHR 0x203D
165-
CL_DEVICE_HANDLE_LIST_KHR 0x2051
166-
CL_DEVICE_HANDLE_LIST_END_KHR 0
166+
CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR 0x2053
167+
CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR 0
167168
----
168169

169170
New return values from {clGetEventInfo} when _param_name_ is {CL_EVENT_COMMAND_TYPE}:
@@ -243,7 +244,7 @@ include::{generated}/api/protos/clCreateSemaphoreWithPropertiesKHR.txt[]
243244

244245
_context_ identifies a valid OpenCL context that the created {cl_semaphore_khr_TYPE} will belong to.
245246

246-
// TODO: Do we want the same "all devices in the context" behavior if CL_DEVICE_HANDLE_LIST_KHR is not specified?
247+
// TODO: Do we want the same "all devices in the context" behavior if CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR is not specified?
247248

248249
_sema_props_ specifies additional semaphore properties in the form list of <property_name, property_value> pairs terminated with 0.
249250
{CL_SEMAPHORE_TYPE_KHR} must be part of the list of properties specified by _sema_props_.
@@ -257,12 +258,12 @@ Following new properties are added to the list of possible supported properties
257258
| {CL_SEMAPHORE_TYPE_KHR}
258259
| {cl_semaphore_type_khr_TYPE}
259260
| Specifies the type of semaphore to create. This property is always required.
260-
| {CL_DEVICE_HANDLE_LIST_KHR}
261+
| {CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR}
261262
| {cl_device_id_TYPE}[]
262-
| Specifies the list of OpenCL devices (terminated with {CL_DEVICE_HANDLE_LIST_END_KHR}) to associate with the semaphore.
263+
| Specifies the list of OpenCL devices (terminated with {CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR}) to associate with the semaphore.
263264
|====
264265

265-
If {CL_DEVICE_HANDLE_LIST_KHR} is not specified as part of _sema_props_, the semaphore object created by {clCreateSemaphoreWithPropertiesKHR} is by default accessible to all devices in the _context_.
266+
If {CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR} is not specified as part of _sema_props_, the semaphore object created by {clCreateSemaphoreWithPropertiesKHR} is by default accessible to all devices in the _context_.
266267

267268
_errcode_ret_ returns an appropriate error code. If _errcode_ret_ is `NULL`, no error code is returned.
268269

@@ -271,7 +272,7 @@ Otherwise, it returns a `NULL` value with one of the following error values retu
271272

272273
* {CL_INVALID_CONTEXT} if _context_ is not a valid context.
273274
* {CL_INVALID_PROPERTY} if a property name in _sema_props_ is not a supported property name, if the value specified for a supported property name is not valid, or if the same property name is specified more than once.
274-
* {CL_INVALID_DEVICE} if {CL_DEVICE_HANDLE_LIST_KHR} is specified as part of _sema_props_, but it does not identify a valid device or if a device identified by {CL_DEVICE_HANDLE_LIST_KHR} is not one of the devices within _context_.
275+
* {CL_INVALID_DEVICE} if {CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR} is specified as part of _sema_props_, but it does not identify a valid device or if a device identified by {CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR} is not one of the devices within _context_.
275276
* {CL_INVALID_VALUE}
276277
** if _sema_props_ is `NULL`, or
277278
** if _sema_props_ do not specify <property, value> pairs for minimum set of properties (i.e. {CL_SEMAPHORE_TYPE_KHR}) required for successful creation of a {cl_semaphore_khr_TYPE}, or
@@ -315,7 +316,7 @@ Otherwise, it returns one of the following errors:
315316

316317
* {CL_INVALID_COMMAND_QUEUE}
317318
** if _command_queue_ is not a valid command-queue, or
318-
** if the device associated with _command_queue_ is not same as one of the devices specified by {CL_DEVICE_HANDLE_LIST_KHR} at the time of creating one or more of _sema_objects_, or
319+
** if the device associated with _command_queue_ is not same as one of the devices specified by {CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR} at the time of creating one or more of _sema_objects_, or
319320
** if one or more of _sema_objects_ belong to a context that does not contain a device associated with _command_queue_.
320321
* {CL_INVALID_VALUE} if _num_sema_objects_ is 0.
321322
* {CL_INVALID_SEMAPHORE_KHR} if any of the semaphore objects specified by _sema_objects_ is not valid.
@@ -366,7 +367,7 @@ Otherwise, it returns one of the following errors:
366367

367368
* {CL_INVALID_COMMAND_QUEUE}
368369
** if _command_queue_ is not a valid command-queue, or
369-
** if the device associated with _command_queue_ is not same as one of the devices specified by {CL_DEVICE_HANDLE_LIST_KHR} at the time of creating one or more of _sema_objects_, or
370+
** if the device associated with _command_queue_ is not same as one of the devices specified by {CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR} at the time of creating one or more of _sema_objects_, or
370371
** if one or more of _sema_objects_ belong to a context that does not contain a device associated with _command_queue_.
371372
* {CL_INVALID_VALUE} if _num_sema_objects_ is 0
372373
* {CL_INVALID_SEMAPHORE_KHR} if any of the semaphore objects specified by _sema_objects_ is not valid.
@@ -429,7 +430,7 @@ being queried by _param_value_. If _param_value_size_ret_ is `NULL`, it is ignor
429430
if the semaphore is in an un-signaled state and `1` if it is in a
430431
signaled state.
431432

432-
| {CL_DEVICE_HANDLE_LIST_KHR}
433+
| {CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR}
433434
| {cl_device_id_TYPE}[]
434435
| Returns the list of OpenCL devices the semaphore is associated with.
435436
|====
@@ -524,14 +525,15 @@ clGetDeviceIDs(..., &devices, &deviceCount);
524525
// Create cl_context with first two devices
525526
clCreateContext(..., 2, devices, ...);
526527
527-
// Create clSema of type cl_semaphore_khr usable only on devices[0]
528-
529-
cl_semaphore_properties_khr sema_props[] =
530-
{(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR,
531-
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR,
532-
(cl_semaphore_properties_khr)CL_DEVICE_HANDLE_LIST_KHR,
533-
(cl_semaphore_properties_khr)devices[0], CL_DEVICE_HANDLE_LIST_END_KHR,
534-
0};
528+
// Create clSema of type cl_semaphore_khr usable only on device 0
529+
cl_semaphore_properties_khr sema_props[] = {
530+
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR,
531+
(cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR,
532+
(cl_semaphore_properties_khr)CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR,
533+
(cl_semaphore_properties_khr)devices[0],
534+
CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR,
535+
0
536+
};
535537
536538
int errcode_ret = 0;
537539

0 commit comments

Comments
 (0)