浏览代码

OpenCL: do not compile kernel on invalid devices

Nathalie Furmento 14 年之前
父节点
当前提交
c3bfa8def3
共有 2 个文件被更改,包括 7 次插入0 次删除
  1. 2 0
      src/drivers/opencl/driver_opencl.c
  2. 5 0
      src/drivers/opencl/driver_opencl_utils.c

+ 2 - 0
src/drivers/opencl/driver_opencl.c

@@ -133,6 +133,8 @@ cl_int _starpu_opencl_deinit_context(int devid)
         err = clReleaseCommandQueue(queues[devid]);
         if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
 
+        contexts[devid] = NULL;
+
 	PTHREAD_MUTEX_UNLOCK(&big_lock);
 
         return CL_SUCCESS;

+ 5 - 0
src/drivers/opencl/driver_opencl_utils.c

@@ -134,6 +134,11 @@ int starpu_opencl_load_opencl_from_string(char *opencl_program_source, struct st
 
                 starpu_opencl_get_device(dev, &device);
                 starpu_opencl_get_context(dev, &context);
+                if (context == NULL) {
+                        _STARPU_DEBUG("[%d] is not a valid OpenCL context\n", dev);
+                        continue;
+                }
+
                 opencl_programs->programs[dev] = NULL;
 
                 if (context == NULL) continue;