OpenCL create subdevices CL_DEVICE_PARTITION_FAILED

核能气质少年 提交于 2019-12-13 06:53:33

问题


I'm stuck at getting clCreateSubDevices working, where CL_DEVICE_PARTITION_FAILED is always returned and I have no clue to solve this problem. I'm trying to create a subdevice with one core only. Here is the code, do you see anything wrong with it? Thanks!

Here are the function signatures: clCreateSubDevices, clGetPlatformIDs, clGetDeviceIDs

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;
}

来源:https://stackoverflow.com/questions/27526963/opencl-create-subdevices-cl-device-partition-failed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!