|
| 1 | +// Copyright 2018-2025 The Khronos Group. This work is licensed under a |
| 2 | +// Creative Commons Attribution 4.0 International License; see |
| 3 | +// http://creativecommons.org/licenses/by/4.0/ |
| 4 | + |
| 5 | +:data-uri: |
| 6 | +:icons: font |
| 7 | +include::../config/attribs.txt[] |
| 8 | +:source-highlighter: coderay |
| 9 | + |
| 10 | += cl_img_safety_mechanisms |
| 11 | + |
| 12 | +== Name Strings |
| 13 | + |
| 14 | +`cl_img_safety_mechanisms` + |
| 15 | +`cl_img_workgroup_protection` + |
| 16 | +`cl_img_enhanced_event_execution_status` |
| 17 | + |
| 18 | +`cl_img_safety_mechanisms` will be reported if `cl_img_workgroup_protection` or `cl_img_enhanced_event_execution_status` is present. |
| 19 | + |
| 20 | +== Contact |
| 21 | + |
| 22 | +Imagination Technologies Developer Forum: + |
| 23 | +https://forums.imgtec.com/ |
| 24 | + |
| 25 | +Ahmed Amrani Akdi, Imagination Technologies (Ahmed.Akdi 'at' imgtec.com) |
| 26 | + |
| 27 | +== Contributors |
| 28 | + |
| 29 | +Jeremy Kemp, Imagination Technologies |
| 30 | +Ahmed Amrani Akdi, Imagination Technologies |
| 31 | + |
| 32 | +== Notice |
| 33 | + |
| 34 | +Copyright (c) 2020-2025 Imagination Technologies Ltd. All Rights Reserved. |
| 35 | + |
| 36 | +== Status |
| 37 | + |
| 38 | +Shipping. |
| 39 | + |
| 40 | +== Version |
| 41 | + |
| 42 | +Built On: {docdate} + |
| 43 | +Version: 1.0.0 |
| 44 | + |
| 45 | +== Dependencies |
| 46 | + |
| 47 | +This extension is written against the OpenCL Specification |
| 48 | +Version 3.0.5. |
| 49 | + |
| 50 | +This extension requires OpenCL 3.0 or later. |
| 51 | + |
| 52 | +== Overview |
| 53 | + |
| 54 | +This extension allows applications to enable safety features to help detect and recover from faults that may result in unexpected behaviour. |
| 55 | + |
| 56 | +== New API Types |
| 57 | + |
| 58 | +[source,c] |
| 59 | +---- |
| 60 | +typedef cl_bitfield cl_context_safety_properties_img; |
| 61 | +---- |
| 62 | + |
| 63 | +== New API Enums |
| 64 | + |
| 65 | +Additional _properties_ values that can be passed to `clCreateContext` or `clCreateContextFromType`: |
| 66 | + |
| 67 | +[source,c] |
| 68 | +---- |
| 69 | +#define CL_CONTEXT_SAFETY_PROPERTIES_IMG 0x40D9 |
| 70 | +---- |
| 71 | + |
| 72 | +Valid property values for `cl_context_safety_properties_img` where _properties_ is `CL_CONTEXT_SAFETY_PROPERTIES_IMG` when passed to `clCreateContext` or `clCreateContextFromType`: |
| 73 | + |
| 74 | +[source,c] |
| 75 | +---- |
| 76 | +#define CL_CONTEXT_WORKGROUP_PROTECTION_IMG (1 << 0) |
| 77 | +#define CL_CONTEXT_ENHANCED_EVENT_EXECUTION_STATUS_IMG (1 << 1) |
| 78 | +---- |
| 79 | + |
| 80 | +Additional _param_name_ values that can be passed to `clGetDeviceInfo`: |
| 81 | +[source,c] |
| 82 | +---- |
| 83 | +#define CL_DEVICE_WORKGROUP_PROTECTION_SVM_CAPABILITIES_IMG 0x40DA |
| 84 | +#define CL_DEVICE_WORKGROUP_PROTECTION_DEVICE_ENQUEUE_CAPABILITIES_IMG 0x40DB |
| 85 | +#define CL_DEVICE_SAFETY_MEM_SIZE_IMG 0x40DC |
| 86 | +---- |
| 87 | + |
| 88 | +Additional values that can be returned in _param_value_ when *clGetEventInfo* is called with `CL_EVENT_COMMAND_EXECUTION_STATUS` given as _param_name_: |
| 89 | + |
| 90 | +[source,c] |
| 91 | +---- |
| 92 | +#define CL_ECC_RECOVERED_IMG 0x40DD |
| 93 | +#define CL_PAGE_FAULT_IMG -1127 |
| 94 | +#define CL_SAFETY_FAULT_IMG -1128 |
| 95 | +#define CL_GENERAL_FAULT_IMG -1129 |
| 96 | +#define CL_ECC_UNRECOVERED_IMG -1130 |
| 97 | +---- |
| 98 | + |
| 99 | +== Modifications to the OpenCL API Specification |
| 100 | + |
| 101 | +(Modify Section 4.2, *Querying Devices*) :: |
| 102 | ++ |
| 103 | +-- |
| 104 | +(Add the following to Table 5. List of supported _param_names_ by `clGetDeviceInfo`) :: |
| 105 | ++ |
| 106 | +[cols="1,1,4",options="header"] |
| 107 | +|==== |
| 108 | +| Device Info |
| 109 | +| Return Type |
| 110 | +| Description |
| 111 | + |
| 112 | +| `CL_DEVICE_WORKGROUP_PROTECTION_SVM_CAPABILITIES_IMG` |
| 113 | +Missing before version 2.0. |
| 114 | +| `cl_device_svm_capabilities` |
| 115 | + |
| 116 | +| Describes the various shared virtual memory (SVM) memory allocation types the device supports when operating with workgroup protection enabled. Contexts created with the `CL_CONTEXT_WORKGROUP_PROTECTION_IMG` property value are considered to have workgroup protection enabled. This parameter is present when the `cl_img_workgroup_protection` extension is present. This is a bit-field that describes a combination of the following values: |
| 117 | + |
| 118 | +`CL_DEVICE_SVM_COARSE_GRAIN_BUFFER` - Support for coarse-grain buffer sharing using `clSVMAlloc`. Memory consistency is guaranteed at synchronization points and the host must use calls to clEnqueueMapBuffer and `clEnqueueUnmapMemObject`. |
| 119 | +`CL_DEVICE_SVM_FINE_GRAIN_BUFFER` - Support for fine-grain buffer sharing using `clSVMAlloc`. Memory consistency is guaranteed at synchronization points without need for clEnqueueMapBuffer and `clEnqueueUnmapMemObject`. |
| 120 | +`CL_DEVICE_SVM_FINE_GRAIN_SYSTEM` - Support for sharing the host’s entire virtual memory including memory allocated using `malloc`. Memory consistency is guaranteed at synchronization points. |
| 121 | +`CL_DEVICE_SVM_ATOMICS` - Support for the OpenCL 2.0 atomic operations that provide memory consistency across the host and all OpenCL devices supporting fine-grain SVM allocations. |
| 122 | + |
| 123 | +The mandated minimum capability for an OpenCL 2.0, 2.1, or 2.2 device is `CL_DEVICE_SVM_COARSE_GRAIN_BUFFER`. |
| 124 | + |
| 125 | +For other device versions there is no mandated minimum capability. |
| 126 | + |
| 127 | +|`CL_DEVICE_WORKGROUP_PROTECTION_DEVICE_ENQUEUE_CAPABILITIES_IMG` |
| 128 | + |
| 129 | +|`cl_device_device_enqueue_capabilities` |
| 130 | +| May return 0, indicating that device does not support device-side enqueue and on-device queues when operating with workgroup protection enabled. Otherwise, describes device-side enqueue capabilities of the device. This is a bit-field that describes one or more of the following values: |
| 131 | + |
| 132 | +`CL_DEVICE_QUEUE_SUPPORTED` - Device supports device-side enqueue and on-device queues. |
| 133 | +`CL_DEVICE_QUEUE_REPLACEABLE_DEFAULT` - Device supports a replaceable default on-device queue. |
| 134 | + |
| 135 | +If `CL_DEVICE_QUEUE_REPLACEABLE_DEFAULT` is set, `CL_DEVICE_QUEUE_SUPPORTED` must also be set. |
| 136 | + |
| 137 | +Devices that set `CL_DEVICE_QUEUE_SUPPORTED` for `CL_DEVICE_WORKGROUP_PROTECTION_DEVICE_ENQUEUE_CAPABILITIES_IMG` must also return `CL_TRUE` for `CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT`. |
| 138 | + |
| 139 | +|`CL_DEVICE_SAFETY_MEM_SIZE_IMG` |
| 140 | + |
| 141 | +|`cl_ulong` |
| 142 | + |
| 143 | +| May return 0, indicating that device does not support workgroup protection. Otherwise, returns the size of the memory where memory objects are allocated when operating with workgroup protection enabled. |
| 144 | +|==== |
| 145 | +-- |
| 146 | + |
| 147 | +(Modify Section 4.4, *Contexts*) :: |
| 148 | ++ |
| 149 | +-- |
| 150 | + |
| 151 | +(Add the following to Table 7. List of supported context creation properties by `clCreateContext`) :: |
| 152 | ++ |
| 153 | +[cols="1,1,4",options="header"] |
| 154 | +|==== |
| 155 | +| Context Property |
| 156 | +| Property Value |
| 157 | +| Description |
| 158 | + |
| 159 | +| `CL_CONTEXT_SAFETY_PROPERTIES_IMG` |
| 160 | +| `cl_context_safety_properties_img` |
| 161 | +| This bitfield allows a context to be created with a range of safety mechanisms that will apply to all commands enqueued to the context when the `cl_img_safety_mechanisms` extension is present. |
| 162 | + |
| 163 | + If `CL_CONTEXT_WORKGROUP_PROTECTION_IMG` is specified, all kernel commands enqueued to this context will enable error checking at the workgroup level to verify that all memory operations within each workgroup workgroup perform as expected. This may effect performance. This property requires the `cl_img_workgroup_protection` extension to be present. |
| 164 | + |
| 165 | + If `CL_CONTEXT_ENHANCED_EVENT_EXECUTION_STATUS_IMG` is specified, additional event execution status' will be available. This property requires the `cl_img_enhanced_event_execution_status` extension to be present. |
| 166 | +-- |
| 167 | + |
| 168 | +(Modify Section 5.11, *Event Objects*) :: |
| 169 | ++ |
| 170 | +-- |
| 171 | + |
| 172 | +(Add the following to the second paragraph) :: |
| 173 | ++ |
| 174 | +When the `cl_img_safety_mechanisms` extension is present, an event object must be passed to _event_ for every clEnqueue* call where the _context_ associated with _command_queue_ was created with the `CL_CONTEXT_WORKGROUP_PROTECTION_IMG` property value. It is strongly recommended that the execution state of every event object is queried to check for completeness or errors. Not passing a valid event object to _event_ will to cause `clEnqueue*` to return `CL_INVALID_EVENT`. |
| 175 | + |
| 176 | +(Add the following bullets to _The execution status of an enqueued command at any given point in time can be one of the following:_) :: |
| 177 | ++ |
| 178 | +* `CL_PAGE_FAULT_IMG` This indicates that the command was present during execution that resulted in a page fault and is an error code. This status can only be reported if the `cl_img_enhanced_event_execution_status` extension is present. |
| 179 | +* `CL_SAFETY_FAULT_IMG` This indicates that the command was present during execution that resulted in workgroup protection identifying an error with the command and is an error code. This status can only be reported if the the associated _context_ was created with the `CL_CONTEXT_WORKGROUP_PROTECTION_IMG` property value, and the `cl_img_enhanced_event_execution_status` and `cl_img_workgroup_protection` extensions are present. |
| 180 | +* `CL_GENERAL_FAULT_IMG` This indicates that the command was present during execution that resulted in an error with the command and is an error code. This status can only be reported if the `cl_img_enhanced_event_execution_status` extension is present. |
| 181 | +* `CL_ECC_RECOVERED_IMG` This indicates that the command has successfully completed and is considered to have the same semantics as `CL_COMPLETE`. It also indicates that the command was present during execution that resulted in an ECC event where memory was successfully self-corrected. This status can only be reported when `CL_DEVICE_ERROR_CORRECTION_SUPPORT` is `CL_TRUE` and the `cl_img_enhanced_event_execution_status` extension is present. This is not an error code. |
| 182 | +* `CL_ECC_UNRECOVERED_IMG` This indicates that the command was present during execution that resulted in an ECC event where memory was not successfully self-corrected and is an error code. This status can only be reported when `CL_DEVICE_ERROR_CORRECTION_SUPPORT` is `CL_TRUE` and the `cl_img_enhanced_event_execution_status` extension is present. |
| 183 | + |
| 184 | +(Add the following to Table 36. List of supported param_names by clGetEventInfo) :: |
| 185 | ++ |
| 186 | +[cols="1,1,4",options="header"] |
| 187 | +|==== |
| 188 | +| Event Info |
| 189 | +| Return Type |
| 190 | +| Info. returned in _param_value_ |
| 191 | + |
| 192 | +| `CL_EVENT_COMMAND_EXECUTION_STATUS` |
| 193 | +| `cl_int` |
| 194 | +| `CL_PAGE_FAULT_IMG` (during execution, the command was present during a page fault and should be considered to have failed execution) |
| 195 | + |
| 196 | +`CL_SAFETY_FAULT_IMG` (during execution, this command was present when workgroup protection detected an error and should be considered to have failed execution) |
| 197 | + |
| 198 | +`CL_GENERAL_FAULT_IMG` (during execution, the command was present during a general fault and should be considered to have failed execution) |
| 199 | + |
| 200 | +`CL_ECC_RECOVERED_IMG` (during execution, the command was present during an ECC event where the memory successfully self-corrected. This can be considered to have the same semantics as `CL_COMPLETE` and should not be considered to have failed execution) |
| 201 | + |
| 202 | +`CL_ECC_UNRECOVERED_IMG` (during execution, the command was present during an ECC event where the memory did not successfully self-correct and should be considered to have failed execution) |
| 203 | +|==== |
| 204 | +-- |
| 205 | + |
| 206 | +== Interactions with Other Extensions |
| 207 | + |
| 208 | +If `cl_khr_priority_hints` is supported then any command queue created with either `clCreateCommandQueue` or `clCreateCommandQueueWithProperties` where _context_ has the `CL_CONTEXT_SAFETY_PROPERTIES_IMG` and `CL_QUEUE_PRIORITY_KHR` properties then the requested priority will be ignored. |
| 209 | + |
| 210 | +== Issues |
| 211 | + |
| 212 | +== Version History |
| 213 | + |
| 214 | +[cols="5,15,15,70"] |
| 215 | +[grid="rows"] |
| 216 | +[options="header"] |
| 217 | +|==== |
| 218 | +| Version | Date | Author | Changes |
| 219 | +| 1.0.0 | 2025-07-08 | Ahmed Amrani Akdi | *Updated to 1.0.0 version for publishing.* |
| 220 | +| 0.6.0 | 2025-05-02 | Ahmed Amrani Akdi | *Added `CL_DEVICE_SAFETY_MEM_SIZE_IMG`* |
| 221 | +| 0.5.0 | 2022-01-17 | Jeremy Kemp | *Added `CL_DEVICE_WORKGROUP_PROTECTION_DEVICE_ENQUEUE_CAPABILITIES_IMG`* |
| 222 | +| 0.4.0 | 2020-12-03 | Jeremy Kemp | *Added event execution status as extension. Tidy up* |
| 223 | +| 0.3.0 | 2020-11-25 | Jeremy Kemp | *Added SVM queries. Added new event status codes. Lots of additional updates and fixes* |
| 224 | +| 0.2.1 | 2020-11-06 | Jeremy Kemp | *Resolved Issue 3. Removed `cl_arm_import_memory` restriction* |
| 225 | +| 0.2.0 | 2020-10-09 | Jeremy Kemp | *Resolved Issue 3. Removed `cl_img_command_status_query`. Typo fixes* |
| 226 | +| 0.1.0 | 2020-10-02 | Jeremy Kemp | *Initial revision* |
| 227 | +|==== |
0 commit comments