/** * Returns a list of extension names <br> * Extensions defined here must be supported by all devices associated with this platform. */ @InfoName("CL_PLATFORM_EXTENSIONS") public String[] getExtensions() { if (extensions == null) { extensions = new LinkedHashSet<String>(Arrays.asList(infos.getString(getEntity(), CL_PLATFORM_EXTENSIONS).split("\\s+"))); } return extensions.toArray(new String[extensions.size()]); } private Set<String> extensions;
/** * Returns a list of extension names <br> * Extensions defined here must be supported by all devices associated with this platform. */ @InfoName("CL_PLATFORM_EXTENSIONS") public String[] getExtensions() { if (extensions == null) { extensions = new LinkedHashSet<String>(Arrays.asList(infos.getString(getEntity(), CL_PLATFORM_EXTENSIONS).split("\\s+"))); } return extensions.toArray(new String[extensions.size()]); } private Set<String> extensions;
long[] getContextProps(Map<ContextProperties, Object> contextProperties) { int nContextProperties = contextProperties == null ? 0 : contextProperties.size(); final long[] properties = new long[(nContextProperties + 1) * 2 + 1]; properties[0] = CL_CONTEXT_PLATFORM; properties[1] = getEntity(); int iProp = 2; if (nContextProperties != 0) { for (Map.Entry<ContextProperties, Object> e : contextProperties.entrySet()) { //if (!(v instanceof Number)) throw new IllegalArgumentException("Invalid context property value for '" + e.getKey() + ": " + v); properties[iProp++] = e.getKey().value(); Object v = e.getValue(); if (v instanceof Number) properties[iProp++] = ((Number)v).longValue(); else if (v instanceof Pointer) properties[iProp++] = ((Pointer)v).getPeer(); else throw new IllegalArgumentException("Cannot convert value " + v + " to a context property value !"); } } //properties[iProp] = 0; return properties; }
/** * OpenCL profile string. Returns the profile name supported by the implementation. The profile name returned can be one of the following strings: * <ul> * <li>FULL_PROFILE if the implementation supports the OpenCL specification (functionality defined as part of the core specification and does not require any extensions to be supported).</li> * <li>EMBEDDED_PROFILE if the implementation supports the OpenCL embedded profile. The embedded profile is defined to be a subset for each version of OpenCL. The embedded profile for OpenCL 1.0 is described in section 10.</li> * </ul> */ @InfoName("CL_PLATFORM_PROFILE") public String getProfile() { return infos.getString(getEntity(), CL_PLATFORM_PROFILE); }
long[] getContextProps(Map<ContextProperties, Object> contextProperties) { int nContextProperties = contextProperties == null ? 0 : contextProperties.size(); final long[] properties = new long[(nContextProperties + 1) * 2 + 1]; properties[0] = CL_CONTEXT_PLATFORM; properties[1] = getEntity(); int iProp = 2; if (nContextProperties != 0) { for (Map.Entry<ContextProperties, Object> e : contextProperties.entrySet()) { //if (!(v instanceof Number)) throw new IllegalArgumentException("Invalid context property value for '" + e.getKey() + ": " + v); properties[iProp++] = e.getKey().value(); Object v = e.getValue(); if (v instanceof Number) properties[iProp++] = ((Number)v).longValue(); else if (v instanceof Pointer) properties[iProp++] = ((Pointer)v).getPeer(); else throw new IllegalArgumentException("Cannot convert value " + v + " to a context property value !"); } } //properties[iProp] = 0; return properties; }
/** * Platform name string. */ @InfoName("CL_PLATFORM_NAME") public String getName() { return infos.getString(getEntity(), CL_PLATFORM_NAME); }
/** * Platform name string. */ @InfoName("CL_PLATFORM_NAME") public String getName() { return infos.getString(getEntity(), CL_PLATFORM_NAME); }
/** OpenCL version string. Returns the OpenCL version supported by the implementation. This version string has the following format: OpenCL<space><major_version.min or_version><space><platform- specific information> Last Revision Date: 5/16/09 Page 30 The major_version.minor_version value returned will be 1.0. */ @InfoName("CL_PLATFORM_VERSION") public String getVersion() { return infos.getString(getEntity(), CL_PLATFORM_VERSION); }
/** * Platform vendor string. */ @InfoName("CL_PLATFORM_VENDOR") public String getVendor() { return infos.getString(getEntity(), CL_PLATFORM_VENDOR); }
/** * OpenCL profile string. Returns the profile name supported by the implementation. The profile name returned can be one of the following strings: * <ul> * <li>FULL_PROFILE if the implementation supports the OpenCL specification (functionality defined as part of the core specification and does not require any extensions to be supported).</li> * <li>EMBEDDED_PROFILE if the implementation supports the OpenCL embedded profile. The embedded profile is defined to be a subset for each version of OpenCL. The embedded profile for OpenCL 1.0 is described in section 10.</li> * </ul> */ @InfoName("CL_PLATFORM_PROFILE") public String getProfile() { return infos.getString(getEntity(), CL_PLATFORM_PROFILE); }
/** OpenCL version string. Returns the OpenCL version supported by the implementation. This version string has the following format: OpenCL<space><major_version.min or_version><space><platform- specific information> Last Revision Date: 5/16/09 Page 30 The major_version.minor_version value returned will be 1.0. */ @InfoName("CL_PLATFORM_VERSION") public String getVersion() { return infos.getString(getEntity(), CL_PLATFORM_VERSION); }
/** * Platform vendor string. */ @InfoName("CL_PLATFORM_VENDOR") public String getVendor() { return infos.getString(getEntity(), CL_PLATFORM_VENDOR); }
static Map<ContextProperties, Object> getGLContextProperties(CLPlatform platform) { Map<ContextProperties, Object> out = new LinkedHashMap<ContextProperties, Object>(); if (Platform.isMacOSX()) { Pointer<?> context = OpenGLContextUtils.CGLGetCurrentContext(); Pointer<?> shareGroup = OpenGLContextUtils.CGLGetShareGroup(context); out.put(ContextProperties.CGLShareGroupApple, shareGroup.getPeer()); } else if (Platform.isWindows()) { Pointer<?> context = OpenGLContextUtils.wglGetCurrentContext(); Pointer<?> dc = OpenGLContextUtils.wglGetCurrentDC(); out.put(ContextProperties.GLContext, context.getPeer()); out.put(ContextProperties.WGLHDC, dc.getPeer()); out.put(ContextProperties.Platform, platform.getEntity()); } else if (Platform.isUnix()) { Pointer<?> context = OpenGLContextUtils.glXGetCurrentContext(); Pointer<?> dc = OpenGLContextUtils.glXGetCurrentDisplay(); out.put(ContextProperties.GLContext, context.getPeer()); out.put(ContextProperties.GLXDisplay, dc.getPeer()); out.put(ContextProperties.Platform, platform.getEntity()); } else throw new UnsupportedOperationException("Current GL context retrieval not implemented on this platform !"); //out.put(ContextProperties.Platform, platform.getEntity().getPointer()); return out; } /**
static Map<ContextProperties, Object> getGLContextProperties(CLPlatform platform) { Map<ContextProperties, Object> out = new LinkedHashMap<ContextProperties, Object>(); if (Platform.isMacOSX()) { Pointer<?> context = OpenGLContextUtils.CGLGetCurrentContext(); Pointer<?> shareGroup = OpenGLContextUtils.CGLGetShareGroup(context); out.put(ContextProperties.CGLShareGroupApple, shareGroup.getPeer()); } else if (Platform.isWindows()) { Pointer<?> context = OpenGLContextUtils.wglGetCurrentContext(); Pointer<?> dc = OpenGLContextUtils.wglGetCurrentDC(); out.put(ContextProperties.GLContext, context.getPeer()); out.put(ContextProperties.WGLHDC, dc.getPeer()); out.put(ContextProperties.Platform, platform.getEntity()); } else if (Platform.isUnix()) { Pointer<?> context = OpenGLContextUtils.glXGetCurrentContext(); Pointer<?> dc = OpenGLContextUtils.glXGetCurrentDisplay(); out.put(ContextProperties.GLContext, context.getPeer()); out.put(ContextProperties.GLXDisplay, dc.getPeer()); out.put(ContextProperties.Platform, platform.getEntity()); } else throw new UnsupportedOperationException("Current GL context retrieval not implemented on this platform !"); //out.put(ContextProperties.Platform, platform.getEntity().getPointer()); return out; } /**
/** * Allows the implementation to release the resources allocated by the OpenCL compiler for this platform. */ public void unloadPlatformCompiler() { if (getVersionValue() < 1.2) { requireMinVersionValue("clUnloadCompiler", 1.1, 1.2); error(CL.clUnloadCompiler()); } else { requireMinVersionValue("clUnloadPlatformCompiler", 1.2); error(CL.clUnloadPlatformCompiler(getEntity())); } }
/** * Calls <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clGetDeviceIDs.html">clGetDeviceIDs</a>.<br> * List all the devices of the specified types, with only the ones declared as available if onlyAvailable is true. */ @SuppressWarnings("deprecation") public CLDevice[] listDevices(CLDevice.Type type, boolean onlyAvailable) { Pointer<Integer> pCount = allocateInt(); error(CL.clGetDeviceIDs(getEntity(), type.value(), 0, 0, getPeer(pCount))); int nDevs = pCount.getInt(); if (nDevs <= 0) { return new CLDevice[0]; } Pointer<SizeT> ids = allocateSizeTs(nDevs); error(CL.clGetDeviceIDs(getEntity(), type.value(), nDevs, getPeer(ids), 0)); return getDevices(ids, onlyAvailable); }
/** * Allows the implementation to release the resources allocated by the OpenCL compiler for this platform. */ public void unloadPlatformCompiler() { if (getVersionValue() < 1.2) { requireMinVersionValue("clUnloadCompiler", 1.1, 1.2); error(CL.clUnloadCompiler()); } else { requireMinVersionValue("clUnloadPlatformCompiler", 1.2); error(CL.clUnloadPlatformCompiler(getEntity())); } }
/** * Calls <a href="http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clGetDeviceIDs.html">clGetDeviceIDs</a>.<br> * List all the devices of the specified types, with only the ones declared as available if onlyAvailable is true. */ @SuppressWarnings("deprecation") public CLDevice[] listDevices(CLDevice.Type type, boolean onlyAvailable) { Pointer<Integer> pCount = allocateInt(); error(CL.clGetDeviceIDs(getEntity(), type.value(), 0, 0, getPeer(pCount))); int nDevs = pCount.getInt(); if (nDevs <= 0) { return new CLDevice[0]; } Pointer<SizeT> ids = allocateSizeTs(nDevs); error(CL.clGetDeviceIDs(getEntity(), type.value(), nDevs, getPeer(ids), 0)); return getDevices(ids, onlyAvailable); }