@@ -130,6 +130,95 @@ ur_result_t urContextRelease(
130130 return UR_RESULT_SUCCESS;
131131}
132132
133+ // /////////////////////////////////////////////////////////////////////////////
134+ // / @brief Intercept function for urProgramBuild
135+ ur_result_t urProgramBuild (
136+ // / [in] handle of the context object
137+ ur_context_handle_t hContext,
138+ // / [in] handle of the program object
139+ ur_program_handle_t hProgram,
140+ // / [in] string of build options
141+ const char *pOptions) {
142+ getContext ()->logger .debug (" ==== urProgramBuild" );
143+
144+ UR_CALL (
145+ getContext ()->urDdiTable .Program .pfnBuild (hContext, hProgram, pOptions));
146+
147+ UR_CALL (getTsanInterceptor ()->registerProgram (hProgram));
148+
149+ return UR_RESULT_SUCCESS;
150+ }
151+
152+ // /////////////////////////////////////////////////////////////////////////////
153+ // / @brief Intercept function for urProgramBuildExp
154+ ur_result_t urProgramBuildExp (
155+ // / [in] Handle of the program to build.
156+ ur_program_handle_t hProgram,
157+ // / [in] number of devices
158+ uint32_t numDevices,
159+ // / [in][range(0, numDevices)] pointer to array of device handles
160+ ur_device_handle_t *phDevices,
161+ // / [in][optional] pointer to build options null-terminated string.
162+ const char *pOptions) {
163+ getContext ()->logger .debug (" ==== urProgramBuildExp" );
164+
165+ UR_CALL (getContext ()->urDdiTable .ProgramExp .pfnBuildExp (hProgram, numDevices,
166+ phDevices, pOptions));
167+ UR_CALL (getTsanInterceptor ()->registerProgram (hProgram));
168+
169+ return UR_RESULT_SUCCESS;
170+ }
171+
172+ // /////////////////////////////////////////////////////////////////////////////
173+ // / @brief Intercept function for urProgramLink
174+ ur_result_t urProgramLink (
175+ // / [in] handle of the context instance.
176+ ur_context_handle_t hContext,
177+ // / [in] number of program handles in `phPrograms`.
178+ uint32_t count,
179+ // / [in][range(0, count)] pointer to array of program handles.
180+ const ur_program_handle_t *phPrograms,
181+ // / [in][optional] pointer to linker options null-terminated string.
182+ const char *pOptions,
183+ // / [out] pointer to handle of program object created.
184+ ur_program_handle_t *phProgram) {
185+ getContext ()->logger .debug (" ==== urProgramLink" );
186+
187+ UR_CALL (getContext ()->urDdiTable .Program .pfnLink (hContext, count, phPrograms,
188+ pOptions, phProgram));
189+
190+ UR_CALL (getTsanInterceptor ()->registerProgram (*phProgram));
191+
192+ return UR_RESULT_SUCCESS;
193+ }
194+
195+ // /////////////////////////////////////////////////////////////////////////////
196+ // / @brief Intercept function for urProgramLinkExp
197+ ur_result_t urProgramLinkExp (
198+ // / [in] handle of the context instance.
199+ ur_context_handle_t hContext,
200+ // / [in] number of devices
201+ uint32_t numDevices,
202+ // / [in][range(0, numDevices)] pointer to array of device handles
203+ ur_device_handle_t *phDevices,
204+ // / [in] number of program handles in `phPrograms`.
205+ uint32_t count,
206+ // / [in][range(0, count)] pointer to array of program handles.
207+ const ur_program_handle_t *phPrograms,
208+ // / [in][optional] pointer to linker options null-terminated string.
209+ const char *pOptions,
210+ // / [out] pointer to handle of program object created.
211+ ur_program_handle_t *phProgram) {
212+ getContext ()->logger .debug (" ==== urProgramLinkExp" );
213+
214+ UR_CALL (getContext ()->urDdiTable .ProgramExp .pfnLinkExp (
215+ hContext, numDevices, phDevices, count, phPrograms, pOptions, phProgram));
216+
217+ UR_CALL (getTsanInterceptor ()->registerProgram (*phProgram));
218+
219+ return UR_RESULT_SUCCESS;
220+ }
221+
133222// /////////////////////////////////////////////////////////////////////////////
134223// / @brief Intercept function for urUSMDeviceAlloc
135224__urdlllocal ur_result_t UR_APICALL urUSMDeviceAlloc (
@@ -283,6 +372,39 @@ __urdlllocal ur_result_t UR_APICALL urGetContextProcAddrTable(
283372 return result;
284373}
285374
375+ // /////////////////////////////////////////////////////////////////////////////
376+ // / @brief Exported function for filling application's Program table
377+ // / with current process' addresses
378+ // /
379+ // / @returns
380+ // / - ::UR_RESULT_SUCCESS
381+ // / - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
382+ ur_result_t urGetProgramProcAddrTable (
383+ // / [in,out] pointer to table of DDI function pointers
384+ ur_program_dditable_t *pDdiTable) {
385+ pDdiTable->pfnBuild = ur_sanitizer_layer::tsan::urProgramBuild;
386+ pDdiTable->pfnLink = ur_sanitizer_layer::tsan::urProgramLink;
387+
388+ return UR_RESULT_SUCCESS;
389+ }
390+
391+ // / @brief Exported function for filling application's ProgramExp table
392+ // / with current process' addresses
393+ // /
394+ // / @returns
395+ // / - ::UR_RESULT_SUCCESS
396+ // / - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
397+ ur_result_t urGetProgramExpProcAddrTable (
398+ // / [in,out] pointer to table of DDI function pointers
399+ ur_program_exp_dditable_t *pDdiTable) {
400+ ur_result_t result = UR_RESULT_SUCCESS;
401+
402+ pDdiTable->pfnBuildExp = ur_sanitizer_layer::tsan::urProgramBuildExp;
403+ pDdiTable->pfnLinkExp = ur_sanitizer_layer::tsan::urProgramLinkExp;
404+
405+ return result;
406+ }
407+
286408// /////////////////////////////////////////////////////////////////////////////
287409// / @brief Exported function for filling application's USM table
288410// / with current process' addresses
@@ -363,6 +485,16 @@ ur_result_t initTsanDDITable(ur_dditable_t *dditable) {
363485 UR_API_VERSION_CURRENT, &dditable->Context );
364486 }
365487
488+ if (UR_RESULT_SUCCESS == result) {
489+ result =
490+ ur_sanitizer_layer::tsan::urGetProgramProcAddrTable (&dditable->Program );
491+ }
492+
493+ if (UR_RESULT_SUCCESS == result) {
494+ result = ur_sanitizer_layer::tsan::urGetProgramExpProcAddrTable (
495+ &dditable->ProgramExp );
496+ }
497+
366498 if (UR_RESULT_SUCCESS == result) {
367499 result = ur_sanitizer_layer::tsan::urGetUSMProcAddrTable (
368500 UR_API_VERSION_CURRENT, &dditable->USM );
0 commit comments