Bug#745363: beignet: No way to check whether the hardware is present

2014-08-08 Thread Rebecca Palmer

Sorry, missed a new-in-0.9 fail point; corrected version attached.

(Testing hint: by default, the GPU isn't visible from inside a chroot)

Upgrading to 0.9 does fix #745767 (duplicate listing in 
/etc/OpenCL/vendors), and comments there suggest it fixes LP#1350773 
(llvm 3.5 incompatibility); #740695/LP#1255323 (broken header path) 
appears to already be fixed in 0.8.
Description: If no device, return CL_DEVICE_NOT_FOUND instead of exiting

If no Intel GPU is present, beignet currently exits on
clGetDeviceIDs.  This patch instead returns CL_DEVICE_NOT_FOUND,
allowing the calling application to decide what to do
(e.g. try a different platform).

Author: Rebecca Palmer rebecca_pal...@zoho.com
Bug-Debian: https://bugs.debian.org/745363
Forwarded: no


--- beignet-0.9.3git.orig/src/cl_api.c
+++ beignet-0.9.3git/src/cl_api.c
@@ -170,6 +170,7 @@ cl_check_device_type(cl_device_type devi
 static cl_int
 cl_device_id_is_ok(const cl_device_id device)
 {
+  if(UNLIKELY(device == NULL)) return CL_FALSE;
   return device != cl_get_gt_device() ? CL_FALSE : CL_TRUE;
 }
 
--- beignet-0.9.3git.orig/src/cl_device_data.h
+++ beignet-0.9.3git/src/cl_device_data.h
@@ -20,6 +20,8 @@
 #ifndef __CL_DEVICE_DATA_H__
 #define __CL_DEVICE_DATA_H__
 
+#define INVALID_CHIP_ID -1 //returned by intel_get_device_id if no device found
+
 #define PCI_CHIP_GM45_GM0x2A42
 #define PCI_CHIP_IGD_E_G0x2E02
 #define PCI_CHIP_Q45_G  0x2E12
--- beignet-0.9.3git.orig/src/intel/intel_driver.c
+++ beignet-0.9.3git/src/intel/intel_driver.c
@@ -193,7 +193,7 @@ intel_driver_init(intel_driver_t *driver
 #endif /* EMULATE_GEN */
 }
 
-static void
+static cl_int
 intel_driver_open(intel_driver_t *intel, cl_context_prop props)
 {
   int cardi;
@@ -203,7 +203,7 @@ intel_driver_open(intel_driver_t *intel,
props-gl_type != CL_GL_GLX_DISPLAY
props-gl_type != CL_GL_EGL_DISPLAY) {
 fprintf(stderr, Unsupported gl share type %d.\n, props-gl_type);
-exit(-1);
+return CL_INVALID_OPERATION;
   }
 
   intel-x11_display = XOpenDisplay(NULL);
@@ -239,7 +239,7 @@ intel_driver_open(intel_driver_t *intel,
 
   if(!intel_driver_is_active(intel)) {
 fprintf(stderr, Device open failed, aborting...\n);
-exit(-1);
+return CL_DEVICE_NOT_FOUND;
   }
 
 #ifdef HAS_EGL
@@ -247,6 +247,7 @@ intel_driver_open(intel_driver_t *intel,
 assert(props-egl_display);
   }
 #endif
+  return CL_SUCCESS;
 }
 
 static void
@@ -399,7 +400,7 @@ intel_get_device_id(void)
 
   driver = intel_driver_new();
   assert(driver != NULL);
-  intel_driver_open(driver, NULL);
+  if(UNLIKELY(intel_driver_open(driver, NULL) != CL_SUCCESS)) return 
INVALID_CHIP_ID;
   intel_device_id = driver-device_id;
   intel_driver_context_destroy(driver);
   intel_driver_close(driver);
@@ -426,7 +427,7 @@ cl_intel_driver_new(cl_context_prop prop
 {
   intel_driver_t *driver = NULL;
   TRY_ALLOC_NO_ERR (driver, intel_driver_new());
-  intel_driver_open(driver, props);
+  if(UNLIKELY(intel_driver_open(driver, props) != CL_SUCCESS)) goto error;
 exit:
   return driver;
 error:
--- beignet-0.9.3git.orig/src/intel/intel_gpgpu.c
+++ beignet-0.9.3git/src/intel/intel_gpgpu.c
@@ -1500,6 +1500,4 @@ intel_set_gpgpu_callbacks(int device_id)
 intel_gpgpu_get_scratch_index = intel_gpgpu_get_scratch_index_gen7;
 intel_gpgpu_post_action = intel_gpgpu_post_action_gen7;
   }
-  else
-assert(0);
 }


Bug#745363: beignet: No way to check whether the hardware is present

2014-08-07 Thread Rebecca Palmer
(Sorry for delay: n...@bugs.debian.org doesn't go to the bug submitter, 
you need nnn-submit...@bugs.debian.org for that.)


I recently acquired Intel GPU hardware: 0.8 works as well with this 
patch as without it (i.e. badly but that's an unrelated problem: 
https://bugs.launchpad.net/ubuntu/+source/beignet/+bug/1354086 ).  The 
patch fails to apply to 0.9x; I will attempt to fix this and submit it 
upstream.


Also, there's a copyright problem in CMakeLists.txt: 
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=757395



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org