Platforms

sycl::platform

class platform;

Abstraction for SYCL platform.

A platform contains 1 or more SYCL devices, or a host device.

See also

SYCL Specification Section 4.6.2

Example

Enumerate the platforms and the devices they contain.

 1#include <CL/sycl.hpp>
 2
 3int main() {
 4  auto platforms = sycl::platform::get_platforms();
 5
 6  for (auto &platform : platforms) {
 7    std::cout << "Platform: "
 8	      << platform.get_info<sycl::info::platform::name>()
 9	      << std::endl;
10
11    auto devices = platform.get_devices();
12    for (auto &device : devices ) {
13      std::cout << "  Device: "
14		<< device.get_info<sycl::info::device::name>()
15		<< std::endl;
16    }
17  }
18
19  return 0;
20}

Output:

Platform: Intel(R) FPGA Emulation Platform for OpenCL(TM)
  Device: Intel(R) FPGA Emulation Device
Platform: Intel(R) OpenCL
  Device: Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz
Platform: Intel(R) CPU Runtime for OpenCL(TM) Applications
  Device: Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz
Platform: SYCL host platform
  Device: SYCL host device

(constructors)

platform();
explicit platform(cl_platform_id platformID);
explicit platform(const sycl::device_selector &deviceSelector);

Construct a SYCL platform instance.

The default constructor creates a host platform. When passed a cl_platform_id, an OpenCL|trade| platform is used to construct the platform. The cl_platform_id is retained and available via get. When passed a sycl::device_selector, a platform is constructed that includes the preferred device.

get

cl_platform_id get() const;

Returns the OpenCL device associated with the platform.

Only call this when the platform constructor was passed a cl_platform_id.

get_devices

sycl::vector_class<sycl::device> get_devices(
   sycl::info::device_type = sycl::info::device_type::all) const;

Returns vector of SYCL devices associated with the platform and filtered by sycl::info::device_type

Example

See platform-example.

get_info

template< sycl::info::platform param >
typename sycl::info::param_traits<sycl::info::platform, param>::return_type get_info() const;

Returns information about the platform as determined by param.

See sycl::info::platform for details.

Example

See platform-example.

has_extension

bool has_extension(const sycl::string_class &extension) const;

Returns True if the platform has extension.

is_host

bool is_host() const;

Returns True if the platform contains a SYCL host device

get_platforms

static sycl::vector_class<platform> get_platforms();

Returns a vector_class containing SYCL platforms bound to the system.

Example

See platform-example.

sycl::info::platform

enum class platform : unsigned int {
  profile,
  version,
  name,
  vendor,
  extensions
};

Used as a template parameter for get_info to determine the type of information.

Descriptor

Return type

Description

profile

string_class

OpenCL profile

version

string_class

OpenCL software driver version

name

string_class

Device name of the platform

vendor

string_class

Vendor name

extensions

vector_class<string_class>

Extension names supported by the platform