15 #include <unordered_map>
18 inline namespace _V1 {
26 class ods_target_list;
32 using PluginPtr = std::shared_ptr<plugin>;
65 std::unordered_map<PlatformImplPtr, ContextImplPtr> &
92 #ifdef XPTI_ENABLE_INSTRUMENTATION
93 void *GSYCLCallEvent =
nullptr;
96 bool OkToDefer =
true;
103 static SpinLock MSyclGlobalHandlerProtector;
110 template <
typename T>
struct InstWithLock {
111 std::unique_ptr<T> Inst;
115 template <
typename T,
typename... Types>
116 T &getOrCreate(InstWithLock<T> &IWL, Types... Args);
118 InstWithLock<Scheduler> MScheduler;
119 InstWithLock<ProgramManager> MProgramManager;
120 InstWithLock<Sync> MSync;
121 InstWithLock<std::vector<PlatformImplPtr>> MPlatformCache;
122 InstWithLock<std::unordered_map<PlatformImplPtr, ContextImplPtr>>
123 MPlatformToDefaultContextCache;
124 InstWithLock<std::mutex> MPlatformToDefaultContextCacheMutex;
125 InstWithLock<std::mutex> MPlatformMapMutex;
126 InstWithLock<std::mutex> MFilterMutex;
127 InstWithLock<std::vector<PluginPtr>> MPlugins;
128 InstWithLock<ods_target_list> MOneapiDeviceSelectorTargets;
129 InstWithLock<XPTIRegistry> MXPTIRegistry;
131 InstWithLock<ThreadPool> MHostTaskThreadPool;
Wrapper class for global data structures with non-trivial destructors.
static void registerEarlyShutdownHandler()
GlobalHandler(const GlobalHandler &)=delete
ods_target_list & getOneapiDeviceSelectorTargets(const std::string &InitValue)
bool isSchedulerAlive() const
GlobalHandler & operator=(const GlobalHandler &)=delete
void releaseDefaultContexts()
std::vector< PlatformImplPtr > & getPlatformCache()
XPTIRegistry & getXPTIRegistry()
ProgramManager & getProgramManager()
std::unordered_map< PlatformImplPtr, ContextImplPtr > & getPlatformToDefaultContextCache()
std::vector< PluginPtr > & getPlugins()
GlobalHandler(GlobalHandler &&)=delete
void prepareSchedulerToRelease(bool Blocking)
void TraceEventXPTI(const char *Message)
std::mutex & getPlatformMapMutex()
friend void shutdown_early()
void attachScheduler(Scheduler *Scheduler)
void registerSchedulerUsage(bool ModifyCounter=true)
std::mutex & getPlatformToDefaultContextCacheMutex()
void endDeferredRelease()
std::mutex & getFilterMutex()
ThreadPool & getHostTaskThreadPool()
Scheduler & getScheduler()
static GlobalHandler & instance()
friend void shutdown_win()
friend void shutdown_late()
DPC++ graph scheduler class.
SpinLock is a synchronization primitive, that uses atomic variable and causes thread trying acquire l...
Groups and provides access to all the locks used the SYCL runtime.
std::shared_ptr< sycl::detail::context_impl > ContextImplPtr
std::shared_ptr< plugin > PluginPtr
std::shared_ptr< detail::platform_impl > PlatformImplPtr