@@ -417,22 +417,25 @@ ur_result_t SanitizerInterceptor::registerProgram(ur_context_handle_t Context,
417
417
for (auto Device : Devices) {
418
418
ManagedQueue Queue (Context, Device);
419
419
420
- uint64_t NumOfDeviceGlobal;
420
+ size_t MetadataSize;
421
+ void *MetadataPtr;
421
422
auto Result =
422
- getContext ()->urDdiTable .Enqueue .pfnDeviceGlobalVariableRead (
423
- Queue, Program, kSPIR_AsanDeviceGlobalCount , true ,
424
- sizeof (NumOfDeviceGlobal), 0 , &NumOfDeviceGlobal, 0 , nullptr ,
425
- nullptr );
423
+ getContext ()->urDdiTable .Program .pfnGetGlobalVariablePointer (
424
+ Device, Program, kSPIR_AsanDeviceGlobalMetadata , &MetadataSize,
425
+ &MetadataPtr);
426
426
if (Result != UR_RESULT_SUCCESS) {
427
427
getContext ()->logger .info (" No device globals" );
428
428
continue ;
429
429
}
430
430
431
+ const uint64_t NumOfDeviceGlobal =
432
+ MetadataSize / sizeof (DeviceGlobalInfo);
433
+ assert ((MetadataSize % sizeof (DeviceGlobalInfo) == 0 ) &&
434
+ " DeviceGlobal metadata size is not correct" );
431
435
std::vector<DeviceGlobalInfo> GVInfos (NumOfDeviceGlobal);
432
- Result = getContext ()->urDdiTable .Enqueue .pfnDeviceGlobalVariableRead (
433
- Queue, Program, kSPIR_AsanDeviceGlobalMetadata , true ,
434
- sizeof (DeviceGlobalInfo) * NumOfDeviceGlobal, 0 , &GVInfos[0 ], 0 ,
435
- nullptr , nullptr );
436
+ Result = getContext ()->urDdiTable .Enqueue .pfnUSMMemcpy (
437
+ Queue, true , &GVInfos[0 ], MetadataPtr,
438
+ sizeof (DeviceGlobalInfo) * NumOfDeviceGlobal, 0 , nullptr , nullptr );
436
439
if (Result != UR_RESULT_SUCCESS) {
437
440
getContext ()->logger .error (" Device Global[{}] Read Failed: {}" ,
438
441
kSPIR_AsanDeviceGlobalMetadata , Result);
0 commit comments