浏览代码

tests/main/driver_api: set cl_device_type properly before calling clGetDeviceIDs

Nathalie Furmento 12 年之前
父节点
当前提交
2238313448
共有 2 个文件被更改,包括 13 次插入2 次删除
  1. 7 1
      tests/main/driver_api/init_run_deinit.c
  2. 6 1
      tests/main/driver_api/run_driver.c

+ 7 - 1
tests/main/driver_api/init_run_deinit.c

@@ -199,8 +199,14 @@ test_opencl(void)
 		return STARPU_TEST_SKIPPED;
 	}
 
+	cl_device_type device_type = CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR;
+	if (starpu_get_env_number("STARPU_OPENCL_ON_CPUS") > 0)
+		device_type |= CL_DEVICE_TYPE_CPU;
+	if (starpu_get_env_number("STARPU_OPENCL_ONLY_ON_CPUS") > 0)
+		device_type = CL_DEVICE_TYPE_CPU;
+
 	cl_device_id device_id;
-        err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device_id, NULL);
+        err = clGetDeviceIDs(platform, device_type, 1, &device_id, NULL);
         if (err != CL_SUCCESS)
         {
 		FPRINTF(stderr, "WARNING: No GPU devices found on OpenCL platform\n");

+ 6 - 1
tests/main/driver_api/run_driver.c

@@ -190,8 +190,13 @@ test_opencl(void)
 		return STARPU_TEST_SKIPPED;
 	}
 
+	cl_device_type device_type = CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR;
+	if (starpu_get_env_number("STARPU_OPENCL_ON_CPUS") > 0)
+		device_type |= CL_DEVICE_TYPE_CPU;
+	if (starpu_get_env_number("STARPU_OPENCL_ONLY_ON_CPUS") > 0)
+		device_type = CL_DEVICE_TYPE_CPU;
+
 	cl_device_id device_id;
-	int device_type = CL_DEVICE_TYPE_GPU; /* TODO Support CPU */
         err = clGetDeviceIDs(platform, device_type, 1, &device_id, NULL);
         if (err != CL_SUCCESS)
 	{