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::{
12    device::{Aspect, Device},
13    info::Info,
14    private::Sealed,
15};
16
17/// Returns the device type associated with the device. May not return `sycl_rs::info::DeviceType::All`
18pub struct DeviceType;
19impl Sealed for DeviceType {}
20impl Info for DeviceType {
21    type Item = crate::info::DeviceType;
22    type Target = Device;
23    fn get_item(target: &Self::Target) -> Self::Item {
24        ffi::get_device_type(&target.0)
25    }
26}
27
28/// Returns a backend-defined device version.
29pub struct Version;
30impl Sealed for Version {}
31impl Info for Version {
32    type Item = String;
33    type Target = Device;
34    fn get_item(target: &Self::Target) -> Self::Item {
35        ffi::get_version(&target.0)
36    }
37}
38
39/// Returns the device name of this SYCL device.
40pub struct Name;
41impl Sealed for Name {}
42impl Info for Name {
43    type Item = String;
44    type Target = Device;
45    fn get_item(target: &Self::Target) -> Self::Item {
46        ffi::get_name(&target.0)
47    }
48}
49
50/// Returns the PCI BDF address reported by the Intel SYCL extension.
51/// Panics when the device does not support the extension.
52pub struct PciBdfAddress;
53impl Sealed for PciBdfAddress {}
54impl Info for PciBdfAddress {
55    type Item = String;
56    type Target = Device;
57    fn get_item(target: &Self::Target) -> Self::Item {
58        assert!(
59            target.has(Aspect::ExtIntelPciAddress),
60            "device does not support the Intel PCI address extension"
61        );
62        ffi::get_pci_bdf_address(&target.0)
63    }
64}