public CLDevice getBestDevice() { return getBestDevice(Arrays.asList(DeviceFeature.MaxComputeUnits), Arrays.asList(listAllDevices(true))); }
@Override public String toString() { return toString(new StringBuilder()).toString(); } StringBuilder toString(StringBuilder out) {
/** * Creates an OpenCL context formed of the provided devices.<br> * It is generally not a good idea to create a context with more than one device, * because much data is shared between all the devices in the same context. * @param devices devices that are to form the new context * @return new OpenCL context */ public static CLContext createContext(Map<CLPlatform.ContextProperties, Object> contextProperties, CLDevice... devices) { return devices[0].getPlatform().createContext(contextProperties, devices); }
public CLContext createContextFromCurrentGL() { return createGLCompatibleContext(listAllDevices(true)); }
StringBuilder toString(StringBuilder out) { out. append(getName()). append(" {vendor: ").append(getVendor()). append(", version: ").append(getVersion()). append(", profile: ").append(getProfile()). append(", extensions: ").append(Arrays.toString(getExtensions())). append("}"); return out; }
for (CLDevice device : platform.listAllDevices(false)) { Map<String, Object> devInfos = new TreeMap<String, Object>(platInfos); for (Map.Entry<String, Method> devMet : devMets.entrySet()) {
public static CLDevice[] getDevices(Target target) { CLPlatform platform = listPlatforms()[0]; switch (target) { case CPU: return platform.listCPUDevices(true); case GPU: return platform.listGPUDevices(true); case CPU_GPU: return platform.listAllDevices(true); default: throw new IllegalArgumentException("Unknown target : " + target); } } public static class ExecResult<B> {
public List<CLPlatform> getPlatforms() { CLPlatform[] platforms = JavaCL.listPlatforms(); boolean hasSharing = false; plat: for (CLPlatform platform : platforms) if (platform.isGLSharingSupported()) for (CLDevice device : platform.listAllDevices(false)) if (device.isGLSharingSupported()) { hasSharing = true; break plat; } configFromGLCheck.setEnabled(hasSharing); if (!hasSharing) { configFromGLCheck.setText(configFromGLCheck.getText() + " (unavailable option)"); configFromGLCheck.setToolTipText("Did not find any OpenCL platform with OpenGL sharing support."); } return Arrays.asList(platforms); }
public static PlatformKind guessPlatformKind(CLPlatform p) { String name = p.getName(); if (name != null) { if (name.equals("Apple")) return PlatformKind.Apple; else if (name.equals("ATI Stream") || name.equals("AMD Accelerated Parallel Processing")) return PlatformKind.AMDApp; else { String vendor = p.getVendor().toLowerCase(); if (vendor.contains("nvidia")) return PlatformKind.NVIDIA; } } return null; } }
public String toString() { StringBuilder b = new StringBuilder("CLContext(platform = ").append(getPlatform().getName()).append("; devices = "); boolean first = true; for (CLDevice d : getDevices()) { if (first) first = false; else b.append(", "); b.append(d.getName()); } b.append(")"); return b.toString(); } public CLQueue createDefaultOutOfOrderQueueIfPossible() {
/** * Calls <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clCreateContext.html">clCreateContext</a>.<br> */ @Deprecated public CLContext createGLCompatibleContext(CLDevice... devices) { for (CLDevice device : devices) { if (!device.isGLSharingSupported()) continue; try { return createContext(getGLContextProperties(this), device); } catch (Throwable th) {} } throw new UnsupportedOperationException("Failed to create an OpenGL-sharing-enabled OpenCL context out of devices " + Arrays.asList(devices)); }
/** * List the OpenCL implementations that contain at least one GPU device. */ public static CLPlatform[] listGPUPoweredPlatforms() { CLPlatform[] platforms = listPlatforms(); List<CLPlatform> out = new ArrayList<CLPlatform>(platforms.length); for (CLPlatform platform : platforms) { if (platform.listGPUDevices(true).length > 0) out.add(platform); } return out.toArray(new CLPlatform[out.size()]); } /**
System.out.println("Found platforms : " + Arrays.asList(JavaCL.listPlatforms())); CLPlatform platform = JavaCL.listPlatforms()[0]; String v = platform.getVendor(); System.out.println("Platform Vendor: " + v); boolean isAMD = v.equals("Advanced Micro Devices, Inc.");
for (CLDevice device : platform.listAllDevices(false)) { Map<String, Object> devInfos = new TreeMap<String, Object>(platInfos); for (Map.Entry<String, Method> devMet : devMets.entrySet()) {
StringBuilder toString(StringBuilder out) { out. append(getName()). append(" {vendor: ").append(getVendor()). append(", version: ").append(getVersion()). append(", profile: ").append(getProfile()). append(", extensions: ").append(Arrays.toString(getExtensions())). append("}"); return out; }
public CLContext createContextFromCurrentGL() { return createGLCompatibleContext(listAllDevices(true)); }
public static PlatformKind guessPlatformKind(CLPlatform p) { String name = p.getName(); if (name != null) { if (name.equals("Apple")) return PlatformKind.Apple; else if (name.equals("ATI Stream") || name.equals("AMD Accelerated Parallel Processing")) return PlatformKind.AMDApp; else { String vendor = p.getVendor().toLowerCase(); if (vendor.contains("nvidia")) return PlatformKind.NVIDIA; } } return null; } }
public String toString() { StringBuilder b = new StringBuilder("CLContext(platform = ").append(getPlatform().getName()).append("; devices = "); boolean first = true; for (CLDevice d : getDevices()) { if (first) first = false; else b.append(", "); b.append(d.getName()); } b.append(")"); return b.toString(); } public CLQueue createDefaultOutOfOrderQueueIfPossible() {
/** * Calls <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clCreateContext.html">clCreateContext</a>.<br> */ @Deprecated public CLContext createGLCompatibleContext(CLDevice... devices) { for (CLDevice device : devices) { if (!device.isGLSharingSupported()) continue; try { return createContext(getGLContextProperties(this), device); } catch (Throwable th) {} } throw new UnsupportedOperationException("Failed to create an OpenGL-sharing-enabled OpenCL context out of devices " + Arrays.asList(devices)); }
/** * List the OpenCL implementations that contain at least one GPU device. */ public static CLPlatform[] listGPUPoweredPlatforms() { CLPlatform[] platforms = listPlatforms(); List<CLPlatform> out = new ArrayList<CLPlatform>(platforms.length); for (CLPlatform platform : platforms) { if (platform.listGPUDevices(true).length > 0) out.add(platform); } return out.toArray(new CLPlatform[out.size()]); } /**