#include <detail/kernel_program_cache.hpp>
Classes | |
struct | BuildError |
Denotes build error data. More... | |
struct | BuildResult |
Denotes pointer to some entity with its general state and build error. More... | |
struct | KernelBuildResult |
struct | ProgramBuildResult |
struct | ProgramCache |
Public Member Functions | |
~KernelProgramCache ()=default | |
void | setContextPtr (const ContextPtr &AContext) |
Locked< ProgramCache > | acquireCachedPrograms () |
Locked< KernelCacheT > | acquireKernelsPerProgramCache () |
std::pair< ProgramBuildResultPtr, bool > | getOrInsertProgram (const ProgramCacheKeyT &CacheKey) |
std::pair< KernelBuildResultPtr, bool > | getOrInsertKernel (sycl::detail::pi::PiProgram Program, const std::string &KernelName) |
template<typename KeyT > | |
KernelFastCacheValT | tryToGetKernelFast (KeyT &&CacheKey) |
template<typename KeyT , typename ValT > | |
void | saveKernel (KeyT &&CacheKey, ValT &&CacheVal) |
void | reset () |
Clears cache state. More... | |
template<typename ExceptionT , typename GetCachedBuildFT , typename BuildFT > | |
auto | getOrBuild (GetCachedBuildFT &&GetCachedBuild, BuildFT &&Build) |
Try to fetch entity (kernel or program) from cache. More... | |
Friends | |
class | ::MockKernelProgramCache |
Definition at line 34 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::CommonProgramKeyT = std::pair<std::uintptr_t, sycl::detail::pi::PiDevice> |
Definition at line 112 of file kernel_program_cache.hpp.
Definition at line 122 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelArgMaskPairT = std::pair<sycl::detail::pi::PiKernel, const KernelArgMask *> |
Definition at line 124 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelBuildResultPtr = std::shared_ptr<KernelBuildResult> |
Definition at line 139 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelByNameT = ::boost::unordered_map<std::string, KernelBuildResultPtr> |
Definition at line 141 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelCacheT = ::boost::unordered_map<sycl::detail::pi::PiProgram, KernelByNameT> |
Definition at line 143 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelFastCacheKeyT = std::tuple<SerializedObj, sycl::detail::pi::PiDevice, std::string, std::string> |
Definition at line 146 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelFastCacheT = ::boost::unordered_flat_map<KernelFastCacheKeyT, KernelFastCacheValT> |
Definition at line 157 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelFastCacheValT = std::tuple<sycl::detail::pi::PiKernel, std::mutex *, const KernelArgMask *, sycl::detail::pi::PiProgram> |
Definition at line 149 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::ProgramBuildResultPtr = std::shared_ptr<ProgramBuildResult> |
Definition at line 104 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::ProgramCacheKeyT = std::pair<std::pair<SerializedObj, std::uintptr_t>, sycl::detail::pi::PiDevice> |
Definition at line 110 of file kernel_program_cache.hpp.
Denotes the state of a build.
Enumerator | |
---|---|
BS_Initial | |
BS_InProgress | |
BS_Done | |
BS_Failed |
Definition at line 46 of file kernel_program_cache.hpp.
|
default |
|
inline |
Definition at line 164 of file kernel_program_cache.hpp.
Referenced by getOrInsertProgram(), and sycl::_V1::detail::context_impl::getProgramForDevImgs().
|
inline |
Definition at line 168 of file kernel_program_cache.hpp.
Referenced by getOrInsertKernel().
|
inline |
Try to fetch entity (kernel or program) from cache.
If there is no such entity try to build it. Throw any exception build process may throw. This method eliminates unwanted builds by employing atomic variable with build state and waiting until the entity is built in another thread. If the building thread has failed the awaiting thread will fail either. Exception thrown by build procedure are rethrown.
RetT | type of entity to get |
ExceptionT | type of exception to throw on awaiting thread if the building thread fails build step. |
KeyT | key (in cache) to fetch built entity with |
AcquireFT | type of function which will acquire the locked version of the cache. Accept reference to KernelProgramCache. |
GetCacheFT | type of function which will fetch proper cache from locked version. Accepts reference to locked version of cache. |
BuildFT | type of function which will build the entity if it is not in cache. Accepts nothing. Return pointer to built entity. |
Definition at line 251 of file kernel_program_cache.hpp.
References BS_Done, BS_Failed, BS_Initial, BS_InProgress, sycl::_V1::detail::KernelProgramCache::BuildError::Code, sycl::_V1::detail::KernelProgramCache::BuildResult< T >::Error, sycl::_V1::exception::get_cl_code(), sycl::_V1::detail::KernelProgramCache::BuildError::isFilledIn(), sycl::_V1::detail::KernelProgramCache::BuildError::Msg, reset(), sycl::_V1::detail::KernelProgramCache::BuildResult< T >::State, sycl::_V1::detail::KernelProgramCache::BuildResult< T >::updateAndNotify(), sycl::_V1::detail::KernelProgramCache::BuildResult< T >::Val, sycl::_V1::detail::KernelProgramCache::BuildResult< T >::waitUntilTransition(), and sycl::_V1::exception::what().
Referenced by sycl::_V1::detail::ProgramManager::build(), sycl::_V1::detail::ProgramManager::getBuiltPIProgram(), and sycl::_V1::detail::ProgramManager::getOrCreateKernel().
|
inline |
Definition at line 188 of file kernel_program_cache.hpp.
References acquireKernelsPerProgramCache().
Referenced by sycl::_V1::detail::ProgramManager::getOrCreateKernel().
|
inline |
Definition at line 173 of file kernel_program_cache.hpp.
References acquireCachedPrograms().
Referenced by sycl::_V1::detail::ProgramManager::build(), and sycl::_V1::detail::ProgramManager::getBuiltPIProgram().
|
inline |
Clears cache state.
This member function should only be used in unit tests.
Definition at line 219 of file kernel_program_cache.hpp.
Referenced by getOrBuild().
|
inline |
Definition at line 209 of file kernel_program_cache.hpp.
Referenced by sycl::_V1::detail::ProgramManager::getOrCreateKernel().
|
inline |
Definition at line 162 of file kernel_program_cache.hpp.
Referenced by sycl::_V1::detail::context_impl::context_impl().
|
inline |
Definition at line 199 of file kernel_program_cache.hpp.
References sycl::_V1::detail::make_tuple().
Referenced by sycl::_V1::detail::ProgramManager::getOrCreateKernel().
|
friend |
Definition at line 318 of file kernel_program_cache.hpp.