|
| 1 | += cl_intel_program_scope_host_pipe |
| 2 | + |
| 3 | +// This section needs to be after the document title. |
| 4 | +:doctype: book |
| 5 | +:toc2: |
| 6 | +:toc: left |
| 7 | +:encoding: utf-8 |
| 8 | +:lang: en |
| 9 | + |
| 10 | +:blank: pass:[ +] |
| 11 | + |
| 12 | +// Set the default source code type in this document to C++, |
| 13 | +// for syntax highlighting purposes. This is needed because |
| 14 | +// docbook uses c++ and html5 uses cpp. |
| 15 | +:language: {basebackend@docbook:c++:cpp} |
| 16 | + |
| 17 | +== Name Strings |
| 18 | + |
| 19 | +`cl_intel_program_scope_host_pipe` |
| 20 | + |
| 21 | +== Contact |
| 22 | + |
| 23 | +Zibai Wang, Intel (zibai 'dot' wang 'at' intel 'dot' com) |
| 24 | + |
| 25 | +== Contributors |
| 26 | + |
| 27 | +Bo Lei, Intel + |
| 28 | +Marco Jacques, Intel + |
| 29 | +Robert Ho, Intel + |
| 30 | +Zibai Wang, Intel + |
| 31 | + |
| 32 | +== Notice |
| 33 | + |
| 34 | +Copyright (c) 2023 Intel Corporation. All rights reserved. |
| 35 | + |
| 36 | +== Status |
| 37 | + |
| 38 | +Final Draft |
| 39 | + |
| 40 | +== Version |
| 41 | + |
| 42 | +Built On: {docdate} + |
| 43 | + |
| 44 | +== Dependencies |
| 45 | + |
| 46 | +This extension is written against the OpenCL API Specification Version 3.0.7. |
| 47 | + |
| 48 | +Program scope pipes cannot be expressed in the OpenCL kernel language. But, they can be expressed through SPIR-V entry. These runtime APIs are only relevant for kernels created from SPIR-V. |
| 49 | + |
| 50 | + |
| 51 | +== Overview |
| 52 | + |
| 53 | +This extension adds the ability to send data between host and device through program scope pipes. |
| 54 | + |
| 55 | + |
| 56 | +== New API Functions |
| 57 | + |
| 58 | +[source, c] |
| 59 | +---- |
| 60 | +cl_int clEnqueueReadHostPipeINTEL( |
| 61 | + cl_command_queue command_queue, |
| 62 | + cl_program program, |
| 63 | + const char* pipe_symbol, |
| 64 | + cl_bool blocking_read, |
| 65 | + void* ptr, |
| 66 | + size_t size, |
| 67 | + cl_uint num_events_in_wait_list, |
| 68 | + const cl_event* event_wait_list, |
| 69 | + cl_event* event); |
| 70 | +
|
| 71 | +cl_int clEnqueueWriteHostPipeINTEL( |
| 72 | + cl_command_queue command_queue, |
| 73 | + cl_program program, |
| 74 | + const char* pipe_symbol, |
| 75 | + cl_bool blocking_write, |
| 76 | + const void* ptr, |
| 77 | + size_t size, |
| 78 | + cl_uint num_events_in_wait_list, |
| 79 | + const cl_event* event_wait_list, |
| 80 | + cl_event* event); |
| 81 | +---- |
| 82 | + |
| 83 | + |
| 84 | +== New API Enums |
| 85 | + |
| 86 | +New return values from clGetEventInfo when param_name is CL_EVENT_COMMAND_TYPE: |
| 87 | + |
| 88 | +[source, c] |
| 89 | +---- |
| 90 | +#define CL_COMMAND_READ_HOST_PIPE_INTEL 0x4214 |
| 91 | +#define CL_COMMAND_WRITE_HOST_PIPE_INTEL 0x4215 |
| 92 | +#define CL_PROGRAM_NUM_HOST_PIPES_INTEL 0x4216 |
| 93 | +#define CL_PROGRAM_HOST_PIPE_NAMES_INTEL 0x4217 |
| 94 | +---- |
| 95 | + |
| 96 | + |
| 97 | +== Modifications to the OpenCL API Specification |
| 98 | + |
| 99 | +=== New Section "Program Scope Pipes" |
| 100 | + |
| 101 | +Add a new subsection under Section 5, *The OpenCL Runtime* named *Program Scope Pipes* with the following content: |
| 102 | + |
| 103 | +Program scope pipes (also referred to as host pipes) are a new concept to OpenCL. Unlike regular pipes, program scope pipes are statically allocated in the device code and accessible from the host, whereas regular pipes are allocated by the OpenCL runtime and passed to the device. |
| 104 | + |
| 105 | + |
| 106 | +The following functions enqueue commands to read or write data through pipes on the host: |
| 107 | + |
| 108 | +[source, c] |
| 109 | +---- |
| 110 | +cl_int clEnqueueReadHostPipeINTEL( |
| 111 | + cl_command_queue command_queue, |
| 112 | + cl_program program, |
| 113 | + const char* pipe_symbol, |
| 114 | + cl_bool blocking_read, |
| 115 | + void* ptr, |
| 116 | + size_t size, |
| 117 | + cl_uint num_events_in_wait_list, |
| 118 | + const cl_event* event_wait_list, |
| 119 | + cl_event* event); |
| 120 | +
|
| 121 | +cl_int clEnqueueWriteHostPipeINTEL( |
| 122 | + cl_command_queue command_queue, |
| 123 | + cl_program program, |
| 124 | + const char* pipe_symbol, |
| 125 | + cl_bool blocking_write, |
| 126 | + const void* ptr, |
| 127 | + size_t size, |
| 128 | + cl_uint num_events_in_wait_list, |
| 129 | + const cl_event* event_wait_list, |
| 130 | + cl_event* event); |
| 131 | +---- |
| 132 | + |
| 133 | + |
| 134 | +* _command_queue_ is a valid host command-queue in which the read / write command will be queued. command_queue and program must be created with the same OpenCL context. |
| 135 | + |
| 136 | +* _program_ is a program object with a successfully built executable. |
| 137 | + |
| 138 | +* _pipe_symbol_ is the name of the program scope pipe global variable. |
| 139 | + |
| 140 | +* _blocking_read_ and _blocking_write_ indicate if the read and write operations are blocking or non-blocking (see below). |
| 141 | + |
| 142 | +* _ptr_ is a pointer to buffer in host memory where data is to be read into or written from. |
| 143 | + |
| 144 | +* _size_ describes the size of the memory region to read or write, in bytes. |
| 145 | + |
| 146 | +* _event_wait_list_ and _num_events_in_wait_list_ specify events that need to complete before this particular command can be executed. If event_wait_list is NULL, then this particular command does not wait on any event to complete. If event_wait_list is NULL, num_events_in_wait_list must be 0. If event_wait_list is not NULL, the list of events pointed to by event_wait_list must be valid and num_events_in_wait_list must be greater than 0. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same. The memory associated with event_wait_list can be reused or freed after the function returns. |
| 147 | + |
| 148 | +* _event_ returns an event object that identifies this read / write command and can be used to query or queue a wait for this command to complete. If event is NULL or the enqueue is unsuccessful, no event will be created and therefore it will not be possible to query the status of this command or to wait for this command to complete. If event_wait_list and event are not NULL, event must not refer to an element of the event_wait_list array. |
| 149 | + |
| 150 | +*clEnqueueReadHostPipeINTEL* and *clEnqueueWriteHostPipeINTEL* return CL_SUCCESS if the command is queued successfully. Otherwise, they return one of the following errors: |
| 151 | + |
| 152 | +* `CL_INVALID_COMMAND_QUEUE` if command_queue is not a valid host command-queue. |
| 153 | + |
| 154 | +* `CL_INVALID_CONTEXT` if the context associated with command_queue and program are not the same or if the context associated with command_queue and events in event_wait_list are not the same. |
| 155 | + |
| 156 | +* `CL_INVALID_PROGRAM` if program is not a valid program object. |
| 157 | + |
| 158 | +* `CL_INVALID_PROGRAM_EXECUTABLE` if there is no successfully built program executable available for device associated with command_queue. |
| 159 | + |
| 160 | +* `CL_INVALID_VALUE` if either _pipe_symbol_ or _ptr_ are `NULL`, or no such symbol is found on the device. |
| 161 | + |
| 162 | +* `CL_INVALID_SIZE` if _size_ doesn't equal the size of one data struct defined in the pipe. |
| 163 | + |
| 164 | +* `CL_INVALID_EVENT_WAIT_LIST` if event_wait_list is NULL and num_events_in_wait_list > 0, or event_wait_list is not NULL and num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events. |
| 165 | + |
| 166 | +* `CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST` if the read and write operations are blocking and the execution status of any of the events in event_wait_list is a negative integer value. |
| 167 | + |
| 168 | +* `CL_INVALID_OPERATION` if *clEnqueueReadHostPipeINTEL* is called for a global variable that is not a host pipe that can be read by the host. |
| 169 | + |
| 170 | +* `CL_INVALID_OPERATION` if *clEnqueueWriteHostPipeINTEL* is called for a global variable that is not a host pipe that can be written by the host. |
| 171 | + |
| 172 | + |
| 173 | +* `CL_OUT_OF_RESOURCES` if there is a failure to allocate resources required by the OpenCL implementation on the device. |
| 174 | + |
| 175 | +* `CL_OUT_OF_HOST_MEMORY` if there is a failure to allocate resources required by the OpenCL implementation on the host. |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | +== Modify Section 5.8.9. Program Object Queries |
| 180 | +Add following rows to *Table 29. List of supported param_names by clGetProgramInfo*: |
| 181 | + |
| 182 | +[width="100%",cols="25,25,25"] |
| 183 | +|=== |
| 184 | +| CL_PROGRAM_NUM_HOST_PIPES_INTEL |
| 185 | +| size_t |
| 186 | +| Returns the number of host pipes declared in program. This information is only available after a successful program executable has been built for at least one device in the list of devices associated with program. |
| 187 | +| CL_PROGRAM_HOST_PIPE_NAMES_INTEL |
| 188 | +| char[] |
| 189 | +| Returns a semi-colon separated list of host pipe names in program. This information is only available after a successful program executable has been built for at least one device in the list of devices associated with program. |
| 190 | +|=== |
| 191 | + |
| 192 | + |
| 193 | +== Section 5.11: Event Objects |
| 194 | +Add two new rows to *Table 37, List of supported event command types*: |
| 195 | + |
| 196 | +[width="100%",cols="50,50"] |
| 197 | +|=== |
| 198 | +| Events Created By |Event Command Type |
| 199 | +| clEnqueueReadHostPipeINTEL |
| 200 | +| CL_COMMAND_READ_HOST_PIPE_INTEL |
| 201 | +| clEnqueueWriteHostPipeINTEL |
| 202 | +| CL_COMMAND_WRITE_HOST_PIPE_INTEL |
| 203 | +|=== |
| 204 | + |
| 205 | +== Issues |
| 206 | + |
| 207 | +== Revision History |
| 208 | + |
| 209 | +[cols="5,15,15,70"] |
| 210 | +[grid="rows"] |
| 211 | +[options="header"] |
| 212 | +|======================================== |
| 213 | +|Rev|Date|Author|Changes |
| 214 | +|1|2021-06-29|Bo Lei|*Initial working draft* |
| 215 | +|2|2022-02-22|Marco Jacques|*Updated draft, rewrote the API* |
| 216 | +|3|2022-12-12|Zibai Wang|*Final draft* |
| 217 | +|======================================== |
| 218 | + |
| 219 | +//************************************************************************ |
| 220 | +//Other formatting suggestions: |
| 221 | +// |
| 222 | +//* Use *bold* text for host APIs, or [source] syntax highlighting. |
| 223 | +//* Use `mono` text for device APIs, or [source] syntax highlighting. |
| 224 | +//* Use `mono` text for extension names, types, or enum values. |
| 225 | +//* Use _italics_ for parameters. |
| 226 | +//************************************************************************ |
0 commit comments