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

#include <detail/platform_impl.hpp>

Public Member Functions

 platform_impl ()
 Constructs platform_impl for a SYCL host platform. More...
 
 platform_impl (RT::PiPlatform APlatform, const plugin &APlugin)
 Constructs platform_impl from a plug-in interoperability platform handle. More...
 
 platform_impl (RT::PiPlatform APlatform, std::shared_ptr< plugin > APlugin)
 
 ~platform_impl ()=default
 
bool has_extension (const std::string &ExtensionName) const
 Checks if this platform supports extension. More...
 
std::vector< deviceget_devices (info::device_type DeviceType=info::device_type::all) const
 Returns all SYCL devices associated with this platform. More...
 
template<info::platform param>
info::param_traits< info::platform, param >::return_type get_info () const
 Queries this SYCL platform for info. More...
 
bool is_host () const
 
cl_platform_id get () const
 
const RT::PiPlatformgetHandleRef () const
 Returns raw underlying plug-in platform handle. More...
 
const plugingetPlugin () const
 
void setPlugin (std::shared_ptr< plugin > PluginPtr)
 Sets the platform implementation to use another plugin. More...
 
pi_native_handle 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_implgetOrMakeDeviceImpl (RT::PiDevice PiDevice, 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 PiDevice 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_implgetHostPlatformImpl ()
 Static functions that help maintain platform uniquess and equality of comparison. More...
 
static std::shared_ptr< platform_implgetOrMakePlatformImpl (RT::PiPlatform PiPlatform, const plugin &Plugin)
 Queries the cache to see if the specified PiPlatform has been seen before. More...
 
static std::shared_ptr< platform_implgetPlatformFromPiDevice (RT::PiDevice PiDevice, const plugin &Plugin)
 Queries the cache for the specified platform based on an input device. More...
 

Detailed Description

Definition at line 31 of file platform_impl.hpp.

Constructor & Destructor Documentation

◆ platform_impl() [1/3]

cl::sycl::detail::platform_impl::platform_impl ( )
inline

Constructs platform_impl for a SYCL host platform.

Definition at line 34 of file platform_impl.hpp.

◆ platform_impl() [2/3]

cl::sycl::detail::platform_impl::platform_impl ( RT::PiPlatform  APlatform,
const 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 41 of file platform_impl.hpp.

◆ platform_impl() [3/3]

cl::sycl::detail::platform_impl::platform_impl ( RT::PiPlatform  APlatform,
std::shared_ptr< plugin APlugin 
)
inlineexplicit

Definition at line 44 of file platform_impl.hpp.

◆ ~platform_impl()

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

Member Function Documentation

◆ get()

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

Definition at line 79 of file platform_impl.hpp.

References PI_INVALID_PLATFORM.

◆ get_devices()

std::vector< device > cl::sycl::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 236 of file platform_impl.cpp.

References cl::sycl::all(), cl::sycl::detail::applyAllowList(), cl::sycl::detail::plugin::call(), cl::sycl::detail::device_filter_list::containsHost(), cl::sycl::detail::filterDeviceFilter(), std::get(), cl::sycl::detail::pi::getPlugin(), cl::sycl::detail::pi::initialize(), and piDevicesGet().

◆ get_info()

template<info::platform param>
info::param_traits< info::platform, param >::return_type cl::sycl::detail::platform_impl::get_info

Queries this SYCL platform for info.

The return type depends on information being queried.

Definition at line 319 of file platform_impl.cpp.

References std::get(), and cl::sycl::detail::pi::getPlugin().

◆ get_platforms()

std::vector< platform > cl::sycl::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 96 of file platform_impl.cpp.

References cl::sycl::detail::device_filter_list::backendCompatible(), std::get(), cl::sycl::platform::get_devices(), cl::sycl::detail::get_forced_type(), cl::sycl::detail::pi::initialize(), cl::sycl::detail::IsBannedPlatform(), PI_SUCCESS, and piPlatformsGet().

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

◆ getHandleRef()

const RT::PiPlatform& cl::sycl::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 95 of file platform_impl.hpp.

References PI_INVALID_PLATFORM.

◆ getHostPlatformImpl()

PlatformImplPtr cl::sycl::detail::platform_impl::getHostPlatformImpl ( )
static

Static functions that help maintain platform uniquess and equality of comparison.

Returns the host platform impl

Returns
the host platform impl

Definition at line 30 of file platform_impl.cpp.

◆ getNative()

pi_native_handle cl::sycl::detail::platform_impl::getNative ( ) const

Gets the native handle of the SYCL platform.

Returns
a native handle.

Definition at line 310 of file platform_impl.cpp.

References cl::sycl::detail::pi::getPlugin(), and piextPlatformGetNativeHandle().

◆ getOrMakeDeviceImpl()

std::shared_ptr< device_impl > cl::sycl::detail::platform_impl::getOrMakeDeviceImpl ( RT::PiDevice  PiDevice,
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 PiDevice or add a new entry to the cache.

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

Definition at line 215 of file platform_impl.cpp.

◆ getOrMakePlatformImpl()

PlatformImplPtr cl::sycl::detail::platform_impl::getOrMakePlatformImpl ( RT::PiPlatform  PiPlatform,
const plugin Plugin 
)
static

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

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

Parameters
PiPlatformis the PI Platform handle representing the platform
Pluginis the PI plugin providing the backend for the platform
Returns
the platform_impl representing the PI platform

Definition at line 36 of file platform_impl.cpp.

◆ getPlatformFromPiDevice()

PlatformImplPtr cl::sycl::detail::platform_impl::getPlatformFromPiDevice ( RT::PiDevice  PiDevice,
const plugin 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
PiDeviceis the PI device handle for the device whose platform is desired
Pluginis the PI plugin providing the backend for the device and platform
Returns
the platform_impl that contains the input device

Definition at line 60 of file platform_impl.cpp.

References cl::sycl::detail::plugin::call(), PI_DEVICE_INFO_PLATFORM, and piDeviceGetInfo().

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

◆ getPlugin()

const plugin& cl::sycl::detail::platform_impl::getPlugin ( ) const
inline

Definition at line 113 of file platform_impl.hpp.

◆ has()

bool cl::sycl::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 329 of file platform_impl.cpp.

◆ has_extension()

bool cl::sycl::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 300 of file platform_impl.cpp.

References std::get(), and cl::sycl::detail::pi::getPlugin().

◆ is_host()

bool cl::sycl::detail::platform_impl::is_host ( ) const
inline
Returns
true if this SYCL platform is a host platform.

Definition at line 76 of file platform_impl.hpp.

◆ setPlugin()

void cl::sycl::detail::platform_impl::setPlugin ( std::shared_ptr< plugin PluginPtr)
inline

Sets the platform implementation to use another plugin.

Parameters
PluginPtris a pointer to a plugin instance

Definition at line 121 of file platform_impl.hpp.


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