JOCL v2.6.0-rc-20250722
JOCL, OpenCL® API Binding for Java™ (public API).
CLInfo.java
Go to the documentation of this file.
1/*
2 * Copyright 2009 - 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29/*
30 * Created on Tuesday, September 07 2010 15:35
31 */
32package com.jogamp.opencl.util;
33
34import com.jogamp.common.os.Platform;
35import com.jogamp.opencl.CLDevice;
36import com.jogamp.opencl.CLPlatform;
37import com.jogamp.opencl.llb.impl.CLImpl11;
38import java.util.Map;
39
40
41/**
42 * Prints out diagnostic properties about the OpenCL installation and the runtime environment of the host application.
43 * @author Michael Bien
44 */
45public class CLInfo {
46
47 public static StringBuilder print(final StringBuilder sb) {
48
49 // host
50 sb.append("HOST_JRE: ").append(System.getProperty("java.runtime.version")).append("\n");
51 sb.append("HOST_JVM: ").append(System.getProperty("java.vm.name")).append("\n");
52 sb.append("HOST_ARCH: ").append(Platform.getArchName()).append("\n");
53 sb.append("HOST_NUM_CORES: ").append(Runtime.getRuntime().availableProcessors()).append("\n");
54 sb.append("HOST_OS: ").append(Platform.getOSName()).append("\n");
55 sb.append("HOST_LITTLE_ENDIAN: ").append(Platform.isLittleEndian()).append("\n");
56
58
59 // binding
60 sb.append("CL_BINDING_UNAVAILABLE_FUNCTIONS: ");
61 sb.append(CLImpl11.getAddressTable().getNullPointerFunctions());
62 sb.append("\n");
63
64 // OpenCL
65 final CLPlatform[] platforms = CLPlatform.listCLPlatforms();
66
67 for (final CLPlatform platform : platforms) {
68 final Map<String, String> platformProperties = platform.getProperties();
69 sb.append("\n");
70 printInfo(sb, "", platformProperties);
71
72 final CLDevice[] devices = platform.listCLDevices();
73 for (final CLDevice device : devices) {
74 final Map<String, String> deviceProperties = device.getProperties();
75 sb.append("\n");
76 printInfo(sb, " - ", deviceProperties);
77 }
78 }
79
80 return sb;
81 }
82
83
84 private static void printInfo(final StringBuilder sb, final String prefix, final Map<String, String> properties) {
85 for (final Map.Entry<String, String> entry : properties.entrySet()) {
86 sb.append(prefix).append(entry.getKey()).append(": ").append(entry.getValue()).append(Platform.getNewline());
87 }
88 }
89
90 public static void main(final String[] args) throws Exception {
91 System.out.println(print(new StringBuilder()).toString());
92 }
93}
This object represents an OpenCL device.
Definition: CLDevice.java:53
Map< String, String > getProperties()
Returns a Map of device properties with the enum names as keys.
Definition: CLDevice.java:708
CLPlatfrorm representing a OpenCL implementation (e.g.
Definition: CLPlatform.java:99
static void initialize()
Eagerly initializes JOCL.
static CLPlatform[] listCLPlatforms()
Lists all available OpenCL implementations.
Map< String, String > getProperties()
Returns a Map of platform properties with the enum names as keys.
Java bindings to OpenCL, the Open Computing Language (generated).
Definition: CLImpl11.java:32
static CLProcAddressTable11 getAddressTable()
Definition: CLImpl11.java:1800
Prints out diagnostic properties about the OpenCL installation and the runtime environment of the hos...
Definition: CLInfo.java:45
static StringBuilder print(final StringBuilder sb)
Definition: CLInfo.java:47
static void main(final String[] args)
Definition: CLInfo.java:90