diff --git a/c10/xpu/XPUDeviceProp.h b/c10/xpu/XPUDeviceProp.h index 00b7969a73d4..591a14f4ad91 100644 --- a/c10/xpu/XPUDeviceProp.h +++ b/c10/xpu/XPUDeviceProp.h @@ -113,18 +113,21 @@ namespace c10::xpu { _(native_vector_width_double) \ _(native_vector_width_half) -#define AT_FORALL_XPU_EXT_DEVICE_PROPERTIES(_) \ - /* the number of EUs associated with the Intel GPU. */ \ - _(gpu_eu_count, 512) \ - \ - /* the number of EUs in a subslice. */ \ - _(gpu_eu_count_per_subslice, 8) \ - \ - /* the simd width of EU of GPU. */ \ - _(gpu_eu_simd_width, 8) \ - \ - /* the number of hardware threads per EU of GPU. */ \ - _(gpu_hw_threads_per_eu, 8) +#define AT_FORALL_XPU_EXT_DEVICE_PROPERTIES(_) \ + /* the number of EUs associated with the Intel GPU. */ \ + _(gpu_eu_count, 512) \ + \ + /* the number of EUs in a subslice. */ \ + _(gpu_eu_count_per_subslice, 8) \ + \ + /* the simd width of EU of GPU. */ \ + _(gpu_eu_simd_width, 8) \ + \ + /* the number of hardware threads per EU of GPU. */ \ + _(gpu_hw_threads_per_eu, 8) \ + \ + /* the device identifier of the Intel GPU, also known as the product ID. */ \ + _(device_id, 0) #define AT_FORALL_XPU_DEVICE_ASPECT(_) \ /* sycl::half is supported on device. */ \ diff --git a/test/test_xpu.py b/test/test_xpu.py index c8bef60998ef..cd5275418c44 100644 --- a/test/test_xpu.py +++ b/test/test_xpu.py @@ -101,6 +101,7 @@ class TestXpu(TestCase): self.assertEqual(device_name, torch.xpu.get_device_name()) device_capability = torch.xpu.get_device_capability(current_device) + self.assertTrue(device_capability["device_id"] > 0) self.assertTrue(device_capability["max_work_group_size"] > 0) self.assertTrue(device_capability["max_num_sub_groups"] > 0) self.assertEqual( diff --git a/torch/_C/__init__.pyi.in b/torch/_C/__init__.pyi.in index e1a940c74a4f..a9810251d1f4 100644 --- a/torch/_C/__init__.pyi.in +++ b/torch/_C/__init__.pyi.in @@ -2342,6 +2342,7 @@ class _XpuDeviceProperties: name: str platform_name: str vendor: str + device_id: _int driver_version: str version: str max_compute_units: _int diff --git a/torch/csrc/xpu/Module.cpp b/torch/csrc/xpu/Module.cpp index 6c3204490003..715bf5b8fb66 100644 --- a/torch/csrc/xpu/Module.cpp +++ b/torch/csrc/xpu/Module.cpp @@ -305,6 +305,7 @@ static void registerXpuDeviceProperties(PyObject* module) { ._(name) \ ._(platform_name) \ ._(vendor) \ + ._(device_id) \ ._(driver_version) \ ._(version) \ ._(max_compute_units) \ @@ -333,8 +334,10 @@ static void registerXpuDeviceProperties(PyObject* module) { std::ostringstream stream; stream << "_XpuDeviceProperties(name='" << prop.name << "', platform_name='" << prop.platform_name << "', type='" - << get_device_type(prop) << "', driver_version='" - << prop.driver_version << "', total_memory=" + << get_device_type(prop) << "', device_id=0x" << std::hex + << std::uppercase << prop.device_id << std::dec + << ", driver_version='" << prop.driver_version + << "', total_memory=" << prop.global_mem_size / (1024ull * 1024) << "MB" << ", max_compute_units=" << prop.max_compute_units << ", gpu_eu_count=" << prop.gpu_eu_count