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