summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLPlatform.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/mbien/opencl/CLPlatform.java')
-rw-r--r--src/com/mbien/opencl/CLPlatform.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/com/mbien/opencl/CLPlatform.java b/src/com/mbien/opencl/CLPlatform.java
index 56ef3713..f1ecdd86 100644
--- a/src/com/mbien/opencl/CLPlatform.java
+++ b/src/com/mbien/opencl/CLPlatform.java
@@ -82,6 +82,38 @@ public final class CLPlatform {
}
+ static final CLDevice findMaxFlopsDevice(CLDevice[] devices) {
+
+ CLDevice maxFLOPSDevice = null;
+
+ int maxflops = -1;
+
+ for (int i = 0; i < devices.length; i++) {
+
+ CLDevice device = devices[i];
+ int maxComputeUnits = device.getMaxComputeUnits();
+ int maxClockFrequency = device.getMaxClockFrequency();
+ int flops = maxComputeUnits*maxClockFrequency;
+
+ if(flops > maxflops) {
+ maxflops = flops;
+ maxFLOPSDevice = device;
+ }
+ }
+
+ return maxFLOPSDevice;
+ }
+
+
+ /**
+ * Gets the device with maximal FLOPS from this platform.
+ * The device speed is estimated by calulating the product of
+ * MAX_COMPUTE_UNITS and MAX_CLOCK_FREQUENCY.
+ */
+ public CLDevice getMaxFlopsDevice() {
+ return findMaxFlopsDevice(listCLDevices());
+ }
+
/**
* Returns the platform name.
*/