summaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-10-23 00:21:58 +0200
committerMichael Bien <[email protected]>2009-10-23 00:21:58 +0200
commit054e5005d1429ba6ea4f9283eee2988ff54d1abb (patch)
tree163f7124f6dba109de965f3382f8b2613cf2068c /resources
parent503845224a820c0b9ce9204aa6215519f6b93c36 (diff)
utility methods and refactoring.
Diffstat (limited to 'resources')
-rw-r--r--resources/cl-if.cfg6
-rw-r--r--resources/cl-impl.cfg2
-rw-r--r--resources/clImplCustomCode.c34
-rw-r--r--resources/clImplCustomCode.java18
4 files changed, 24 insertions, 36 deletions
diff --git a/resources/cl-if.cfg b/resources/cl-if.cfg
index 4d7d80f1..8a4d62d8 100644
--- a/resources/cl-if.cfg
+++ b/resources/cl-if.cfg
@@ -7,7 +7,7 @@ Import java.nio.IntBuffer
ClassJavadoc CL /**
ClassJavadoc CL * Java bindings to OpenCL, the Open Computing Language.
-ClassJavadoc CL * @autor Michael Bien
+ClassJavadoc CL * @author Michael Bien
ClassJavadoc CL */
JavaClass CL
@@ -18,12 +18,12 @@ Ignore CL_GL_.*|cl.*GL.*
Ignore clCreateContext
CustomJavaCode CL
CustomJavaCode CL /** Interface to C language function: <br> <code> cl_context clCreateContext(intptr_t * , uint32_t, cl_device_id * , void (*pfn_notify)(const char *, const void *, size_t, void *), void *, int32_t * ); </code> */
-CustomJavaCode CL public long clCreateContext(IntBuffer properties, int properties_offset, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int errcode_offset);
+CustomJavaCode CL public long clCreateContext(IntBuffer properties, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret);
Ignore clCreateContextFromType
CustomJavaCode CL
CustomJavaCode CL /** Interface to C language function: <br> <code> cl_context clCreateContextFromType(cl_context_properties *properties, cl_device_type device_type, void (*pfn_notify)(const char *errinfo, const void *private_info, size_t cb, void *user_data), void *user_data, cl_int *errcode_ret) ; </code> */
-CustomJavaCode CL public long clCreateContextFromType(IntBuffer properties, int properties_offset, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int errcode_offset);
+CustomJavaCode CL public long clCreateContextFromType(IntBuffer properties, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret);
Ignore clBuildProgram
CustomJavaCode CL
diff --git a/resources/cl-impl.cfg b/resources/cl-impl.cfg
index 58d06be2..cee848c8 100644
--- a/resources/cl-impl.cfg
+++ b/resources/cl-impl.cfg
@@ -9,7 +9,7 @@ Import java.nio.Buffer
ClassJavadoc CLImpl /**
ClassJavadoc CLImpl * Java bindings to OpenCL, the Open Computing Language.
-ClassJavadoc CLImpl * @autor Michael Bien
+ClassJavadoc CLImpl * @author Michael Bien
ClassJavadoc CLImpl */
ImplJavaClass CLImpl
diff --git a/resources/clImplCustomCode.c b/resources/clImplCustomCode.c
index 41e9f159..a35328dc 100644
--- a/resources/clImplCustomCode.c
+++ b/resources/clImplCustomCode.c
@@ -24,9 +24,8 @@ void createContextCallback(const char * c, const void * v, size_t s, void * o) {
* void * user_data ,
* cl_int * errcode_ret );
*/
-//__Ljava_lang_Object_2IJLjava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2I
JNIEXPORT jlong JNICALL
-Java_com_mbien_opencl_impl_CLImpl_clCreateContextFromType0(JNIEnv *env, jobject _unused,
+Java_com_mbien_opencl_impl_CLImpl_clCreateContextFromType1(JNIEnv *env, jobject _unused,
jobject props, jint props_byte_offset, jlong device_type, jobject cb, jobject data, jobject errcode, jint errcode_byte_offset) {
intptr_t * _props_ptr = NULL;
@@ -34,26 +33,21 @@ Java_com_mbien_opencl_impl_CLImpl_clCreateContextFromType0(JNIEnv *env, jobject
cl_context _ctx;
if (props != NULL) {
- _props_ptr = (intptr_t *) (((char*) (*env)->GetDirectBufferAddress(env, props)) + props_byte_offset);
+ _props_ptr = (void *) (((char*) (*env)->GetPrimitiveArrayCritical(env, props, NULL)) + props_byte_offset);
}
if (errcode != NULL) {
- _errcode_ptr = (int32_t *) (((char*) (*env)->GetDirectBufferAddress(env, errcode)) + errcode_byte_offset);
+ _errcode_ptr = (void *) (((char*) (*env)->GetPrimitiveArrayCritical(env, errcode, NULL)) + errcode_byte_offset);
}
//TODO callback; payload
- _ctx = clCreateContextFromType((intptr_t *) _props_ptr, (uint64_t) device_type, NULL, NULL, (int32_t *) _errcode_ptr);
+ _ctx = clCreateContextFromType((cl_context_properties *) _props_ptr, (uint64_t) device_type, NULL, NULL, (int32_t *) _errcode_ptr);
-/*
- printf(" - - - - test - - - - \n");
- cl_uint err;
- size_t deviceListSize;
-
- // get the list of GPU devices associated with context
- err = clGetContextInfo(_ctx, CL_CONTEXT_DEVICES, 0, NULL, &deviceListSize); checkStatus("getContextInfo1", err);
- cl_uint count = (cl_uint)deviceListSize / sizeof(cl_device_id);
- printf("devices: %d \n", count);
- printf(" - - - - test end - - - - \n");
-*/
+ if (errcode != NULL) {
+ (*env)->ReleasePrimitiveArrayCritical(env, errcode, _errcode_ptr, 0);
+ }
+ if (props != NULL) {
+ (*env)->ReleasePrimitiveArrayCritical(env, props, _props_ptr, 0);
+ }
return (jlong)_ctx;
}
@@ -111,14 +105,6 @@ Java_com_mbien_opencl_impl_CLImpl_clBuildProgram0(JNIEnv *env, jobject _unused,
_deviceListPtr = (void *) (((char*) (*env)->GetPrimitiveArrayCritical(env, deviceList, NULL)) + offset);
}
-/*
- printf("---------------------------------------------------------------------------\n");
- printf("deviceList: %d\n", _deviceListPtr);
- printf("_strchars_options: %d\n", _strchars_options);
- printf("deviceCount: %d\n", deviceCount);
- printf("---------------------------------------------------------------------------\n");
-*/
-
// TODO payload, callback...
_res = clBuildProgram((cl_program)program, (cl_uint)deviceCount, _deviceListPtr, _strchars_options, NULL, NULL);
diff --git a/resources/clImplCustomCode.java b/resources/clImplCustomCode.java
index 3c5e1f07..0d25ddb6 100644
--- a/resources/clImplCustomCode.java
+++ b/resources/clImplCustomCode.java
@@ -1,23 +1,25 @@
- public long clCreateContext(IntBuffer properties, int offset1, long[] devices, CreateContextCallback cb, Object userData, IntBuffer errcode_ret, int offset2) {
+ public long clCreateContext(IntBuffer properties, long[] devices, CreateContextCallback cb, Object userData, IntBuffer errcode_ret) {
throw new RuntimeException("not yet implemented, use clCreateContextFromType instead");
// return this.clCreateContext0(properties, offset1, devices, cb, null, errcode_ret, offset2);
}
- private native long clCreateContext0(IntBuffer cl_context_properties, int size, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int size2);
+ private native long clCreateContext0(Object cl_context_properties, int props_offset, long[] devices, CreateContextCallback pfn_notify, Object userData, Object errcode_ret, int err_offset);
-
- public long clCreateContextFromType(IntBuffer properties, int offset1, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int offset2) {
+
+ public long clCreateContextFromType(IntBuffer properties, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret) {
if(pfn_notify != null)
throw new RuntimeException("asynchronous execution with callback is not yet implemented, pass null through this method to block until complete.");
if(userData != null)
- System.out.println("WARNING: userData not yet implemented... ignoring");
+ System.err.println("WARNING: userData not yet implemented... ignoring");
- return this.clCreateContextFromType0(properties, offset1, device_type, pfn_notify, null, errcode_ret, offset2);
+ return this.clCreateContextFromType1(
+ BufferFactory.getArray(properties), BufferFactory.getIndirectBufferByteOffset(properties), device_type, pfn_notify, null,
+ BufferFactory.getArray(errcode_ret), BufferFactory.getIndirectBufferByteOffset(errcode_ret) );
}
- private native long clCreateContextFromType0(IntBuffer properties, int size, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int size2);
+ private native long clCreateContextFromType1(Object properties, int props_offset, long device_type, CreateContextCallback pfn_notify, Object userData, Object errcode_ret, int err_offset);
/** Interface to C language function: <br> <code> int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); </code> */
@@ -27,7 +29,7 @@
throw new RuntimeException("asynchronous execution with callback is not yet implemented, pass null through this method to block until complete.");
if(userData != null)
- System.out.println("WARNING: userData not yet implemented... ignoring");
+ System.err.println("WARNING: userData not yet implemented... ignoring");
int listLength = 0;
if(deviceList != null)