summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--resources/CL/stdint.h6
-rw-r--r--resources/clImplCustomCode.java4
-rw-r--r--test/com/mbien/opencl/JOCLTest.java75
3 files changed, 71 insertions, 14 deletions
diff --git a/resources/CL/stdint.h b/resources/CL/stdint.h
index a9dd63a4..8fd0d29f 100644
--- a/resources/CL/stdint.h
+++ b/resources/CL/stdint.h
@@ -15,10 +15,10 @@
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
- typedef int intptr_t;
- typedef unsigned int uintptr_t;
+ typedef long intptr_t;
+ typedef unsigned long uintptr_t;
- typedef unsigned int size_t;
+ typedef unsigned long size_t;
// FIXME workaround prevent re-defininition of int16_t in types.h
# define __int8_t_defined
diff --git a/resources/clImplCustomCode.java b/resources/clImplCustomCode.java
index 4b1d50c3..2fa48d64 100644
--- a/resources/clImplCustomCode.java
+++ b/resources/clImplCustomCode.java
@@ -2,13 +2,13 @@
public long clCreateContext(IntBuffer properties, int arg1, long[] devices, CreateContextCallback cb, Object userData, IntBuffer errcode_ret) {
return this.clCreateContext0(properties, arg1, devices, cb, null, errcode_ret, 0);
}
- public native long clCreateContext0(IntBuffer properties, int size, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int size2);
+ private native long clCreateContext0(IntBuffer properties, int size, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int size2);
public long clCreateContextFromType(IntBuffer arg0, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret) {
return this.clCreateContextFromType0(arg0, 0, device_type, pfn_notify, null, errcode_ret, 0);
}
- public native long clCreateContextFromType0(IntBuffer arg0, int size, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int size2);
+ private native long clCreateContextFromType0(IntBuffer arg0, int size, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int size2);
\ No newline at end of file
diff --git a/test/com/mbien/opencl/JOCLTest.java b/test/com/mbien/opencl/JOCLTest.java
index 053f22d3..d0b19204 100644
--- a/test/com/mbien/opencl/JOCLTest.java
+++ b/test/com/mbien/opencl/JOCLTest.java
@@ -1,7 +1,10 @@
package com.mbien.opencl;
import com.mbien.opencl.impl.CLImpl;
+import java.nio.Buffer;
import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.util.Arrays;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -25,10 +28,7 @@ public class JOCLTest {
}
@Test
- public void basicTest() {
-// System.out.println(0xFFFFFFFF);
-// System.out.println(0xFFFFFFFE);
-// System.out.println(0xFFFFFFFD);
+ public void basicLowLevelTest() {
System.out.print("loading native libs...");
System.loadLibrary("gluegen-rt");
@@ -44,14 +44,71 @@ public class JOCLTest {
System.out.println("creating OpenCL context");
- CLImpl impl = new CLImpl();
+ int ret = 0;
- long context = impl.clCreateContextFromType(null, CL.CL_DEVICE_TYPE_ALL, cb, null, null);
+ CL cl = new CLImpl();
+
+ int[] intBuffer = new int[1];
+ ret = cl.clGetPlatformIDs(0, null, 0, intBuffer, 0);
+ assertEquals(CL.CL_SUCCESS, ret);
+ System.out.println("#platforms: "+intBuffer[0]);
+
+ long[] platformId = new long[intBuffer[0]];
+ ret = cl.clGetPlatformIDs(platformId.length, platformId, 0, null, 0);
+ assertEquals(CL.CL_SUCCESS, ret);
+
+ long[] longBuffer = new long[1];
+
+ ByteBuffer bb = ByteBuffer.allocate(128);
+ byte[] str = new byte[128];
+
+ for (int i = 0; i < platformId.length; i++) {
+
+ long platform = platformId[i];
+ System.out.println("platform id: "+platform);
+
+ ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_PROFILE, bb.capacity(), bb, null, 0);
+ assertEquals(CL.CL_SUCCESS, ret);
+ bb.get(str);
+
+ System.out.println(" profile: "+new String(str));
+ Arrays.fill(str, (byte)0);
+ bb.rewind();
+
+ ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_VERSION, bb.capacity(), bb, null, 0);
+ assertEquals(CL.CL_SUCCESS, ret);
+ bb.get(str);
+ System.out.println(" version: "+new String(str));
+ Arrays.fill(str, (byte)0);
+ bb.rewind();
+
+ ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_NAME, bb.capacity(), bb, null, 0);
+ assertEquals(CL.CL_SUCCESS, ret);
+ bb.get(str);
+ System.out.println(" name: "+new String(str));
+ Arrays.fill(str, (byte)0);
+ bb.rewind();
+
+ ret = cl.clGetPlatformInfo(platform, CL.CL_PLATFORM_VENDOR, bb.capacity(), bb, null, 0);
+ assertEquals(CL.CL_SUCCESS, ret);
+ bb.get(str);
+ System.out.println(" vendor: "+new String(str));
+ Arrays.fill(str, (byte)0);
+ bb.rewind();
+
+ }
+
+ Arrays.fill(longBuffer, 0);
+
+
+ long context = cl.clCreateContextFromType(null, CL.CL_DEVICE_TYPE_ALL, cb, null, null);
System.out.println("context handle: "+context);
- int[] buffer = new int[1];
- impl.clGetContextInfo(context, CL.CL_CONTEXT_NUM_DEVICES, 0, null, buffer, 0);
- System.out.println("CL_CONTEXT_NUM_DEVICES result: "+buffer[0]);
+ 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]);
+// System.out.println("CL_CONTEXT_DEVICES result: "+buffer[1]);
}