I want to run some threads on my CPU ( the localhost
host ) and some other on a portable device connected ( like a USB ).
I know that OpenCL supports parallelization, but how do I distribute a work onto a portable devices using OpenCL?
Any other idea to do this other than OpenCL would also help.
Any device which might run an OpenCL task must have an Installable Client Driver associated with it, which can be picked up by the OpenCL Driver on the computer in question. Graphics Cards (especially if they're no older than half a decade) are nearly guaranteed to have a valid ICD, provided their drivers are up-to-date, and many Consumer-level CPUs have ICDs that are provided by their drivers.
However, other devices like a Network Device or a USB device are considerably less guaranteed to have a valid ICD unless they've been specifically designed for use in a Heterogeneous Compute system. If they do have a valid ICD, then it's a mere matter of querying for their platform at runtime and choosing it to use when constructing your OpenCL Context, then using it the same way you'd use OpenCL normally:
//C++ OpenCL API
cl::Platform target_platform;
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
for(cl::Platform & platform : platforms) {
std::string name = platform.getInfo<CL_PLATFORM_NAME>();
if(name == /*Whatever the Name of the platform is*/) {
target_platform = platform;
break;
}
}
std::vector<cl::Device> devices;
target_platform.getDevices(CL_DEVICE_TYPE_ALL, &devices);
cl::Device target_device;
for(cl::Device & device : devices) {
if(device.getInfo</*...*/>() == /*...*/) {//Whatever properties you need
target_device = device;
break;
}
}