OpenCL创建子设备CL_DEVICE_PARTITION_FAILED

时间:2014-12-17 13:44:24

标签: opencl

我坚持让clCreateSubDevices工作,总是返回CL_DEVICE_PARTITION_FAILED,我无法解决这个问题。我试图创建一个只有一个核心的子设备。这是代码,你看到它有什么问题吗?谢谢!

以下是功能签名: clCreateSubDevicesclGetPlatformIDsclGetDeviceIDs

cl_platform_id platform_id = NULL;
cl_device_id device_id = NULL;
cl_uint ret_num_devices;
cl_uint ret_num_platforms;
cl_int ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms);
ret = clGetDeviceIDs( platform_id, CL_DEVICE_TYPE_GPU, 1,
                     &device_id, &ret_num_devices);

if (device_id == NULL) {
    fprintf(stderr, "failed to get device id!");
    return 1;
}

const cl_device_partition_property properties[3] = {
    CL_DEVICE_PARTITION_BY_COUNTS,
    1, // Use only one compute unit
    CL_DEVICE_PARTITION_BY_COUNTS_LIST_END
};

cl_device_id subdevice_id;
cl_int error = clCreateSubDevices(device_id, properties, 1, &subdevice_id, NULL);
if (error != CL_SUCCESS) {
    fprintf(stderr, "failed to create sub device %d!\n", error);
    return 1;
}

0 个答案:

没有答案