Function cl3::device::get_device_info[][src]

pub fn get_device_info(
    device: cl_device_id,
    param_name: DeviceInfo
) -> Result<InfoType, cl_int>

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_GPU, DeviceInfo,};

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 a the first device
let device_id = device_ids[0];

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

let value = get_device_info(device_id, DeviceInfo::CL_DEVICE_VENDOR).unwrap();
let value = value.to_str().unwrap();
println!("CL_DEVICE_VENDOR: {:?}", value);
assert!(0 < value.to_bytes().len());

let value = get_device_info(device_id, DeviceInfo::CL_DEVICE_VERSION).unwrap();
let value = value.to_str().unwrap();
println!("CL_DEVICE_VERSION: {:?}", value);
assert!(0 < value.to_bytes().len());
  • 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.