Platform

Struct Platform 

Source
pub struct Platform { /* private fields */ }
Expand description

Structure containing information about an OpenCL platform.

Implementations§

Source§

impl Platform

Source

pub fn get(id: PlatformId) -> Result<Self>

Get the platform information for the given platform ID.

§Errors

The following errors may be returned:

  • Error::InvalidPlatform - An invalid platform ID was passed.
Examples found in repository?
examples/clinfo.rs (line 26)
5fn main() {
6    let platforms = Platform::get_all();
7    println!("Number of platforms                               {}", platforms.len());
8    for platform in &platforms {
9        println!("  Platform Name                                   {}", platform.name());
10        println!("  Platform Vendor                                 {}", platform.vendor());
11        println!("  Platform Version                                {}", platform.version());
12        println!("  Platform Profile                                {}", platform.profile());
13        println!("  Platform Extensions                             {}", platform.extensions().join(" "));
14    }
15    if !platforms.is_empty() {
16        println!();
17    }
18
19    for platform in &platforms {
20        println!("  Platform Name                                   {}", platform.name());
21        if let Ok(device_ids) = cl_get_device_ids(platform.id(), DeviceType::ALL) {
22            println!("Number of devices                                 {}", device_ids.len());
23        }
24    }
25
26    if let Ok(null_platform) = Platform::get(0) {
27        println!();
28        println!("NULL platform behavior");
29        println!("  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  {}", null_platform.name());
30    }
31}
Source

pub fn get_all() -> Vec<Platform>

Get all available platforms.

§Examples
for platform in Platform::get_all() {
    println!("Profile: {}", platform.profile());
    println!("Version: {}", platform.version());
    println!("Name: {}", platform.name());
    println!("Vendor: {}", platform.vendor());
    println!("Extensions: {}", platform.extensions().join(" "));
}
Examples found in repository?
examples/clinfo.rs (line 6)
5fn main() {
6    let platforms = Platform::get_all();
7    println!("Number of platforms                               {}", platforms.len());
8    for platform in &platforms {
9        println!("  Platform Name                                   {}", platform.name());
10        println!("  Platform Vendor                                 {}", platform.vendor());
11        println!("  Platform Version                                {}", platform.version());
12        println!("  Platform Profile                                {}", platform.profile());
13        println!("  Platform Extensions                             {}", platform.extensions().join(" "));
14    }
15    if !platforms.is_empty() {
16        println!();
17    }
18
19    for platform in &platforms {
20        println!("  Platform Name                                   {}", platform.name());
21        if let Ok(device_ids) = cl_get_device_ids(platform.id(), DeviceType::ALL) {
22            println!("Number of devices                                 {}", device_ids.len());
23        }
24    }
25
26    if let Ok(null_platform) = Platform::get(0) {
27        println!();
28        println!("NULL platform behavior");
29        println!("  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  {}", null_platform.name());
30    }
31}
Source

pub fn id(&self) -> PlatformId

The ID of the platform.

Examples found in repository?
examples/clinfo.rs (line 21)
5fn main() {
6    let platforms = Platform::get_all();
7    println!("Number of platforms                               {}", platforms.len());
8    for platform in &platforms {
9        println!("  Platform Name                                   {}", platform.name());
10        println!("  Platform Vendor                                 {}", platform.vendor());
11        println!("  Platform Version                                {}", platform.version());
12        println!("  Platform Profile                                {}", platform.profile());
13        println!("  Platform Extensions                             {}", platform.extensions().join(" "));
14    }
15    if !platforms.is_empty() {
16        println!();
17    }
18
19    for platform in &platforms {
20        println!("  Platform Name                                   {}", platform.name());
21        if let Ok(device_ids) = cl_get_device_ids(platform.id(), DeviceType::ALL) {
22            println!("Number of devices                                 {}", device_ids.len());
23        }
24    }
25
26    if let Ok(null_platform) = Platform::get(0) {
27        println!();
28        println!("NULL platform behavior");
29        println!("  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  {}", null_platform.name());
30    }
31}
Source

pub fn profile(&self) -> Profile

The profile of the platform.

Examples found in repository?
examples/clinfo.rs (line 12)
5fn main() {
6    let platforms = Platform::get_all();
7    println!("Number of platforms                               {}", platforms.len());
8    for platform in &platforms {
9        println!("  Platform Name                                   {}", platform.name());
10        println!("  Platform Vendor                                 {}", platform.vendor());
11        println!("  Platform Version                                {}", platform.version());
12        println!("  Platform Profile                                {}", platform.profile());
13        println!("  Platform Extensions                             {}", platform.extensions().join(" "));
14    }
15    if !platforms.is_empty() {
16        println!();
17    }
18
19    for platform in &platforms {
20        println!("  Platform Name                                   {}", platform.name());
21        if let Ok(device_ids) = cl_get_device_ids(platform.id(), DeviceType::ALL) {
22            println!("Number of devices                                 {}", device_ids.len());
23        }
24    }
25
26    if let Ok(null_platform) = Platform::get(0) {
27        println!();
28        println!("NULL platform behavior");
29        println!("  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  {}", null_platform.name());
30    }
31}
Source

