• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    NV_cuda_event
4
5Name Strings
6
7    EGL_NV_cuda_event
8
9Contributors
10
11    Debalina Bhattacharjee
12    Michael Chock
13    James Jones
14    Daniel Kartch
15
16Contact
17
18    Michael Chock (mchock 'at' nvidia.com)
19
20Status
21
22    Complete
23
24Version
25
26    Version 2, June 28, 2018
27
28Number
29
30    EGL Extension #75
31
32Extension Type
33
34    EGL display extension
35
36Dependencies
37
38    This extension is written against the language of EGL 1.5 and the
39    EGL_EXT_sync_reuse extension.
40
41    Either EGL_KHR_fence_sync and the EGLAttrib type or EGL 1.5 are
42    required.
43
44    This extension interacts with, but does not require,
45    EGL_EXT_sync_reuse.
46
47    This extension interacts with EGL_NV_device_cuda.
48
49Overview
50
51    This extension allows creating an EGL sync object linked to a CUDA
52    event object, potentially improving efficiency of sharing images and
53    compute results between the two APIs.
54
55IP Status
56
57    No known claims.
58
59New Types
60
61    A pointer to type cudaEvent_t, defined in the CUDA header files, may
62    be included in the attribute list passed to eglCreateSync.
63
64New Procedures and Functions
65
66    None.
67
68New Tokens
69
70    Accepted as attribute names in the <attrib_list> argument
71    of eglCreateSync:
72
73        EGL_CUDA_EVENT_HANDLE_NV        0x323B
74
75    Returned in <values> for eglGetSyncAttrib <attribute>
76    EGL_SYNC_TYPE:
77
78        EGL_SYNC_CUDA_EVENT_NV          0x323C
79
80    Returned in <values> for eglGetSyncAttrib <attribute>
81    EGL_SYNC_CONDITION:
82
83        EGL_SYNC_CUDA_EVENT_COMPLETE_NV 0x323D
84
85Add to section 3.8.1 (Sync Objects) of the EGL 1.5 specification, after
86the sixth paragraph:
87
88    Likewise, a <CUDA event sync object> reflects the status of a
89    corresponding CUDA object. Waiting on this type of sync object is
90    equivalent to waiting for completion of the corresponding linked
91    CUDA event object.
92
93Add a new section following section 3.8.1.2 (Creating and Signaling
94OpenCL Event Sync Objects):
95
96    Section 3.8.1.X Creating and Signaling CUDA Event Sync Objects
97
98    If <type> is EGL_SYNC_CUDA_EVENT_NV, a CUDA event sync object is
99    created. The <attrib_list> may contain the attribute
100    EGL_CUDA_EVENT_HANDLE_NV, set to a pointer to a cudaEvent_t object.
101    If it does not contain this attribute, the sync object will start in
102    the signaled state, and an event attribute must be provided the
103    first time eglUnsignalSyncEXT is called. Otherwise, a call to
104    eglUnsignalSyncEXT may replace this event attribute or leave it
105    unspecified, causing the previous object to be reused.
106
107    A cudaEvent_t object provided to eglCreateSync or eglUnsignalSyncEXT
108    must be properly initialized and recorded by the CUDA API (using
109    cudaEventCreate and cudaEventRecord), and the CUDA device
110    used to create the event must correspond to <dpy>[fn1]. Note that
111    EGL_CUDA_EVENT_HANDLE_NV is not a queryable property of a sync
112    object.
113
114    [fn1] If EGL_NV_device_cuda is supported, it is sufficient that the
115          CUDA device used to create the CUDA event matches the
116          EGL_CUDA_DEVICE_NV attribute of <dpy>'s underlying EGL
117          device.
118
119    Attributes of the CUDA event sync object are set as follows:
120
121        Attribute Name          Initial Attribute Value(s)
122        -------------           --------------------------
123        EGL_SYNC_TYPE           EGL_SYNC_CUDA_EVENT_NV
124        EGL_SYNC_STATUS         Depends on status of <event>
125        EGL_SYNC_CONDITION      EGL_SYNC_CUDA_EVENT_COMPLETE_NV
126
127    If an <event> is linked to the sync object, the status of this type
128    of sync object depends on the state of <event> evaluated at the time
129    of the most recent call to eglCreateSync or eglUnsignalSyncEXT. If
130    all device work preceding the most recent call to cudaEventRecord on
131    the event has not yet completed, the status of the linked sync
132    object will be EGL_UNSIGNALED. If all such work has completed, the
133    status of the linked sync object will be EGL_SIGNALED. Calling
134    cudaEventRecord to modify an event has no effect on the sync object
135    while its status is EGL_UNSIGNALED, but will have an effect if the
136    event is reevaluated at a subsequent eglUnsignalSyncEXT call.
137
138    The only condition supported for CUDA event sync objects is
139    EGL_SYNC_CUDA_EVENT_COMPLETE_NV. It is satisfied when all device
140    work prior to the most recent call to cudaEventRecord at sync
141    unsignaling time has completed.
142
143If EGL_EXT_sync_reuse is not present, then change the second sentence of
1443.8.1.X above to "The <attrib_list> must contain ..." and omit the
145remaining sentences in the paragraph. Omit all references to
146eglUnsignalSyncEXT.
147
148In 3.8.1 (Sync Objects), if EGL_EXT_sync_reuse is present, then add the
149following to the error list for eglUnsignalSyncEXT. Otherwise add it to
150the error list for eglCreateSync:
151
152    If <type> is EGL_SYNC_CUDA_EVENT_NV and a EGL_CUDA_EVENT_HANDLE_NV
153    is not linked to the sync object, then an EGL_BAD_ATTRIBUTE error is
154    generated. If its attribute value is not a valid CUDA event pointer
155    or has not been initialized as described above, then
156    EGL_BAD_ATTRIBUTE may be generated, but the results are undefined
157    and may include program termination.
158
159Modify the third paragraph of section 3.8.1.4 (Querying Sync Object
160Attributes):
161
162    If any eglClientWaitSync or eglWaitSync commands are blocking on
163    <sync> when eglDestroySync is called, <sync> is flagged for deletion
164    and will be deleted when the associated fence command, OpenCL event
165    object, or CUDA event object has completed, and <sync> is no longer
166    blocking any such egl*WaitSync command. Otherwise, the sync object
167    is destroyed immediately.
168
169Replace the EGL_SYNC_CONDITION row of table 3.9 with:
170
171    Attribute           Description              Supported Sync Objects
172    ------------------  -----------------------  ----------------------
173    EGL_SYNC_CONDITION  Signaling condition      EGL_SYNC_FENCE,
174                                                 EGL_SYNC_CL_EVENT, or
175                                                 EGL_SYNC_CUDA_EVENT_NV
176
177    Table 3.9  Attributes Accepted by eglGetSyncAttrib
178
179
180Interactions with EGL versions prior to 1.5
181
182    This extension may be used with earlier versions of EGL, provided
183    that the EGL_KHR_fence_sync extension is supported. In this case,
184    replace all references to sync functions and tokens with
185    corresponding KHR-suffixed versions (e.g., replace eglCreateSync
186    with eglCreateSyncKHR).
187
188    Additionally, this extension may be used with the 64-bit types and
189    functions added to EGL_KHR_fence_sync introduced by
190    EGL_KHR_cl_event2 (EGLAttribKHR and eglCreateSync64KHR). Support
191    for OpenCL events is not required.
192
193Issues
194
195    None
196
197Revision History
198
199    Version 2, 2018/06/28 (Daniel Kartch)
200        - Rewritten to clearly define interactions with
201          EGL_EXT_sync_reuse, without requiring it
202        - Fixed incorrect CUDA function name
203        - Fixed table spacing
204
205    Version 1, 2014/06/20 (Michael Chock)
206        - initial version.
207