[Beignet] [PATCH 2/2] provide meaningful device names through clGetDeviceInfo

Mario Kicherer dev at kicherer.org
Sun Dec 29 14:04:04 PST 2013


Signed-off-by: Mario Kicherer <dev at kicherer.org>
---
 src/cl_device_id.c | 61 ++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 41 insertions(+), 20 deletions(-)

diff --git a/src/cl_device_id.c b/src/cl_device_id.c
index 865d26d..5e7d86b 100644
--- a/src/cl_device_id.c
+++ b/src/cl_device_id.c
@@ -70,28 +70,49 @@ cl_get_gt_device(void)
   cl_device_id ret = NULL;
   const int device_id = cl_driver_get_device_id();
 
+#define DECL_INFO_STRING(STRUCT, FIELD, STRING) \
+    STRUCT.FIELD = STRING; \
+    STRUCT.JOIN(FIELD,_sz) = sizeof(STRING);
+  
   /* XXX we pick IVB for HSW now */
-  if (device_id == PCI_CHIP_HASWELL_M   ||
-      device_id == PCI_CHIP_HASWELL_L   ||
-      device_id == PCI_CHIP_HASWELL_M0  ||
-      device_id == PCI_CHIP_HASWELL_D0) {
-    intel_hsw_device.vendor_id = device_id;
-    intel_hsw_device.platform = intel_platform;
-    ret = &intel_hsw_device;
-  }
-  else if (device_id == PCI_CHIP_IVYBRIDGE_GT1   ||
-           device_id == PCI_CHIP_IVYBRIDGE_M_GT1 ||
-           device_id == PCI_CHIP_IVYBRIDGE_S_GT1) {
-    intel_ivb_gt1_device.vendor_id = device_id;
-    intel_ivb_gt1_device.platform = intel_platform;
-    ret = &intel_ivb_gt1_device;
-  }
-  else if (device_id == PCI_CHIP_IVYBRIDGE_GT2   ||
-           device_id == PCI_CHIP_IVYBRIDGE_M_GT2) {
-    intel_ivb_gt2_device.vendor_id = device_id;
-    intel_ivb_gt2_device.platform = intel_platform;
-    ret = &intel_ivb_gt2_device;
+  switch (device_id) {
+    case PCI_CHIP_HASWELL_M:
+      DECL_INFO_STRING(intel_hsw_device, name, "Intel(R) HD Graphics Haswell M");
+    case PCI_CHIP_HASWELL_L:
+      DECL_INFO_STRING(intel_hsw_device, name, "Intel(R) HD Graphics Haswell L");
+    case PCI_CHIP_HASWELL_M0:
+      DECL_INFO_STRING(intel_hsw_device, name, "Intel(R) HD Graphics Haswell M0");
+    case PCI_CHIP_HASWELL_D0:
+      DECL_INFO_STRING(intel_hsw_device, name, "Intel(R) HD Graphics Haswell D0");
+      intel_hsw_device.vendor_id = device_id;
+      intel_hsw_device.platform = intel_platform;
+      ret = &intel_hsw_device;
+      break;
+
+    case PCI_CHIP_IVYBRIDGE_GT1:
+      DECL_INFO_STRING(intel_ivb_gt1_device, name, "Intel(R) HD Graphics IvyBridge GT1");
+    case PCI_CHIP_IVYBRIDGE_M_GT1:
+      DECL_INFO_STRING(intel_ivb_gt1_device, name, "Intel(R) HD Graphics IvyBridge M GT1");
+    case PCI_CHIP_IVYBRIDGE_S_GT1:
+      DECL_INFO_STRING(intel_ivb_gt1_device, name, "Intel(R) HD Graphics IvyBridge S GT1");
+      intel_ivb_gt1_device.vendor_id = device_id;
+      intel_ivb_gt1_device.platform = intel_platform;
+      ret = &intel_ivb_gt1_device;
+      break;
+
+    case PCI_CHIP_IVYBRIDGE_GT2:
+      DECL_INFO_STRING(intel_ivb_gt2_device, name, "Intel(R) HD Graphics IvyBridge GT2");
+    case PCI_CHIP_IVYBRIDGE_M_GT2:
+      DECL_INFO_STRING(intel_ivb_gt2_device, name, "Intel(R) HD Graphics IvyBridge M GT2");
+      intel_ivb_gt2_device.vendor_id = device_id;
+      intel_ivb_gt2_device.platform = intel_platform;
+      ret = &intel_ivb_gt2_device;
+      break;
+    default:
+      printf("cl_get_gt_device(): error, unknown device\n");
+      exit(1);
   }
+
   return ret;
 }
 
-- 
1.8.3.2



More information about the Beignet mailing list