pub fn version(&self) -> &Version

The OpenCL version of the platform.

Examples found in repository?
examples/clinfo.rs (line 11)
5fn main() {
6    let platforms = Platform::get_all();
7    println!("Number of platforms                               {}", platforms.len());
8    for platform in &platforms {
9        println!("  Platform Name                                   {}", platform.name());
10        println!("  Platform Vendor                                 {}", platform.vendor());
11        println!("  Platform Version                                {}", platform.version());
12        println!("  Platform Profile                                {}", platform.profile());
13        println!("  Platform Extensions                             {}", platform.extensions().join(" "));
14    }
15    if !platforms.is_empty() {
16        println!();
17    }
18
19    for platform in &platforms {
20        println!("  Platform Name                                   {}", platform.name());
21        if let Ok(device_ids) = cl_get_device_ids(platform.id(), DeviceType::ALL) {
22            println!("Number of devices                                 {}", device_ids.len());
23        }
24    }
25
26    if let Ok(null_platform) = Platform::get(0) {
27        println!();
28        println!("NULL platform behavior");
29        println!("  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  {}", null_platform.name());
30    }
31}
Source

pub fn name(&self) -> &str

The name of the platform.

Examples found in repository?
examples/clinfo.rs (line 9)
5fn main() {
6    let platforms = Platform::get_all();
7    println!("Number of platforms                               {}", platforms.len());
8    for platform in &platforms {
9        println!("  Platform Name                                   {}", platform.name());
10        println!("  Platform Vendor                                 {}", platform.vendor());
11        println!("  Platform Version                                {}", platform.version());
12        println!("  Platform Profile                                {}", platform.profile());
13        println!("  Platform Extensions                             {}", platform.extensions().join(" "));
14    }
15    if !platforms.is_empty() {
16        println!();
17    }
18
19    for platform in &platforms {
20        println!("  Platform Name                                   {}", platform.name());
21        if let Ok(device_ids) = cl_get_device_ids(platform.id(), DeviceType::ALL) {
22            println!("Number of devices                                 {}", device_ids.len());
23        }
24    }
25
26    if let Ok(null_platform) = Platform::get(0) {
27        println!();
28        println!("NULL platform behavior");
29        println!("  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  {}", null_platform.name());
30    }
31}
Source

pub fn vendor(&self) -> &str

The vendor of the platform.

Examples found in repository?
examples/clinfo.rs (line 10)
5fn main() {
6    let platforms = Platform::get_all();
7    println!("Number of platforms                               {}", platforms.len());
8    for platform in &platforms {
9        println!("  Platform Name                                   {}", platform.name());
10        println!("  Platform Vendor                                 {}", platform.vendor());
11        println!("  Platform Version                                {}", platform.version());
12        println!("  Platform Profile                                {}", platform.profile());
13        println!("  Platform Extensions                             {}", platform.extensions().join(" "));
14    }
15    if !platforms.is_empty() {
16        println!();
17    }
18
19    for platform in &platforms {
20        println!("  Platform Name                                   {}", platform.name());
21        if let Ok(device_ids) = cl_get_device_ids(platform.id(), DeviceType::ALL) {
22            println!("Number of devices                                 {}", device_ids.len());
23        }
24    }
25
26    if let Ok(null_platform) = Platform::get(0) {
27        println!();
28        println!("NULL platform behavior");
29        println!("  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  {}", null_platform.name());
30    }
31}
Source

pub fn extensions(&self) -> &[String]

The available extensions on the platform.

Examples found in repository?
examples/clinfo.rs (line 13)
5fn main() {
6    let platforms = Platform::get_all();
7    println!("Number of platforms                               {}", platforms.len());
8    for platform in &platforms {
9        println!("  Platform Name                                   {}", platform.name());
10        println!("  Platform Vendor                                 {}", platform.vendor());
11        println!("  Platform Version                                {}", platform.version());
12        println!("  Platform Profile                                {}", platform.profile());
13        println!("  Platform Extensions                             {}", platform.extensions().join(" "));
14    }
15    if !platforms.is_empty() {
16        println!();
17    }
18
19    for platform in &platforms {
20        println!("  Platform Name                                   {}", platform.name());
21        if let Ok(device_ids) = cl_get_device_ids(platform.id(), DeviceType::ALL) {
22            println!("Number of devices                                 {}", device_ids.len());
23        }
24    }
25
26    if let Ok(null_platform) = Platform::get(0) {
27        println!();
28        println!("NULL platform behavior");
29        println!("  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  {}", null_platform.name());
30    }
31}

Trait Implementations§

Source§

impl Clone for Platform

Source§

fn clone(&self) -> Platform

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Platform

Source§

fn default() -> Self

Get the default platform of the system.

§Panics

This function may panic if there are no available platforms or if there is no default.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.