#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 Types | |
enum class | BuildState { BS_Initial , BS_InProgress , BS_Done , BS_Failed } |
Denotes the state of a build. More... | |
using | ProgramBuildResultPtr = std::shared_ptr< ProgramBuildResult > |
using | ProgramCacheKeyT = std::pair< std::pair< SerializedObj, std::uintptr_t >, ur_device_handle_t > |
using | CommonProgramKeyT = std::pair< std::uintptr_t, ur_device_handle_t > |
using | ContextPtr = context_impl * |
using | KernelArgMaskPairT = std::pair< ur_kernel_handle_t, const KernelArgMask * > |
using | KernelBuildResultPtr = std::shared_ptr< KernelBuildResult > |
using | KernelByNameT = ::boost::unordered_map< std::string, KernelBuildResultPtr > |
using | KernelCacheT = ::boost::unordered_map< ur_program_handle_t, KernelByNameT > |
using | KernelFastCacheKeyT = std::tuple< SerializedObj, ur_device_handle_t, std::string, std::string > |
using | KernelFastCacheValT = std::tuple< ur_kernel_handle_t, std::mutex *, const KernelArgMask *, ur_program_handle_t > |
using | KernelFastCacheT = ::boost::unordered_flat_map< KernelFastCacheKeyT, KernelFastCacheValT > |
Public Member Functions | |
~KernelProgramCache ()=default | |
void | setContextPtr (const ContextPtr &AContext) |
Locked< ProgramCache > | acquireCachedPrograms () |
Locked< KernelCacheT > | acquireKernelsPerProgramCache () |
std::pair< ProgramBuildResultPtr, bool > | getOrInsertProgram (const ProgramCacheKeyT &CacheKey) |
bool | insertBuiltProgram (const ProgramCacheKeyT &CacheKey, ur_program_handle_t Program) |
std::pair< KernelBuildResultPtr, bool > | getOrInsertKernel (ur_program_handle_t 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<errc Errc, 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 35 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::CommonProgramKeyT = std::pair<std::uintptr_t, ur_device_handle_t> |
Definition at line 117 of file kernel_program_cache.hpp.
Definition at line 126 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelArgMaskPairT = std::pair<ur_kernel_handle_t, const KernelArgMask *> |
Definition at line 128 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelBuildResultPtr = std::shared_ptr<KernelBuildResult> |
Definition at line 142 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelByNameT = ::boost::unordered_map<std::string, KernelBuildResultPtr> |
Definition at line 144 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelCacheT = ::boost::unordered_map<ur_program_handle_t, KernelByNameT> |
Definition at line 146 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelFastCacheKeyT = std::tuple<SerializedObj, ur_device_handle_t, std::string, std::string> |
Definition at line 149 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelFastCacheT = ::boost::unordered_flat_map<KernelFastCacheKeyT, KernelFastCacheValT> |
Definition at line 159 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::KernelFastCacheValT = std::tuple<ur_kernel_handle_t, std::mutex *, const KernelArgMask *, ur_program_handle_t> |
Definition at line 151 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::ProgramBuildResultPtr = std::shared_ptr<ProgramBuildResult> |
Definition at line 109 of file kernel_program_cache.hpp.
using sycl::_V1::detail::KernelProgramCache::ProgramCacheKeyT = std::pair<std::pair<SerializedObj, std::uintptr_t>, ur_device_handle_t> |
Definition at line 115 of file kernel_program_cache.hpp.
Denotes the state of a build.
Enumerator | |
---|---|
BS_Initial | |
BS_InProgress | |
BS_Done | |
BS_Failed |
Definition at line 47 of file kernel_program_cache.hpp.
|
default |
|
inline |
Definition at line 166 of file kernel_program_cache.hpp.
Referenced by getOrInsertProgram(), sycl::_V1::detail::context_impl::getProgramForDevImgs(), and insertBuiltProgram().
|
inline |
Definition at line 170 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 |
Errc | error code 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 275 of file kernel_program_cache.hpp.
References BS_Done, BS_Failed, BS_Initial, BS_InProgress, sycl::_V1::exception::code(), sycl::_V1::detail::KernelProgramCache::BuildError::Code, sycl::_V1::detail::KernelProgramCache::BuildResult< T >::Error, sycl::_V1::detail::get_ur_error(), sycl::_V1::detail::KernelProgramCache::BuildError::isFilledIn(), sycl::_V1::make_error_code(), sycl::_V1::memory_allocation, sycl::_V1::detail::KernelProgramCache::BuildError::Msg, reset(), sycl::_V1::detail::set_ur_error(), 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::getBuiltURProgram(), and sycl::_V1::detail::ProgramManager::getOrCreateKernel().
|
inline |
Definition at line 212 of file kernel_program_cache.hpp.
References acquireKernelsPerProgramCache().
Referenced by sycl::_V1::detail::ProgramManager::getOrCreateKernel().
|
inline |
Definition at line 175 of file kernel_program_cache.hpp.
References acquireCachedPrograms().
Referenced by sycl::_V1::detail::ProgramManager::build(), and sycl::_V1::detail::ProgramManager::getBuiltURProgram().
|
inline |
Definition at line 194 of file kernel_program_cache.hpp.
References acquireCachedPrograms(), and BS_Done.
Referenced by sycl::_V1::detail::ProgramManager::getBuiltURProgram().
|
inline |
Clears cache state.
This member function should only be used in unit tests.
Definition at line 243 of file kernel_program_cache.hpp.
Referenced by getOrBuild().
|
inline |
Definition at line 233 of file kernel_program_cache.hpp.
Referenced by sycl::_V1::detail::ProgramManager::getOrCreateKernel().
|
inline |
Definition at line 164 of file kernel_program_cache.hpp.
Referenced by sycl::_V1::detail::context_impl::context_impl().
|
inline |
Definition at line 223 of file kernel_program_cache.hpp.
References sycl::_V1::detail::make_tuple().
Referenced by sycl::_V1::detail::ProgramManager::getOrCreateKernel().
|
friend |
Definition at line 346 of file kernel_program_cache.hpp.