DPC++ Runtime
Runtime libraries for oneAPI DPC++
sycl::_V1::detail::platform_impl Class Reference

#include <detail/platform_impl.hpp>

Collaboration diagram for sycl::_V1::detail::platform_impl:

Public Member Functions

 platform_impl (ur_platform_handle_t APlatform, const std::shared_ptr< plugin > &APlugin)
 Constructs platform_impl from a plug-in interoperability platform handle. More...
 
 ~platform_impl ()=default
 
bool has_extension (const std::string &ExtensionName) const
 Checks if this platform supports extension. More...
 
bool supports_usm () const
 Checks if this platform supports usm. More...
 
std::vector< deviceget_devices (info::device_type DeviceType=info::device_type::all) const
 Returns all SYCL devices associated with this platform. More...
 
template<typename Param >
Param::return_type get_info () const
 Queries this SYCL platform for info. More...
 
template<typename Param >
Param::return_type get_backend_info () const
 Queries this SYCL platform for SYCL backend-specific information. More...
 
backend getBackend (void) const
 Returns the backend of this platform. More...
 
void getBackendOption (const char *frontend_option, const char **backend_option) const
 Get backend option. More...
 
cl_platform_id get () const
 
const ur_platform_handle_t & getHandleRef () const
 Returns raw underlying plug-in platform handle. More...
 
const PluginPtrgetPlugin () const
 
void setPlugin (PluginPtr &PluginPtr, backend Backend)
 Sets the platform implementation to use another plugin. More...
 
ur_native_handle_t getNative () const
 Gets the native handle of the SYCL platform. More...
 
bool has (aspect Aspect) const
 Indicates if all of the SYCL devices on this platform have the given feature. More...
 
std::shared_ptr< device_implgetDeviceImpl (ur_device_handle_t UrDevice)
 Queries the device_impl cache to return a shared_ptr for the device_impl corresponding to the UrDevice. More...
 
std::shared_ptr< device_implgetOrMakeDeviceImpl (ur_device_handle_t UrDevice, const std::shared_ptr< platform_impl > &PlatformImpl)
 Queries the device_impl cache to either return a shared_ptr for the device_impl corresponding to the UrDevice or add a new entry to the cache. More...
 

Static Public Member Functions

static std::vector< platformget_platforms ()
 Returns all available SYCL platforms in the system. More...
 
static std::shared_ptr< platform_implgetOrMakePlatformImpl (ur_platform_handle_t UrPlatform, const PluginPtr &Plugin)
 Queries the cache to see if the specified UR platform has been seen before. More...
 
static std::shared_ptr< platform_implgetPlatformFromUrDevice (ur_device_handle_t UrDevice, const PluginPtr &Plugin)
 Queries the cache for the specified platform based on an input device. More...
 

Public Attributes

bool MAlwaysRootDevice = false
 

Detailed Description

Definition at line 33 of file platform_impl.hpp.

Constructor & Destructor Documentation

◆ platform_impl()

sycl::_V1::detail::platform_impl::platform_impl ( ur_platform_handle_t  APlatform,
const std::shared_ptr< plugin > &  APlugin 
)
inlineexplicit

Constructs platform_impl from a plug-in interoperability platform handle.

Parameters
APlatformis a raw plug-in platform handle.
APluginis a plug-in handle.

Definition at line 40 of file platform_impl.hpp.

References sycl::_V1::detail::convertUrBackend().

◆ ~platform_impl()

sycl::_V1::detail::platform_impl::~platform_impl ( )
default

Member Function Documentation

◆ get()

cl_platform_id sycl::_V1::detail::platform_impl::get ( ) const
inline
Returns
an instance of OpenCL cl_platform_id.

Definition at line 101 of file platform_impl.hpp.

References getPlugin().

◆ get_backend_info()

template<typename Param >
Param::return_type sycl::_V1::detail::platform_impl::get_backend_info ( ) const

Queries this SYCL platform for SYCL backend-specific information.

The return type depends on information being queried.

