29package com.jogamp.opencl;
31import static com.jogamp.common.util.VersionUtil.getPlatformInfo;
33import com.jogamp.common.GlueGenVersion;
34import com.jogamp.common.os.Platform;
35import com.jogamp.common.util.VersionUtil;
36import com.jogamp.common.util.JogampVersion;
38import java.io.PrintWriter;
39import java.io.StringWriter;
40import java.util.ArrayList;
44import java.util.jar.Manifest;
50 protected JoclVersion(
final String packageName,
final Manifest mf) {
51 super(packageName, mf);
58 final String packageName =
"com.jogamp.opencl";
59 final Manifest mf = VersionUtil.getManifest(
JoclVersion.class.getClassLoader(), packageName);
69 sb =
new StringBuilder();
74 sb.append(Platform.getNewline());
75 GlueGenVersion.getInstance().toString(sb);
76 sb.append(Platform.getNewline());
78 sb.append(Platform.getNewline());
79 }
catch (
final Exception e) {
80 sb.append(e.getMessage());
87 private volatile int maxKeyStrlen = -1;
91 sb =
new StringBuilder();
97 }
catch (
final Throwable t) {
98 final Throwable cause;
100 Throwable pre =
null;
102 while(
null != next ) {
104 next = next.getCause();
108 System.err.println(
"CLPlatform.listCLPlatforms() failed, exception: "+cause.getMessage());
110 sb.append(
"CLPlatform.listCLPlatforms() failed, exception: "+cause.getMessage());
111 final StringWriter stackTrace =
new StringWriter();
112 cause.printStackTrace(
new PrintWriter(stackTrace));
113 sb.append(stackTrace.toString());
118 final List<Map<String, String>> platProps =
new ArrayList<Map<String, String>>();
119 if( 0 > maxKeyStrlen ) {
121 if( 0 > maxKeyStrlen ) {
123 platProps.add(p.getProperties());
124 final CLDevice[] devices = p.listCLDevices();
127 final Set<
Map.Entry<String, String>> entries = props.entrySet();
128 for(
final Map.Entry<String, String> e : entries) {
129 maxKeyStrlen = Math.max(maxKeyStrlen, e.getKey().length());
136 sb.append(String.format(
"PP:DD:EE - Platform (PP), Device (DD), Entry (EE)%n"));
140 platProps.add(p.getProperties());
141 final CLDevice[] devices = p.listCLDevices();
146 final Set<
Map.Entry<String, String>> entries = props.entrySet();
148 for(
final Map.Entry<String, String> e : entries) {
150 sb.append(String.format(
"%02d:%02d:%02d %"+maxKeyStrlen+
"s: %s%n", pI, dI, eI, e.getKey(), e.getValue()));
159 sb =
new StringBuilder();
165 }
catch (
final Throwable t) {
166 final Throwable cause;
168 Throwable pre =
null;
170 while(
null != next ) {
172 next = next.getCause();
176 System.err.println(
"CLPlatform.listCLPlatforms() failed, exception: "+cause.getMessage());
178 sb.append(
"<pre>CLPlatform.listCLPlatforms() failed, exception: "+cause.getMessage());
179 final StringWriter stackTrace =
new StringWriter();
180 cause.printStackTrace(
new PrintWriter(stackTrace));
181 sb.append(stackTrace.toString()).append(
"</pre>");
184 sb.append(
"<table border=\"1\">");
187 final List<Map<String, String>> platProps =
new ArrayList<Map<String, String>>();
188 final List<Integer> spans =
new ArrayList<Integer>();
190 platProps.add(p.getProperties());
191 spans.add(p.listCLDevices().length);
193 fillHtmlTable(platProps, spans, sb);
196 final ArrayList<Map<String, String>> devProps =
new ArrayList<Map<String, String>>();
198 final CLDevice[] devices = p.listCLDevices();
200 devProps.add(d.getProperties());
203 fillHtmlTable(devProps, sb);
204 sb.append(
"</table>");
209 private static void fillHtmlTable(
final List<
Map<String, String>> properties,
final StringBuilder sb) {
210 final ArrayList<Integer> spans =
new ArrayList<Integer>(properties.size());
211 for (
int i = 0; i < properties.size(); i++) {
214 fillHtmlTable(properties, spans, sb);
217 private static void fillHtmlTable(
final List<Map<String, String>> properties,
final List<Integer> spans,
final StringBuilder sb) {
218 boolean header =
true;
219 for (
final String key : properties.get(0).keySet()) {
223 for (
final Map<String, String> map : properties) {
224 htmlCell(sb, spans.get(i), map.get(key), header);
232 private static void htmlCell(
final StringBuilder sb,
final String value) {
233 sb.append(
"<td>").append(value).append(
"</td>");
236 private static void htmlCell(
final StringBuilder sb,
final int span,
final String value,
final boolean header) {
238 sb.append(
"<th colspan=\"").append(span).append(
"\">").append(value).append(
"</th>");
240 sb.append(
"<td colspan=\"").append(span).append(
"\">").append(value).append(
"</td>");
244 public static void main(
final String args[]) {
245 System.err.println(VersionUtil.getPlatformInfo());
246 System.err.println(GlueGenVersion.getInstance());
249 System.err.println(v.toString());
254 System.err.println(
"JOCL/OpenCL not available");
This object represents an OpenCL device.
static void main(final String args[])
static volatile JoclVersion jogampCommonVersionInfo
JoclVersion(final String packageName, final Manifest mf)
StringBuilder getOpenCLTextInfo(StringBuilder sb)
StringBuilder getAllVersions(StringBuilder sb)
StringBuilder getOpenCLHtmlInfo(StringBuilder sb)
static JoclVersion getInstance()
Configures the mapping process.