/** * 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); }
/** * 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); }
/** * 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)); }
/** * 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)); }
/** * 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); }
/** * 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); }
CLContext createContext() { if (ctx == null) ctx = createPlatform().createContext(null, createDevice()); return ctx; }
@InfoName("Out of order queues support") public boolean hasOutOfOrderQueueSupport() { CLContext context = getPlatform().createContext(null, this); CLQueue queue = null; try { queue = createOutOfOrderQueue(context); return true; } catch (CLException ex) { return false; } finally { if (queue != null) queue.release(); context.release(); } }
@InfoName("Out of order queues support") public boolean hasOutOfOrderQueueSupport() { CLContext context = getPlatform().createContext(null, this); CLQueue queue = null; try { queue = createOutOfOrderQueue(context); return true; } catch (CLException ex) { return false; } finally { if (queue != null) queue.release(); context.release(); } }
AbstractCommon(CLDevice device) { this.device = device; platform = device.getPlatform(); context = platform.createContext(null, device); queue = context.createDefaultQueue(); device = context.getDevices()[0]; formatsRead2D = context.getSupportedImageFormats(CLMem.Flags.ReadOnly, CLMem.ObjectType.Image2D); formatsWrite2D = context.getSupportedImageFormats(CLMem.Flags.WriteOnly, CLMem.ObjectType.Image2D); formatsRead3D = context.getSupportedImageFormats(CLMem.Flags.ReadOnly, CLMem.ObjectType.Image3D); formatsWrite3D = context.getSupportedImageFormats(CLMem.Flags.WriteOnly, CLMem.ObjectType.Image3D); formatsReadWrite2D = context.getSupportedImageFormats(CLMem.Flags.ReadWrite, CLMem.ObjectType.Image2D); formatsReadWrite3D = context.getSupportedImageFormats(CLMem.Flags.ReadWrite, CLMem.ObjectType.Image3D); }