@@ -567,8 +567,7 @@ RT::PiProgram ProgramManager::getBuiltPIProgram(
567
567
568
568
ProgramPtr BuiltProgram =
569
569
build (std::move (ProgramManaged), ContextImpl, CompileOpts, LinkOpts,
570
- getRawSyclObjImpl (Device)->getHandleRef (),
571
- ContextImpl->getCachedLibPrograms (), DeviceLibReqMask);
570
+ getRawSyclObjImpl (Device)->getHandleRef (), DeviceLibReqMask);
572
571
573
572
emitBuiltProgramInfo (BuiltProgram.get (), ContextImpl);
574
573
@@ -779,13 +778,14 @@ static const char *getDeviceLibExtensionStr(DeviceLibExt Extension) {
779
778
PI_INVALID_OPERATION);
780
779
}
781
780
782
- static RT::PiProgram loadDeviceLibFallback (
783
- const ContextImplPtr Context, DeviceLibExt Extension,
784
- const RT::PiDevice &Device,
785
- std::map<std::pair<DeviceLibExt, RT::PiDevice>, RT::PiProgram>
786
- &CachedLibPrograms) {
781
+ static RT::PiProgram loadDeviceLibFallback (const ContextImplPtr Context,
782
+ DeviceLibExt Extension,
783
+ const RT::PiDevice &Device) {
787
784
788
785
const char *LibFileName = getDeviceLibFilename (Extension);
786
+
787
+ auto LockedCache = Context->acquireCachedLibPrograms ();
788
+ auto CachedLibPrograms = LockedCache.get ();
789
789
auto CacheResult = CachedLibPrograms.emplace (
790
790
std::make_pair (std::make_pair (Extension, Device), nullptr ));
791
791
bool Cached = !CacheResult.second ;
@@ -923,11 +923,9 @@ static bool isDeviceLibRequired(DeviceLibExt Ext, uint32_t DeviceLibReqMask) {
923
923
return ((DeviceLibReqMask & Mask) == Mask);
924
924
}
925
925
926
- static std::vector<RT::PiProgram> getDeviceLibPrograms (
927
- const ContextImplPtr Context, const RT::PiDevice &Device,
928
- std::map<std::pair<DeviceLibExt, RT::PiDevice>, RT::PiProgram>
929
- &CachedLibPrograms,
930
- uint32_t DeviceLibReqMask) {
926
+ static std::vector<RT::PiProgram>
927
+ getDeviceLibPrograms (const ContextImplPtr Context, const RT::PiDevice &Device,
928
+ uint32_t DeviceLibReqMask) {
931
929
std::vector<RT::PiProgram> Programs;
932
930
933
931
std::pair<DeviceLibExt, bool > RequiredDeviceLibExt[] = {
@@ -975,21 +973,18 @@ static std::vector<RT::PiProgram> getDeviceLibPrograms(
975
973
bool DeviceSupports = DevExtList.npos != DevExtList.find (ExtStr);
976
974
977
975
if (!DeviceSupports || InhibitNativeImpl) {
978
- Programs.push_back (
979
- loadDeviceLibFallback (Context, Ext, Device, CachedLibPrograms));
976
+ Programs.push_back (loadDeviceLibFallback (Context, Ext, Device));
980
977
FallbackIsLoaded = true ;
981
978
}
982
979
}
983
980
return Programs;
984
981
}
985
982
986
- ProgramManager::ProgramPtr ProgramManager::build (
987
- ProgramPtr Program, const ContextImplPtr Context,
988
- const std::string &CompileOptions, const std::string &LinkOptions,
989
- const RT::PiDevice &Device,
990
- std::map<std::pair<DeviceLibExt, RT::PiDevice>, RT::PiProgram>
991
- &CachedLibPrograms,
992
- uint32_t DeviceLibReqMask) {
983
+ ProgramManager::ProgramPtr
984
+ ProgramManager::build (ProgramPtr Program, const ContextImplPtr Context,
985
+ const std::string &CompileOptions,
986
+ const std::string &LinkOptions,
987
+ const RT::PiDevice &Device, uint32_t DeviceLibReqMask) {
993
988
994
989
if (DbgProgMgr > 0 ) {
995
990
std::cerr << " >>> ProgramManager::build(" << Program.get () << " , "
@@ -1008,8 +1003,7 @@ ProgramManager::ProgramPtr ProgramManager::build(
1008
1003
1009
1004
std::vector<RT::PiProgram> LinkPrograms;
1010
1005
if (LinkDeviceLibs) {
1011
- LinkPrograms = getDeviceLibPrograms (Context, Device, CachedLibPrograms,
1012
- DeviceLibReqMask);
1006
+ LinkPrograms = getDeviceLibPrograms (Context, Device, DeviceLibReqMask);
1013
1007
}
1014
1008
1015
1009
static const char *ForceLinkEnv = std::getenv (" SYCL_FORCE_LINK" );
@@ -1899,8 +1893,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage,
1899
1893
1900
1894
ProgramPtr BuiltProgram =
1901
1895
build (std::move (ProgramManaged), ContextImpl, CompileOpts, LinkOpts,
1902
- getRawSyclObjImpl (Devs[0 ])->getHandleRef (),
1903
- ContextImpl->getCachedLibPrograms (), DeviceLibReqMask);
1896
+ getRawSyclObjImpl (Devs[0 ])->getHandleRef (), DeviceLibReqMask);
1904
1897
1905
1898
emitBuiltProgramInfo (BuiltProgram.get (), ContextImpl);
1906
1899
0 commit comments