Open GoogleCodeExporter opened 9 years ago
Correct ;) The Wiki is indeed out of date.
Rather than having folks loop through all devices, I created API's for
selecting/comparing device capabilities.
For example you can create a device selector (uses the first device instance
returned as non null from select(device)).
OpenCLDevice firstAMD = OpenCLDevice.select(new OpenCLDevice.DeviceSelector() {
public OpenCLDevice select(OpenCLDevice d) {
return((d.getPlatform().getVendor().contains("AMD"))?d : null);
}
});
or of course if you are using Java 8 ;) DeviceSelector is a SAM type, so we can
use a lambda ;)
OpenCLDevice amdDevice = OpenCLDevice.select(
d->{return((d.getPlatform().getVendor().contains("AMD"))?d : null);});
We also have a device comparitor, where the comparitor returns the preferable
of two given devices.
So to select the device with the largest local memory we can use
OpenCLDevice maxLocalMemory = OpenCLDevice.select(
(lhs, rhs)->{return(lhs.getLocalMemSize()>rhs.getLocalMemSize()?lhs:rhs);});
Or
OpenCLDevice maxLocalMemory = OpenCLDevice.select(new
OpenCLDevice.DeviceComparitor(){
public OpenCLDevice select(OpenCLDevice lhs, OpenCLDevice rhs){
return(lhs.getLocalMemSize()>rhs.getLocalMemSize()?lhs:rhs);
}
});
I will update the Wiki.
Original comment by frost.g...@gmail.com
on 24 Apr 2013 at 3:40
Original comment by ecasp...@gmail.com
on 24 Apr 2013 at 4:00
Original issue reported on code.google.com by
ecasp...@gmail.com
on 24 Apr 2013 at 3:23