Develop an OpenCL application without GPU support on a laptop?
I am new to OpenCL and want to develop a portable, hardware independent OpenCL application. I have an ATI Radeon 7670m on my laptop that supports OpenCL 1.1 on the official site . However, this GPU is missing from the APP SDK system requirements. I'm interested in using OpenCL for GPU-only development, not CPU-only. So can I do this?
0
source to share
2 answers
With the OpenCL Context, you can choose which device to use for development (like processors or GPU devices), in your case CL_DEVICE_TYPE_GPU :
cl::Context context(CL_DEVICE_TYPE_GPU, cprops, NULL, NULL, &err);
For example, from the 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()");
}
+2
user4018366
source
to share