@@ -643,6 +643,19 @@ ur_result_t AsanInterceptor::insertProgram(ur_program_handle_t Program) {
643643 if (m_ProgramMap.find (Program) != m_ProgramMap.end ()) {
644644 return UR_RESULT_SUCCESS;
645645 }
646+ auto CI = getContextInfo (GetContext (Program));
647+ auto DI = getDeviceInfo (CI->DeviceList [0 ]);
648+ ur_specialization_constant_info_t SpecConstantInfo{
649+ SPEC_CONSTANT_DEVICE_TYPE_ID, sizeof (DeviceType), &DI->Type };
650+ ur_result_t URes =
651+ getContext ()->urDdiTable .Program .pfnSetSpecializationConstants (
652+ Program, 1 , &SpecConstantInfo);
653+ if (URes != UR_RESULT_SUCCESS) {
654+ UR_LOG_L (getContext ()->logger , DEBUG,
655+ " Set specilization constant for device type failed: {}, the "
656+ " program may not be sanitized or is created from binary." ,
657+ URes);
658+ }
646659 m_ProgramMap.emplace (Program, std::make_shared<ProgramInfo>(Program));
647660 return UR_RESULT_SUCCESS;
648661}
@@ -812,7 +825,6 @@ ur_result_t AsanInterceptor::prepareLaunch(
812825 // Prepare asan runtime data
813826 LaunchInfo.Data .Host .GlobalShadowOffset = DeviceInfo->Shadow ->ShadowBegin ;
814827 LaunchInfo.Data .Host .GlobalShadowOffsetEnd = DeviceInfo->Shadow ->ShadowEnd ;
815- LaunchInfo.Data .Host .DeviceTy = DeviceInfo->Type ;
816828 LaunchInfo.Data .Host .Debug = getContext ()->Options .Debug ? 1 : 0 ;
817829
818830 // Write shadow memory offset for local memory
@@ -874,16 +886,14 @@ ur_result_t AsanInterceptor::prepareLaunch(
874886
875887 UR_LOG_L (getContext ()->logger , INFO,
876888 " LaunchInfo {} (GlobalShadow={}, LocalShadow={}, PrivateBase={}, "
877- " PrivateShadow={}, LocalArgs={}, NumLocalArgs={}, "
878- " Device={}, Debug={})" ,
889+ " PrivateShadow={}, LocalArgs={}, NumLocalArgs={}, Debug={})" ,
879890 (void *)LaunchInfo.Data .getDevicePtr (),
880891 (void *)LaunchInfo.Data .Host .GlobalShadowOffset ,
881892 (void *)LaunchInfo.Data .Host .LocalShadowOffset ,
882893 (void *)LaunchInfo.Data .Host .PrivateBase ,
883894 (void *)LaunchInfo.Data .Host .PrivateShadowOffset ,
884895 (void *)LaunchInfo.Data .Host .LocalArgs ,
885- LaunchInfo.Data .Host .NumLocalArgs ,
886- ToString (LaunchInfo.Data .Host .DeviceTy ), LaunchInfo.Data .Host .Debug );
896+ LaunchInfo.Data .Host .NumLocalArgs , LaunchInfo.Data .Host .Debug );
887897
888898 return UR_RESULT_SUCCESS;
889899}
0 commit comments