aboutsummaryrefslogtreecommitdiffstats
path: root/test/com/mbien/opencl
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-10-12 19:05:13 +0200
committerMichael Bien <[email protected]>2009-10-12 19:05:13 +0200
commit223e32b5ce6943abf7c1ac31f1b90d3679de5571 (patch)
tree435b04350e9be30a19077b94dce660000b975d74 /test/com/mbien/opencl
parent2b05a67d30bde1419c2b0f1b5b427d65b8415eb7 (diff)
cleaned up test output, removed some internal hardcoded fields from CLDevice.
Diffstat (limited to 'test/com/mbien/opencl')
-rw-r--r--test/com/mbien/opencl/JOCLTest.java130
1 files changed, 64 insertions, 66 deletions
diff --git a/test/com/mbien/opencl/JOCLTest.java b/test/com/mbien/opencl/JOCLTest.java
index 89292320..0eccf430 100644
--- a/test/com/mbien/opencl/JOCLTest.java
+++ b/test/com/mbien/opencl/JOCLTest.java
@@ -1,16 +1,15 @@
package com.mbien.opencl;
-import com.mbien.opencl.impl.CLImpl;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
+import static java.lang.System.*;
/**
- *
+ * Test for testing basic functionality.
* @author Michael Bien
*/
public class JOCLTest {
@@ -18,60 +17,16 @@ public class JOCLTest {
public JOCLTest() {
}
- @Before
- public void setUpClass() throws Exception {
- }
-
- @After
- public void tearDownClass() throws Exception {
- }
-
-// @Test
- public void highLevelTest() {
- System.out.println(" - - - highLevelTest - - - ");
-
- CLPlatform[] clPlatforms = CLContext.listCLPlatforms();
-
- for (CLPlatform platform : clPlatforms) {
-
- System.out.println("platform info:");
- System.out.println("name: "+platform.getName());
- System.out.println("profile: "+platform.getProfile());
- System.out.println("version: "+platform.getVersion());
- System.out.println("vendor: "+platform.getVendor());
-
- CLDevice[] clDevices = platform.listCLDevices();
- for (CLDevice device : clDevices) {
- System.out.println("device info:");
- System.out.println("name: "+device.getName());
- System.out.println("profile: "+device.getProfile());
- System.out.println("vendor: "+device.getVendor());
- System.out.println("type: "+device.getType());
- System.out.println("global mem: "+device.getGlobalMemSize()/(1024*1024)+" MB");
- System.out.println("local mem: "+device.getLocalMemSize()/1024+" KB");
- System.out.println("clock: "+device.getMaxClockFrequency()+" MHz");
- System.out.println("max work group size: "+device.getMaxWorkGroupSize());
- System.out.println("max compute units: "+device.getMaxComputeUnits());
- System.out.println("extensions: "+device.getExtensions());
- }
- }
-
-
- CLContext ctx = CLContext.create();
- CLDevice device = ctx.getMaxFlopsDevice();
- System.out.println("max FLOPS device: " + device);
- ctx.release();
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ out.println("OS: " + System.getProperty("os.name"));
+ out.println("VM: " + System.getProperty("java.vm.name"));
}
@Test
public void lowLevelTest() {
- System.out.println(" - - - lowLevelTest - - - ");
- // already loaded
- System.out.print("loading native libs...");
- System.loadLibrary("gluegen-rt");
- System.loadLibrary("jocl");
- System.out.println("done");
+ out.println(" - - - lowLevelTest - - - ");
CreateContextCallback cb = new CreateContextCallback() {
@Override
@@ -80,17 +35,17 @@ public class JOCLTest {
}
};
- System.out.println("creating OpenCL context");
+ out.println("creating OpenCL context");
int ret = 0;
- CL cl = new CLImpl();
+ CL cl = CLContext.getLowLevelBinding();
int[] intBuffer = new int[1];
// find all available OpenCL platforms
ret = cl.clGetPlatformIDs(0, null, 0, intBuffer, 0);
assertEquals(CL.CL_SUCCESS, ret);
- System.out.println("#platforms: "+intBuffer[0]);
+ out.println("#platforms: "+intBuffer[0]);
long[] platformId = new long[intBuffer[0]];
ret = cl.clGetPlatformIDs(platformId.length, platformId, 0, null, 0);
@@ -104,28 +59,28 @@ public class JOCLTest {
for (int i = 0; i < platformId.length; i++) {
long platform = platformId[i];
- System.out.println("platform id: "+platform);
+ out.println("platform id: "+platform);
ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_PROFILE, bb.capacity(), bb, longBuffer, 0);
assertEquals(CL.CL_SUCCESS, ret);
- System.out.println(" profile: "+new String(bb.array(), 0, (int)longBuffer[0]));
+ out.println(" profile: "+new String(bb.array(), 0, (int)longBuffer[0]));
ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_VERSION, bb.capacity(), bb, longBuffer, 0);
assertEquals(CL.CL_SUCCESS, ret);
- System.out.println(" version: "+new String(bb.array(), 0, (int)longBuffer[0]));
+ out.println(" version: "+new String(bb.array(), 0, (int)longBuffer[0]));
ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_NAME, bb.capacity(), bb, longBuffer, 0);
assertEquals(CL.CL_SUCCESS, ret);
- System.out.println(" name: "+new String(bb.array(), 0, (int)longBuffer[0]));
+ out.println(" name: "+new String(bb.array(), 0, (int)longBuffer[0]));
ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_VENDOR, bb.capacity(), bb, longBuffer, 0);
assertEquals(CL.CL_SUCCESS, ret);
- System.out.println(" vendor: "+new String(bb.array(), 0, (int)longBuffer[0]));
+ out.println(" vendor: "+new String(bb.array(), 0, (int)longBuffer[0]));
//find all devices
ret = cl.clGetDeviceIDs(platform, CL.CL_DEVICE_TYPE_ALL, 0, null, 0, intBuffer, 0);
assertEquals(CL.CL_SUCCESS, ret);
- System.out.println("#devices: "+intBuffer[0]);
+ out.println("#devices: "+intBuffer[0]);
long[] devices = new long[intBuffer[0]];
ret = cl.clGetDeviceIDs(platform, CL.CL_DEVICE_TYPE_ALL, devices.length, devices, 0, null, 0);
@@ -135,11 +90,11 @@ public class JOCLTest {
long device = devices[j];
ret = cl.clGetDeviceInfo(device, CL.CL_DEVICE_NAME, bb.capacity(), bb, longBuffer, 0);
assertEquals(CL.CL_SUCCESS, ret);
- System.out.println(" device: "+new String(bb.array(), 0, (int)longBuffer[0]));
+ out.println(" device: "+new String(bb.array(), 0, (int)longBuffer[0]));
ret = cl.clGetDeviceInfo(device, CL.CL_DEVICE_TYPE, bb.capacity(), bb, longBuffer, 0);
assertEquals(CL.CL_SUCCESS, ret);
- System.out.println(" type: " + CLDevice.Type.valueOf(bb.get()));
+ out.println(" type: " + CLDevice.Type.valueOf(bb.get()));
bb.rewind();
}
@@ -149,15 +104,58 @@ public class JOCLTest {
Arrays.fill(longBuffer, 0);
long context = cl.clCreateContextFromType(null, 0, CL.CL_DEVICE_TYPE_ALL, cb, null, null, 0);
- System.out.println("context handle: "+context);
+ out.println("context handle: "+context);
ret = cl.clGetContextInfo(context, CL.CL_CONTEXT_DEVICES, 0, null, longBuffer, 0);
assertEquals(CL.CL_SUCCESS, ret);
- System.out.println("CL_CONTEXT_DEVICES result: "+longBuffer[0]);
+ out.println("CL_CONTEXT_DEVICES result: "+longBuffer[0]);
+
+ ret = cl.clGetContextInfo(context, CL.CL_CONTEXT_NUM_DEVICES, 0, null, longBuffer, 0);
+ assertEquals(CL.CL_SUCCESS, ret);
+
+ out.println("CL_CONTEXT_NUM_DEVICES result: "+longBuffer[0]);
cl.clReleaseContext(context);
}
+ @Test
+ public void highLevelTest() {
+
+ out.println(" - - - highLevelTest - - - ");
+
+ CLPlatform[] clPlatforms = CLContext.listCLPlatforms();
+
+ for (CLPlatform platform : clPlatforms) {
+
+ out.println("platform info:");
+ out.println(" name: "+platform.getName());
+ out.println(" profile: "+platform.getProfile());
+ out.println(" version: "+platform.getVersion());
+ out.println(" vendor: "+platform.getVendor());
+
+ CLDevice[] clDevices = platform.listCLDevices();
+ for (CLDevice device : clDevices) {
+ out.println("device info:");
+ out.println(" name: "+device.getName());
+ out.println(" profile: "+device.getProfile());
+ out.println(" vendor: "+device.getVendor());
+ out.println(" type: "+device.getType());
+ out.println(" global mem: "+device.getGlobalMemSize()/(1024*1024)+" MB");
+ out.println(" local mem: "+device.getLocalMemSize()/1024+" KB");
+ out.println(" clock: "+device.getMaxClockFrequency()+" MHz");
+ out.println(" max work group size: "+device.getMaxWorkGroupSize());
+ out.println(" max compute units: "+device.getMaxComputeUnits());
+ out.println(" extensions: "+device.getExtensions());
+ }
+ }
+
+
+ CLContext ctx = CLContext.create();
+// CLDevice device = ctx.getMaxFlopsDevice();
+// out.println("max FLOPS device: " + device);
+ ctx.release();
+ }
+
} \ No newline at end of file