Skip to main content

sycl_rs/info/
device-info.rs

1//
2// Copyright (C) 2026 Intel Corporation
3//
4// Under the MIT License or the Apache License v2.0.
5// See LICENSE-MIT and LICENSE-APACHE for license information.
6// SPDX-License-Identifier: MIT OR Apache-2.0
7//
8
9use sycl_rs_sys::device::ffi;
10
11use crate::{Result, device::Device, info::Info, private::Sealed};
12
13/// Returns the device type associated with the device. May not return `sycl_rs::info::DeviceType::All`
14pub struct DeviceType;
15impl Sealed for DeviceType {}
16impl Info for DeviceType {
17    type Item = crate::info::DeviceType;
18    type Target = Device;
19    fn get_item(target: &Self::Target) -> Self::Item {
20        ffi::get_device_type(&target.0)
21    }
22}
23
24/// Returns a backend-defined device version.
25pub struct Version;
26impl Sealed for Version {}
27impl Info for Version {
28    type Item = String;
29    type Target = Device;
30    fn get_item(target: &Self::Target) -> Self::Item {
31        ffi::get_version(&target.0)
32    }
33}
34
35/// Returns the device name of this SYCL device.
36pub struct Name;
37impl Sealed for Name {}
38impl Info for Name {
39    type Item = String;
40    type Target = Device;
41    fn get_item(target: &Self::Target) -> Self::Item {
42        ffi::get_name(&target.0)
43    }
44}
45
46/// Returns the PCI BDF address reported by the Intel SYCL extension.
47/// Returns an error when the device does not support the extension or the query fails.
48pub struct PciBdfAddress;
49impl Sealed for PciBdfAddress {}
50impl Info for PciBdfAddress {
51    type Item = Result<String>;
52    type Target = Device;
53    fn get_item(target: &Self::Target) -> Self::Item {
54        ffi::get_pci_bdf_address(&target.0)
55    }
56}