Develop OpenCL application without GPU support on Laptop?

房东的猫 提交于 2019-12-13 03:37:22

问题


I am new to OpenCL and want to develop a portable hardware independent OpenCL application. I have ATI Radeon 7670m on my laptop which has OpenCL 1.1 support as per official website. However this GPU is not listed on the APP SDK system requirements site. I am interested in using OpenCL for developing only for GPU and not for CPU. So is there a way I can do this?


回答1:


I guess, information on site is outdated. 7670 is OpenCL-compatible for sure. In fact, almost all cards of 5xxx series & newer can run OpenCL.




回答2:


With OpenCL Context you can choose which device use for development (for example, CPU or GPU devices), in your case CL_DEVICE_TYPE_GPU:

cl::Context context(CL_DEVICE_TYPE_GPU, cprops, NULL, NULL, &err);

For example, from official AMD documentation:

int main(void)
{
    cl_int err;
    cl::vector< cl::Platform > platformList;
    cl::Platform::get(&platformList);
    checkErr(platformList.size()!=0 ? CL_SUCCESS : -1, "cl::Platform::get");
    std::cerr << "Platform number is: " << platformList.size() << std::endl;std::string platformVendor;
    platformList[0].getInfo((cl_platform_info)CL_PLATFORM_VENDOR, &platformVendor);
    std::cerr << "Platform is by: " << platformVendor << "\n";
    cl_context_properties cprops[3] = {CL_CONTEXT_PLATFORM, (cl_context_properties)(platformList[0])(), 0};
    cl::Context context(CL_DEVICE_TYPE_GPU, cprops, NULL, NULL, &err);
    checkErr(err, "Conext::Context()"); 
}


来源:https://stackoverflow.com/questions/21937673/develop-opencl-application-without-gpu-support-on-laptop

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