diff options
author | Michael Bien <[email protected]> | 2009-09-23 01:32:54 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2009-09-23 01:32:54 +0200 |
commit | 0ac4a12fb74de16f41ee9ad46e917b45523bbac4 (patch) | |
tree | d9072115c60805c0f50df2ae4cd90227e6c10cea /resources | |
parent | 8ba956a7df1b98ed2957a932debfce4c6d4cb848 (diff) |
splitted binding in core (CL) and CL-GL interop. (CLGLI)
began with custom impl. for functions with c -> java callbacks
added an utility which uncomments function parameter names in headers
Diffstat (limited to 'resources')
-rw-r--r-- | resources/CL/cl.h | 14 | ||||
-rw-r--r-- | resources/cl-common.cfg | 5 | ||||
-rw-r--r-- | resources/cl-if.cfg | 31 | ||||
-rw-r--r-- | resources/cl-impl.cfg | 27 | ||||
-rw-r--r-- | resources/clImplCustomCode.c | 44 | ||||
-rw-r--r-- | resources/clImplCustomCode.java | 13 | ||||
-rw-r--r-- | resources/clgl-if.cfg | 4 |
7 files changed, 119 insertions, 19 deletions
diff --git a/resources/CL/cl.h b/resources/CL/cl.h index d353f9ad..4a2c6712 100644 --- a/resources/CL/cl.h +++ b/resources/CL/cl.h @@ -437,15 +437,15 @@ extern CL_API_ENTRY cl_context CL_API_CALL clCreateContext(cl_context_properties * /* properties */, cl_uint /* num_devices */, const cl_device_id * /* devices */, -// void (*pfn_notify)(const char *, const void *, size_t, void *) /* pfn_notify */, -// void * /* user_data */, + void (*pfn_notify)(const char *, const void *, size_t, void *) /* pfn_notify */, + void * /* user_data */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_context CL_API_CALL clCreateContextFromType(cl_context_properties * /* properties */, cl_device_type /* device_type */, -// void (*pfn_notify)(const char *, const void *, size_t, void *) /* pfn_notify */, -// void * /* user_data */, + void (*pfn_notify)(const char *, const void *, size_t, void *) /* pfn_notify */, + void * /* user_data */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL @@ -594,7 +594,7 @@ clBuildProgram(cl_program /* program */, cl_uint /* num_devices */, const cl_device_id * /* device_list */, const char * /* options */, -// void (*pfn_notify)(cl_program /* program */, void * /* user_data */), + void (*pfn_notify)(cl_program /* program */, void * /* user_data */), void * /* user_data */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL @@ -834,8 +834,8 @@ clEnqueueTask(cl_command_queue /* command_queue */, extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueNativeKernel(cl_command_queue /* command_queue */, -// void (*user_func)(void *), -// void * /* args */, + void (*user_func)(void *), + void * /* args */, size_t /* cb_args */, cl_uint /* num_mem_objects */, const cl_mem * /* mem_list */, diff --git a/resources/cl-common.cfg b/resources/cl-common.cfg index bcdf7ee9..58b31880 100644 --- a/resources/cl-common.cfg +++ b/resources/cl-common.cfg @@ -1,6 +1,8 @@ JavaOutputDir gensrc/java NativeOutputDir gensrc/native +Package com.mbien.opencl + #map pointers to long as internal representation Opaque long cl_context Opaque long cl_device_type @@ -15,3 +17,6 @@ Opaque long cl_sampler Opaque long cl_platform_id Opaque long cl_device_id +ArgumentIsString clCreateProgramWithSource 2 +ArgumentIsString clBuildProgram 3 +ArgumentIsString clCreateKernel 1
\ No newline at end of file diff --git a/resources/cl-if.cfg b/resources/cl-if.cfg new file mode 100644 index 00000000..6d23789d --- /dev/null +++ b/resources/cl-if.cfg @@ -0,0 +1,31 @@ +Include cl-common.cfg + +Style InterfaceOnly + +#imports for all generated java files +Import java.nio.IntBuffer + +ClassJavadoc CL /** +ClassJavadoc CL * Java bindings to OpenCL, the Open Computing Language. +ClassJavadoc CL * @autor Michael Bien +ClassJavadoc CL */ +JavaClass CL + +#ignore cl-gl interoperability funcions. Interface 'CL' is pure OpenCL. +Ignore CL_GL_.*|cl.*GL.* + +#custom implementations +Ignore clCreateContext +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 arg1, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret); + +Ignore clCreateContextFromType +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, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret); + +Ignore clBuildProgram +#TODO.. + +Ignore clEnqueueNativeKernel +#TODO.. + diff --git a/resources/cl-impl.cfg b/resources/cl-impl.cfg index 5cf23c88..58fc5871 100644 --- a/resources/cl-impl.cfg +++ b/resources/cl-impl.cfg @@ -1,18 +1,15 @@ Include cl-common.cfg -Package com.mbien.opencl - -Style InterfaceAndImpl +Style ImplOnly #imports for all generated java files Import com.mbien.opencl.* -#Import java.nio.* +Import java.nio.IntBuffer -ClassJavadoc CL /** -ClassJavadoc CL * Java bindings to OpenCL, the Open Computing Language. -ClassJavadoc CL * @autor Michael Bien -ClassJavadoc CL */ -JavaClass CL +ClassJavadoc CLImpl /** +ClassJavadoc CLImpl * Java bindings to OpenCL, the Open Computing Language. +ClassJavadoc CLImpl * @autor Michael Bien +ClassJavadoc CLImpl */ ImplJavaClass CLImpl Implements CLImpl CLGLI @@ -20,4 +17,14 @@ Implements CLImpl CLGLI #append to generated c files CustomCCode #include <cl.h> CustomCCode #include <gl3.h> -CustomCCode #include <inttypes.h>
\ No newline at end of file +CustomCCode #include <inttypes.h> + +# implement manually via custom code +Ignore clCreateContext +Ignore clCreateContextFromType +Ignore clBuildProgram +Ignore clEnqueueNativeKernel + +#include custom code +IncludeAs CustomJavaCode CLImpl clImplCustomCode.java +IncludeAs CustomCCode clImplCustomCode.c diff --git a/resources/clImplCustomCode.c b/resources/clImplCustomCode.c new file mode 100644 index 00000000..a281ccc3 --- /dev/null +++ b/resources/clImplCustomCode.c @@ -0,0 +1,44 @@ + +/* +void createContextCallback(const char * c, const void * v, size_t s, void * o) { + //TODO +} +*/ + +/* Java->C glue code: + * Java package: com.mbien.opencl.impl.CLImpl + * Java method: long clCreateContextFromType(java.nio.IntBuffer arg0, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret) + * C function: cl_context clCreateContextFromType( cl_context_properties * properties , + * cl_uint num_devices , + * const cl_device_id * devices , + * void (*pfn_notify)(const char *, const void *, size_t, void *) pfn_notify/, + * void * user_data , + * cl_int * errcode_ret ); + */ +//Ljava/nio/IntBuffer;JLjava/lang/Object;Ljava/lang/Object;Ljava/nio/IntBuffer; +//Ljava_lang_Object_2I J Ljava_lang_Object_2 Ljava_lang_Object_2 Ljava_lang_Object_2I +//IntBuffer arg0, long device_type, Object pfn_notify, Object userData, IntBuffer errcode_ret +JNIEXPORT jlong JNICALL +Java_com_mbien_opencl_impl_CLImpl_clCreateContextFromType0__Ljava_lang_Object_2IJLjava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2I(JNIEnv *env, jobject _unused, + jobject arg0, jint arg0_byte_offset, jlong device_type, jobject cb, jobject data, jobject errcode, jint errcode_byte_offset) { + + printf("%s", "function entry"); + + intptr_t * _ptr0 = NULL; + int32_t * _ptr2 = NULL; + + cl_context _res; + + if (arg0 != NULL) { + _ptr0 = (intptr_t *) (((char*) (*env)->GetDirectBufferAddress(env, arg0)) + arg0_byte_offset); + } + if (errcode != NULL) { + _ptr2 = (int32_t *) (((char*) (*env)->GetDirectBufferAddress(env, errcode)) + errcode_byte_offset); + } + + printf("%s", "pre call"); + _res = clCreateContextFromType((intptr_t *) _ptr0, (uint64_t) device_type, NULL, NULL, (int32_t *) _ptr2); + printf("%s", "post call"); + + return (jlong) (intptr_t) _res; +}
\ No newline at end of file diff --git a/resources/clImplCustomCode.java b/resources/clImplCustomCode.java new file mode 100644 index 00000000..7b69330b --- /dev/null +++ b/resources/clImplCustomCode.java @@ -0,0 +1,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); + } + + public native long clCreateContext0(IntBuffer properties, int arg1, long[] devices, CreateContextCallback cb, Object userData, IntBuffer errcode_ret); + + public long clCreateContextFromType(IntBuffer arg0, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret) { + return this.clCreateContextFromType0(arg0, device_type, pfn_notify, null, errcode_ret); + } + + public native long clCreateContextFromType0(IntBuffer arg0, long device_type, Object pfn_notify, Object userData, IntBuffer errcode_ret); +
\ No newline at end of file diff --git a/resources/clgl-if.cfg b/resources/clgl-if.cfg index 771e39f6..d21e8072 100644 --- a/resources/clgl-if.cfg +++ b/resources/clgl-if.cfg @@ -1,7 +1,5 @@ Include cl-common.cfg -Package com.mbien.opencl - Style InterfaceOnly ClassJavadoc CLGLI /** @@ -11,6 +9,8 @@ ClassJavadoc CLGLI * @autor Michael Bien ClassJavadoc CLGLI */ JavaClass CLGLI +Extends CLGLI CL + #only include token starting with CL_GL_ and methods containing GL IgnoreNot CL_GL_.*|cl.*GL.* |