19 #include <condition_variable>
22 #include <type_traits>
25 class MockKernelProgramCache;
70 using PiProgramT = std::remove_pointer<RT::PiProgram>::type;
74 std::pair<RT::PiDevice, std::string>>;
75 using ProgramCacheT = std::map<ProgramCacheKeyT, ProgramWithBuildStateT>;
78 using PiKernelT = std::remove_pointer<RT::PiKernel>::type;
89 std::tuple<RT::PiKernel, std::mutex *, RT::PiProgram>;
97 return {MCachedPrograms, MProgramCacheMutex};
101 return {MKernelsPerProgramCache, MKernelsPerProgramCacheMutex};
104 template <
typename T,
class Predicate>
106 std::unique_lock<std::mutex> Lock(BR.MBuildResultMutex);
108 BR.MBuildCV.wait(Lock, Pred);
112 BR.MBuildCV.notify_all();
115 template <
typename KeyT>
117 std::unique_lock<std::mutex> Lock(MKernelFastCacheMutex);
118 auto It = MKernelFastCache.find(CacheKey);
119 if (It != MKernelFastCache.end()) {
125 template <
typename KeyT,
typename ValT>
127 std::unique_lock<std::mutex> Lock(MKernelFastCacheMutex);
130 MKernelFastCache.emplace(CacheKey, CacheVal);
143 std::mutex MProgramCacheMutex;
144 std::mutex MKernelsPerProgramCacheMutex;
146 ProgramCacheT MCachedPrograms;
147 KernelCacheT MKernelsPerProgramCache;
148 ContextPtr MParentContext;
150 std::mutex MKernelFastCacheMutex;
151 KernelFastCacheT MKernelFastCache;
152 friend class ::MockKernelProgramCache;