@@ -424,27 +424,6 @@ static bool checkPVCDevice(std::string SingleArg, std::string &DevArg) {
424424 return false ;
425425}
426426
427- // Checks whether there is only one kind of GPU sepcified by '-device'.
428- // Currently, we only check for PVC and DG2 since device sanitizer currently
429- // only supports these 2 kinds of Intel GPU.
430- static size_t isSpecificGPUOnly (const ArgStringList &CmdArgs) {
431- std::string DeviceArg = getDeviceArg (CmdArgs);
432- if (DeviceArg.empty ())
433- return 0 ;
434-
435- if (DeviceArg.find (" ," ) != std::string::npos)
436- return 0 ;
437-
438- std::string Temp;
439- if (checkPVCDevice (DeviceArg, Temp))
440- return 2 ;
441-
442- if (DeviceArg == " dg2" )
443- return 1 ;
444-
445- return 0 ;
446- }
447-
448427SmallVector<std::string, 8 >
449428SYCL::getDeviceLibraries (const Compilation &C, const llvm::Triple &TargetTriple,
450429 bool IsSpirvAOT) {
@@ -606,6 +585,25 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
606585 LibraryList.push_back (Args.MakeArgString (LibName));
607586 };
608587
588+ // This function is used to check whether there is only one GPU device
589+ // (PVC or DG2) specified in AOT compilation mode. If yes, we can use
590+ // corresponding libsycl-asan-* to improve device sanitizer performance,
591+ // otherwise stick to fallback device sanitizer library used in JIT mode.
592+ auto getSpecificGPUTarget = [] (const ArgStringList &CmdArgs)->size_t {
593+ std::string DeviceArg = getDeviceArg (CmdArgs);
594+ if ((DeviceArg.empty ()) || (DeviceArg.find (" ," ) != std::string::npos))
595+ return JIT;
596+
597+ std::string Temp;
598+ if (checkPVCDevice (DeviceArg, Temp))
599+ return AOT_PVC;
600+
601+ if (DeviceArg == " dg2" )
602+ return AOT_DG2;
603+
604+ return JIT;
605+ };
606+
609607 auto getSingleBuildTarget = [&]() -> size_t {
610608 if (!IsSpirvAOT)
611609 return JIT;
@@ -630,9 +628,7 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
630628 StringRef (A->getValue ()).starts_with (" spir64_gen" ))
631629 TargArgs.push_back (A->getValue (1 ));
632630
633- auto TargetType = isSpecificGPUOnly (TargArgs);
634- if (TargetType != 0 )
635- return (TargetType == 2 ) ? AOT_PVC : AOT_DG2;
631+ return getSpecificGPUTarget (TargArgs);
636632 }
637633
638634 return JIT;
0 commit comments