diff options
author | Rebecca Palmer <rebecca_palmer@zoho.com> | 2014-08-08 12:07:24 +0100 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2014-08-12 14:34:27 +0800 |
commit | 2cbeeba1994c2d196770115b7033a6e66d904d00 (patch) | |
tree | 2e7b14c1e7f400ac3c2761a4de93c085a590c66a /src/intel | |
parent | f2d209ee6c8994104cb02da6b0c1b985cf394416 (diff) |
Fail gracefully on unsupported hardware
If no compatible hardware is present, clGetDeviceIDs is supposed to
report CL_DEVICE_NOT_FOUND to the caller, but in Beignet this currently
ends the whole program with exit(-1) or assert(0). This fixes this.
This is required to have a "just works" OpenCL in Debian/Ubuntu, as
their package manager doesn't know the hardware and hence commonly will
install Beignet on hardware that doesn't support it; returning an error
allows the caller to try other ICDs until it finds the right one, or to
run without using OpenCL. Previous discussion:
http://lists.alioth.debian.org/pipermail/pkg-opencl-devel/Week-of-Mon-20140217/000096.html
http://lists.alioth.debian.org/pipermail/pkg-opencl-devel/Week-of-Mon-20140217/000100.html
Testing if you only have supported hardware: use a chroot, the GPU
isn't visible from inside.
Identical patch in case line wrap mangles this:
https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=27;filename=fail_gracefully_without_hardware;att=1;bug=745363
Signed-off-by: Rebecca Palmer <rebecca_palmer@zoho.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/intel_driver.c | 11 | ||||
-rw-r--r-- | src/intel/intel_gpgpu.c | 2 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c index 3cef2f89..2b6d393e 100644 --- a/src/intel/intel_driver.c +++ b/src/intel/intel_driver.c @@ -193,7 +193,7 @@ intel_driver_init(intel_driver_t *driver, int dev_fd) #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, cl_context_prop props) && 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, cl_context_prop props) 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, cl_context_prop props) 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 props) { 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: diff --git a/src/intel/intel_gpgpu.c b/src/intel/intel_gpgpu.c index 1382ce65..867ab4cf 100644 --- a/src/intel/intel_gpgpu.c +++ b/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); } |