@@ -24,49 +24,62 @@ class VariantFeatureConfig:
2424 multi_value : bool = False
2525
2626
27+ def getAllUniqueDeviceIPs ():
28+ pci_vendor_id_intel = 0x8086
29+ devips = []
30+ try :
31+ desc = c_ze_init_driver_type_desc_t ()
32+ desc .flags = ZE_INIT_DRIVER_TYPE_FLAG_GPU
33+ drivers = zeInitDrivers (desc )
34+
35+ for driver in drivers :
36+ devices = zeDeviceGet (driver )
37+ for device in devices :
38+ devip = c_ze_device_ip_version_ext_t ()
39+ props = zeDeviceGetProperties (device , [devip ])
40+ if props .vendorId == pci_vendor_id_intel :
41+ devip = IntelDeviceIp (devip .ipVersion )
42+ for ip in devip .get_all_compat_ips ():
43+ # We must return list of unique IPs as a requirement
44+ # of variantlib.
45+ if ip not in devips :
46+ devips .append (ip )
47+ except Exception as e :
48+ warnings .warn (f"Intel driver stack not installed or malfunctions: { e } " , UserWarning , stacklevel = 1 )
49+ return devips
50+
51+
2752class IntelVariantPlugin :
2853 namespace = "intel"
2954 dynamic = False
3055
3156 @classmethod
3257 @cache
3358 def generate_all_device_ips (cls ) -> list [str ] | None :
34- pci_vendor_id_intel = 0x8086
35-
3659 if platform .system () not in ["Linux" , "Windows" ]:
3760 warnings .warn (f"Unsupported OS: { system } " , UserWarning , stacklevel = 1 )
3861 return []
3962
40- try :
41- desc = c_ze_init_driver_type_desc_t ()
42- desc .flags = ZE_INIT_DRIVER_TYPE_FLAG_GPU
43- drivers = zeInitDrivers (desc )
44-
45- devips = []
46- for driver in drivers :
47- devices = zeDeviceGet (driver )
48- for device in devices :
49- devip = c_ze_device_ip_version_ext_t ()
50- props = zeDeviceGetProperties (device , [devip ])
51- if props .vendorId == pci_vendor_id_intel :
52- devip = IntelDeviceIp (devip .ipVersion )
53- for ip in devip .get_all_compat_ips ():
54- # Filter out devices which IPs are not explicitly
55- # known to plugin. This gives consistency with the
56- # check in validate_property().
57- if ip not in get_all_ips ():
58- warnings .warn (f"Intel device with { ip } device IP is filtered out as not known to plugin)" )
59- continue
60- # We must return list of unique IPs as a requirement
61- # of variantlib.
62- if ip not in devips :
63- devips .append (ip )
64- if not devips :
65- warnings .warn ("No Intel GPU detected" , UserWarning , stacklevel = 1 )
66- return devips
67- except Exception as e :
68- warnings .warn (f"Intel driver stack not installed or malfunctions: { e } " , UserWarning , stacklevel = 1 )
69- return []
63+ devip = os .getenv ("INTEL_VARIANT_PROVIDER_FORCE_DEVICE_IP" )
64+ if devip :
65+ unique_devips = [devip ]
66+ else :
67+ unique_devips = getAllUniqueDeviceIPs ()
68+
69+ devips = []
70+ known_ips = get_all_known_ips ()
71+ for ip in unique_devips :
72+ # Filter out devices which IPs are not explicitly
73+ # known to plugin. This gives consistency with the
74+ # check in validate_property().
75+ if ip not in known_ips :
76+ warnings .warn (f"Intel device with { ip } device IP is filtered out as not known to plugin)" )
77+ else :
78+ devips .append (ip )
79+
80+ if not devips :
81+ warnings .warn ("No Intel GPU detected" , UserWarning , stacklevel = 1 )
82+ return devips
7083
7184 @classmethod
7285 def get_supported_configs (cls ) -> list [VariantFeatureConfig ]:
@@ -88,7 +101,7 @@ def get_all_configs(cls) -> list[VariantFeatureConfig]:
88101 return [
89102 VariantFeatureConfig (
90103 name = "device_ip" ,
91- values = get_all_ips (),
104+ values = get_all_known_ips (),
92105 multi_value = True ,
93106 ),
94107 ]
0 commit comments