/** * Creates an OpenCL context with the "best" device (see {@link JavaCL#getBestDevice() }) */ public static CLContext createBestContext() { return createBestContext(DeviceFeature.MaxComputeUnits); }
/** * 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()]); } /**
CLContext getContext() { Object selection = devicesCombo.getSelectedItem(); if (!(selection instanceof CLDevice)) return null; CLDevice device = (CLDevice)selection; CLContext context = JavaCL.createContext(null, device); return context; } void setProgress(final String caption) {
System.out.println("java.vm.name = " + System.getProperty("java.vm.name")); System.out.println("java.vm.version = " + System.getProperty("java.runtime.version")); System.out.println("Found platforms : " + Arrays.asList(JavaCL.listPlatforms())); CLPlatform platform = JavaCL.listPlatforms()[0]; String v = platform.getVendor(); System.out.println("Platform Vendor: " + v); int dataSize = isAMD ? 1024 : 1024 * 1024; CLContext context = JavaCL.createBestContext(); boolean hasDoubleSupport = context.isDoubleSupported();
private synchronized void initializeCLContextAndQueueOrNothing(int platformNumber, int deviceNumber) { //should check for index out of bounds later. need to figure out how I should throw the errors if(context==null || q == null) { CLDevice device = JavaCL.listPlatforms()[platformNumber].listAllDevices(false)[deviceNumber]; System.out.println("Device = " + device); context = (JavaCL.createContext(null, device)); q = (context.createDefaultQueue()); } } }
context = JavaCL.createContextFromCurrentGL(); CLDevice device = settings.getDevice(); if (device == null) device = JavaCL.getBestDevice(); context = JavaCL.createContext(null, device);
/** * Returns the "best" OpenCL device (currently, the one that has the largest amount of compute units).<br> * For more control on what is to be considered a better device, please use the {@link JavaCL#getBestDevice(CLPlatform.DeviceFeature[]) } variant.<br> * This is currently equivalent to <code>getBestDevice(MaxComputeUnits)</code> */ public static CLDevice getBestDevice() { return getBestDevice(CLPlatform.DeviceFeature.MaxComputeUnits); } /**
@Override public void init(GLAutoDrawable drawable) { try { CLContext context = JavaCL.createContextFromCurrentGL(); assertNotNull(context); if (context != null) {
/** * Returns the "best" OpenCL device (currently, the one that has the largest amount of compute units).<br> * For more control on what is to be considered a better device, please use the {@link JavaCL#getBestDevice(CLPlatform.DeviceFeature[]) } variant.<br> * This is currently equivalent to <code>getBestDevice(MaxComputeUnits)</code> */ public static CLDevice getBestDevice() { return getBestDevice(CLPlatform.DeviceFeature.MaxComputeUnits); } /**
public FloatFFTPow2() throws IOException { this(JavaCL.createBestContext()); }
/** * 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()]); } /**
Comparable extractValue(CLDevice device) { if (!device.hasImageSupport()) return 0; // TODO: fix that ugly hack ? CLContext context = JavaCL.createContext(null, device); try { return (Integer)context.getSupportedImageFormats(CLMem.Flags.ReadWrite, CLMem.ObjectType.Image2D).length; } finally { context.release(); } } };
private void selectBestDevice() { setDevice(JavaCL.getBestDevice()); }
/** * Creates an OpenCL context with the "best" device (see {@link JavaCL#getBestDevice() }) */ public static CLContext createBestContext() { return createBestContext(DeviceFeature.MaxComputeUnits); }
CLPlatform createPlatform() { return JavaCL.listPlatforms()[0]; }
Comparable extractValue(CLDevice device) { if (!device.hasImageSupport()) return 0; // TODO: fix that ugly hack ? CLContext context = JavaCL.createContext(null, device); try { return (Integer)context.getSupportedImageFormats(CLMem.Flags.ReadWrite, CLMem.ObjectType.Image2D).length; } finally { context.release(); } } };
/** * Creates an OpenCL context with the "best" device based on the comparison of the provided * prioritized device feature (see {@link JavaCL#getBestDevice(CLPlatform.DeviceFeature...) }) */ public static CLContext createBestContext(CLPlatform.DeviceFeature... preferredFeatures) { CLDevice device = getBestDevice(preferredFeatures); return device.getPlatform().createContext(null, device); }
public DoubleDFT() throws IOException { this(JavaCL.createBestContext(DeviceFeature.DoubleSupport)); }
/** * Returns the "best" OpenCL device based on the comparison of the provided prioritized device feature.<br> * The returned device does not necessarily exhibit the features listed in preferredFeatures, but it has the best ordered composition of them.<br> * For instance on a system with a GPU and a CPU device, <code>JavaCL.getBestDevice(CPU, MaxComputeUnits)</code> will return the CPU device, but on another system with two GPUs and no CPU device it will return the GPU that has the most compute units. */ public static CLDevice getBestDevice(CLPlatform.DeviceFeature... preferredFeatures) { List<CLDevice> devices = new ArrayList<CLDevice>(); for (CLPlatform platform : listPlatforms()) devices.addAll(Arrays.asList(platform.listAllDevices(true))); return CLPlatform.getBestDevice(Arrays.asList(preferredFeatures), devices); } /**
public static ByteOrder checkByteOrderNeededForBuffers(CLDevice device) { CLContext context = JavaCL.createContext((Map)null, device); CLQueue queue = context.createDefaultQueue(); try {