DPC++ Runtime
Runtime libraries for oneAPI DPC++
cl::sycl::detail::GlobalHandler Class Reference

Wrapper class for global data structures with non-trivial destructors. More...

#include <detail/global_handler.hpp>

Public Member Functions

 GlobalHandler (const GlobalHandler &)=delete
 
 GlobalHandler (GlobalHandler &&)=delete
 
SchedulergetScheduler ()
 
ProgramManagergetProgramManager ()
 
SyncgetSync ()
 
std::vector< PlatformImplPtr > & getPlatformCache ()
 
std::unordered_map< PlatformImplPtr, ContextImplPtr > & getPlatformToDefaultContextCache ()
 
std::mutex & getPlatformToDefaultContextCacheMutex ()
 
std::mutex & getPlatformMapMutex ()
 
std::mutex & getFilterMutex ()
 
std::vector< plugin > & getPlugins ()
 
device_filter_listgetDeviceFilterList (const std::string &InitValue)
 
XPTIRegistrygetXPTIRegistry ()
 
std::mutex & getHandlerExtendedMembersMutex ()
 
ThreadPoolgetHostTaskThreadPool ()
 

Static Public Member Functions

static GlobalHandlerinstance ()
 
static void registerDefaultContextReleaseHandler ()
 

Friends

void releaseDefaultContexts ()
 
void shutdown ()
 

Detailed Description

Wrapper class for global data structures with non-trivial destructors.

As user code can call SYCL Runtime functions from destructor of global objects, it is not safe for the runtime library to have global objects with non-trivial destructors. Such destructors can be called any time after exiting main, which may result in user application crashes. Instead, complex global objects must be wrapped into GlobalHandler. Its instance is stored on heap, and deallocated when the runtime library is being unloaded.

There's no need to store trivial globals here, as no code for their construction or destruction is generated anyway.

Definition at line 45 of file global_handler.hpp.

Constructor & Destructor Documentation

◆ GlobalHandler() [1/2]

cl::sycl::detail::GlobalHandler::GlobalHandler ( const GlobalHandler )
delete

◆ GlobalHandler() [2/2]

cl::sycl::detail::GlobalHandler::GlobalHandler ( GlobalHandler &&  )
delete

Member Function Documentation

◆ getDeviceFilterList()

device_filter_list & cl::sycl::detail::GlobalHandler::getDeviceFilterList ( const std::string &  InitValue)

Definition at line 82 of file global_handler.cpp.

◆ getFilterMutex()

std::mutex & cl::sycl::detail::GlobalHandler::getFilterMutex ( )

Definition at line 75 of file global_handler.cpp.

◆ getHandlerExtendedMembersMutex()

std::mutex & cl::sycl::detail::GlobalHandler::getHandlerExtendedMembersMutex ( )

Definition at line 90 of file global_handler.cpp.

◆ getHostTaskThreadPool()

ThreadPool & cl::sycl::detail::GlobalHandler::getHostTaskThreadPool ( )

Definition at line 94 of file global_handler.cpp.

References std::get().

◆ getPlatformCache()

std::vector< PlatformImplPtr > & cl::sycl::detail::GlobalHandler::getPlatformCache ( )

Definition at line 67 of file global_handler.cpp.

◆ getPlatformMapMutex()

std::mutex & cl::sycl::detail::GlobalHandler::getPlatformMapMutex ( )

Definition at line 71 of file global_handler.cpp.

◆ getPlatformToDefaultContextCache()

std::unordered_map< PlatformImplPtr, ContextImplPtr > & cl::sycl::detail::GlobalHandler::getPlatformToDefaultContextCache ( )

◆ getPlatformToDefaultContextCacheMutex()

std::mutex & cl::sycl::detail::GlobalHandler::getPlatformToDefaultContextCacheMutex ( )

◆ getPlugins()

std::vector< plugin > & cl::sycl::detail::GlobalHandler::getPlugins ( )

Definition at line 78 of file global_handler.cpp.

◆ getProgramManager()

ProgramManager & cl::sycl::detail::GlobalHandler::getProgramManager ( )

Definition at line 52 of file global_handler.cpp.

◆ getScheduler()

Scheduler & cl::sycl::detail::GlobalHandler::getScheduler ( )

Definition at line 50 of file global_handler.cpp.

◆ getSync()

Sync & cl::sycl::detail::GlobalHandler::getSync ( )

Definition at line 65 of file global_handler.cpp.

◆ getXPTIRegistry()

XPTIRegistry & cl::sycl::detail::GlobalHandler::getXPTIRegistry ( )

Definition at line 86 of file global_handler.cpp.

◆ instance()

GlobalHandler & cl::sycl::detail::GlobalHandler::instance ( )
static
Returns
a reference to a GlobalHandler singleton instance. Memory for storing objects is allocated on first call. The reference is valid as long as runtime library is loaded (i.e. untill DllMain or __attribute__((destructor)) is called).

Definition at line 35 of file global_handler.cpp.

Referenced by cl::sycl::platform::ext_oneapi_get_default_context(), cl::sycl::handler::mem_advise(), and cl::sycl::ext::oneapi::filter_selector::select_device().

◆ registerDefaultContextReleaseHandler()

void cl::sycl::detail::GlobalHandler::registerDefaultContextReleaseHandler ( )
static

Definition at line 119 of file global_handler.cpp.

Friends And Related Function Documentation

◆ releaseDefaultContexts

void releaseDefaultContexts ( )
friend

Definition at line 101 of file global_handler.cpp.

◆ shutdown

void shutdown ( )
friend

Definition at line 123 of file global_handler.cpp.


The documentation for this class was generated from the following files: