Function opencl3::device::get_device_info[][src]

pub fn get_device_info(
    device: *mut c_void,
    param_name: u32
) -> Result<InfoType, i32>
Expand description

Get specific information about an OpenCL device.
Calls clGetDeviceInfo to get the desired information about the device.

Examples

use cl3::platform::get_platform_ids;
use cl3::device::{get_device_ids, get_device_info, CL_DEVICE_TYPE, CL_DEVICE_TYPE_GPU, CL_DEVICE_VENDOR, CL_DEVICE_VERSION};
use cl3::types::cl_ulong;

let platform_ids = get_platform_ids().unwrap();
assert!(0 < platform_ids.len());

// Choose a the first platform
let platform_id = platform_ids[0];

let device_ids = get_device_ids(platform_id, CL_DEVICE_TYPE_GPU).unwrap();
println!("CL_DEVICE_TYPE_GPU count: {}", device_ids.len());
assert!(0 < device_ids.len());

// Choose the first device
let device_id = device_ids[0];

let value = get_device_info(device_id, CL_DEVICE_TYPE).unwrap();
let value = cl_ulong::from(value);
println!("CL_DEVICE_TYPE: {}", value);
assert_eq!(CL_DEVICE_TYPE_GPU, value);

let value = get_device_info(device_id, CL_DEVICE_VENDOR).unwrap();
let value = String::from(value);
println!("CL_DEVICE_VENDOR: {}", value);
assert!(!value.is_empty());

let value = get_device_info(device_id, CL_DEVICE_VERSION).unwrap();
let value:String = value.into();
println!("CL_DEVICE_VERSION: {}", value);
assert!(!value.is_empty());
  • device - the cl_device_id of the OpenCL device.
  • param_name - the type of device information being queried, see Device Queries.

returns a Result containing the desired information in an InfoType enum or the error code from the OpenCL C API function.