◆ get_devices()

std::vector< device > sycl::_V1::detail::platform_impl::get_devices ( info::device_type  DeviceType = info::device_type::all) const

Returns all SYCL devices associated with this platform.

If this platform is a host platform and device type requested is either info::device_type::all or info::device_type::host, resulting vector contains only a single SYCL host device. If there are no devices that match given device type, resulting vector is empty.

Parameters
DeviceTypeis a SYCL device type.
Returns
a vector of SYCL devices.

Definition at line 437 of file platform_impl.cpp.

References sycl::_V1::info::accelerator, sycl::_V1::info::all, sycl::_V1::detail::amendDeviceAndSubDevices(), sycl::_V1::detail::applyAllowList(), sycl::_V1::info::cpu, sycl::_V1::detail::SYCLConfig< Config >::get(), getBackend(), getOrMakePlatformImpl(), sycl::_V1::info::gpu, sycl::_V1::info::host, and sycl::_V1::detail::ur::initializeUr().

Referenced by has().

◆ get_info()

template<typename Param >
Param::return_type sycl::_V1::detail::platform_impl::get_info

Queries this SYCL platform for info.

The return type depends on information being queried.

Definition at line 557 of file platform_impl.cpp.

References getHandleRef(), and getPlugin().

◆ get_platforms()

std::vector< platform > sycl::_V1::detail::platform_impl::get_platforms ( )
static

Returns all available SYCL platforms in the system.

By default the resulting vector always contains a single SYCL host platform instance. There are means to override this behavior for testing purposes. See environment variables guide for up-to-date instructions.

Returns
a vector of all available SYCL platforms.

Definition at line 101 of file platform_impl.cpp.

References sycl::_V1::info::all, getOrMakePlatformImpl(), sycl::_V1::detail::getSyclObjImpl(), sycl::_V1::detail::ur::initializeUr(), sycl::_V1::detail::IsBannedPlatform(), and sycl::_V1::detail::GlobalHandler::registerEarlyShutdownHandler().

Referenced by sycl::_V1::platform::get_platforms().

◆ getBackend()

backend sycl::_V1::detail::platform_impl::getBackend ( void  ) const
inline

Returns the backend of this platform.

Definition at line 89 of file platform_impl.hpp.

Referenced by get_devices(), and supports_usm().

◆ getBackendOption()

void sycl::_V1::detail::platform_impl::getBackendOption ( const char *  frontend_option,
const char **  backend_option 
) const
inline

Get backend option.

Definition at line 92 of file platform_impl.hpp.

References getPlugin().

◆ getDeviceImpl()

std::shared_ptr< device_impl > sycl::_V1::detail::platform_impl::getDeviceImpl ( ur_device_handle_t  UrDevice)

Queries the device_impl cache to return a shared_ptr for the device_impl corresponding to the UrDevice.

Parameters
UrDeviceis the UrDevice whose impl is requested
Returns
a shared_ptr<device_impl> corresponding to the device

Definition at line 277 of file platform_impl.cpp.

◆ getHandleRef()

const ur_platform_handle_t& sycl::_V1::detail::platform_impl::getHandleRef ( ) const
inline

Returns raw underlying plug-in platform handle.

Unlike get() method, this method does not retain handler. It is caller responsibility to make sure that platform stays alive while raw handle is in use.

Returns
a raw plug-in platform handle.

Definition at line 114 of file platform_impl.hpp.

Referenced by get_info(), and getNative().

◆ getNative()

ur_native_handle_t sycl::_V1::detail::platform_impl::getNative ( ) const

Gets the native handle of the SYCL platform.

Returns
a native handle.

Definition at line 549 of file platform_impl.cpp.

References getHandleRef(), and getPlugin().

◆ getOrMakeDeviceImpl()

std::shared_ptr< device_impl > sycl::_V1::detail::platform_impl::getOrMakeDeviceImpl ( ur_device_handle_t  UrDevice,
const std::shared_ptr< platform_impl > &  PlatformImpl 
)

