@@ -175,6 +175,64 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuildExp(
175175 return UR_RESULT_SUCCESS;
176176}
177177
178+ // /////////////////////////////////////////////////////////////////////////////
179+ // / @brief Intercept function for urProgramLink
180+ __urdlllocal ur_result_t UR_APICALL urProgramLink (
181+ ur_context_handle_t hContext, // /< [in] handle of the context instance.
182+ uint32_t count, // /< [in] number of program handles in `phPrograms`.
183+ const ur_program_handle_t *
184+ phPrograms, // /< [in][range(0, count)] pointer to array of program handles.
185+ const char *
186+ pOptions, // /< [in][optional] pointer to linker options null-terminated string.
187+ ur_program_handle_t
188+ *phProgram // /< [out] pointer to handle of program object created.
189+ ) {
190+ auto pfnProgramLink = context.urDdiTable .Program .pfnLink ;
191+
192+ if (nullptr == pfnProgramLink) {
193+ return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
194+ }
195+
196+ context.logger .debug (" ==== urProgramLink" );
197+
198+ UR_CALL (pfnProgramLink (hContext, count, phPrograms, pOptions, phProgram));
199+
200+ UR_CALL (context.interceptor ->registerDeviceGlobals (hContext, *phProgram));
201+
202+ return UR_RESULT_SUCCESS;
203+ }
204+
205+ // /////////////////////////////////////////////////////////////////////////////
206+ // / @brief Intercept function for urProgramLinkExp
207+ ur_result_t UR_APICALL urProgramLinkExp (
208+ ur_context_handle_t hContext, // /< [in] handle of the context instance.
209+ uint32_t numDevices, // /< [in] number of devices
210+ ur_device_handle_t *
211+ phDevices, // /< [in][range(0, numDevices)] pointer to array of device handles
212+ uint32_t count, // /< [in] number of program handles in `phPrograms`.
213+ const ur_program_handle_t *
214+ phPrograms, // /< [in][range(0, count)] pointer to array of program handles.
215+ const char *
216+ pOptions, // /< [in][optional] pointer to linker options null-terminated string.
217+ ur_program_handle_t
218+ *phProgram // /< [out] pointer to handle of program object created.
219+ ) {
220+ auto pfnProgramLinkExp = context.urDdiTable .ProgramExp .pfnLinkExp ;
221+
222+ if (nullptr == pfnProgramLinkExp) {
223+ return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
224+ }
225+
226+ context.logger .debug (" ==== urProgramLinkExp" );
227+
228+ UR_CALL (pfnProgramLinkExp (hContext, numDevices, phDevices, count,
229+ phPrograms, pOptions, phProgram));
230+
231+ UR_CALL (context.interceptor ->registerDeviceGlobals (hContext, *phProgram));
232+
233+ return UR_RESULT_SUCCESS;
234+ }
235+
178236// /////////////////////////////////////////////////////////////////////////////
179237// / @brief Intercept function for urEnqueueKernelLaunch
180238__urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunch (
@@ -375,9 +433,11 @@ __urdlllocal ur_result_t UR_APICALL urGetProgramProcAddrTable(
375433 }
376434
377435 pDdiTable->pfnBuild = ur_sanitizer_layer::urProgramBuild;
436+ pDdiTable->pfnLink = ur_sanitizer_layer::urProgramLink;
378437
379438 return UR_RESULT_SUCCESS;
380439}
440+
381441// /////////////////////////////////////////////////////////////////////////////
382442// / @brief Exported function for filling application's ProgramExp table
383443// / with current process' addresses
@@ -405,9 +465,11 @@ __urdlllocal ur_result_t UR_APICALL urGetProgramExpProcAddrTable(
405465 ur_result_t result = UR_RESULT_SUCCESS;
406466
407467 pDdiTable->pfnBuildExp = ur_sanitizer_layer::urProgramBuildExp;
468+ pDdiTable->pfnLinkExp = ur_sanitizer_layer::urProgramLinkExp;
408469
409470 return result;
410471}
472+
411473// /////////////////////////////////////////////////////////////////////////////
412474// / @brief Exported function for filling application's Enqueue table
413475// / with current process' addresses
0 commit comments