Queries the device_impl cache to either return a shared_ptr for the device_impl corresponding to the UrDevice or add a new entry to the cache.

Parameters
UrDeviceis the UrDevice whose impl is requested
PlatormImplis the Platform for that Device
Returns
a shared_ptr<device_impl> corresponding to the device

Definition at line 282 of file platform_impl.cpp.

◆ getOrMakePlatformImpl()

PlatformImplPtr sycl::_V1::detail::platform_impl::getOrMakePlatformImpl ( ur_platform_handle_t  UrPlatform,
const PluginPtr Plugin 
)
static

Queries the cache to see if the specified UR platform has been seen before.

If so, return the cached platform_impl, otherwise create a new one and cache it.

Parameters
UrPlatformis the UR Platform handle representing the platform
Pluginis the UR plugin providing the backend for the platform
Returns
the platform_impl representing the UR platform

Definition at line 37 of file platform_impl.cpp.

References sycl::_V1::detail::GlobalHandler::getPlatformCache(), and sycl::_V1::detail::GlobalHandler::instance().

Referenced by sycl::_V1::detail::applyAllowList(), sycl::_V1::detail::get_device_info_impl< platform, Param >::get(), get_devices(), get_platforms(), getPlatformFromUrDevice(), and sycl::_V1::detail::make_platform().

◆ getPlatformFromUrDevice()

PlatformImplPtr sycl::_V1::detail::platform_impl::getPlatformFromUrDevice ( ur_device_handle_t  UrDevice,
const PluginPtr Plugin 
)
static

Queries the cache for the specified platform based on an input device.

If found, returns the the cached platform_impl, otherwise creates a new one and caches it.

Parameters
UrDeviceis the UR device handle for the device whose platform is desired
Pluginis the UR plugin providing the backend for the device and platform
Returns
the platform_impl that contains the input device

Definition at line 62 of file platform_impl.cpp.

References getOrMakePlatformImpl().

Referenced by sycl::_V1::detail::context_impl::context_impl().

◆ getPlugin()

const PluginPtr& sycl::_V1::detail::platform_impl::getPlugin ( ) const
inline

Definition at line 126 of file platform_impl.hpp.

Referenced by get(), get_info(), getBackendOption(), getNative(), and has_extension().

◆ has()

bool sycl::_V1::detail::platform_impl::has ( aspect  Aspect) const

Indicates if all of the SYCL devices on this platform have the given feature.

Parameters
Aspectis one of the values in Table 4.20 of the SYCL 2020 Provisional Spec.
Returns
true all of the SYCL devices on this platform have the given feature.

Definition at line 607 of file platform_impl.cpp.

References get_devices().

◆ has_extension()

bool sycl::_V1::detail::platform_impl::has_extension ( const std::string &  ExtensionName) const

Checks if this platform supports extension.

Parameters
ExtensionNameis a string containing extension name.
Returns
true if platform supports specified extension.

Definition at line 537 of file platform_impl.cpp.

References sycl::_V1::detail::get_platform_info_string_impl(), and getPlugin().

Referenced by supports_usm().

◆ setPlugin()

void sycl::_V1::detail::platform_impl::setPlugin ( PluginPtr PluginPtr,
backend  Backend 
)
inline

Sets the platform implementation to use another plugin.

Parameters
PluginPtris a pointer to a plugin instance
Backendis the backend that we want this platform to use

Definition at line 132 of file platform_impl.hpp.

◆ supports_usm()

bool sycl::_V1::detail::platform_impl::supports_usm ( ) const

Checks if this platform supports usm.

Non opencl backends are assumed to support it.

Returns
true if platform supports usm.

Definition at line 544 of file platform_impl.cpp.

References getBackend(), has_extension(), and sycl::_V1::opencl.

Member Data Documentation

◆ MAlwaysRootDevice

bool sycl::_V1::detail::platform_impl::MAlwaysRootDevice = false

Definition at line 198 of file platform_impl.hpp.


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