diff options
author | Michael Bien <[email protected]> | 2010-01-22 18:02:35 +0100 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-01-22 18:02:35 +0100 |
commit | 9ca000faa6aea6771ff5cf209846ef7fb9ff227a (patch) | |
tree | 9c4494df5b3fd688a993c4e1672934950cb8919d /resources | |
parent | 468928edc68896718f0a27b47d59ddad2c892967 (diff) |
dynamic dispatch via CLProcAddressTable for OpenCL extensions.
made CLProgram failsafe, updated tests.
Diffstat (limited to 'resources')
-rw-r--r-- | resources/cl-common.cfg | 3 | ||||
-rw-r--r-- | resources/cl-impl.cfg | 6 | ||||
-rw-r--r-- | resources/clImplCustomCode.c | 18 | ||||
-rw-r--r-- | resources/clImplCustomCode.java | 4 |
4 files changed, 20 insertions, 11 deletions
diff --git a/resources/cl-common.cfg b/resources/cl-common.cfg index e7d761ca..46ee61e5 100644 --- a/resources/cl-common.cfg +++ b/resources/cl-common.cfg @@ -72,10 +72,11 @@ NioDirectOnly clGetProgramInfo NioDirectOnly clGetSamplerInfo NioDirectOnly clSetCommandQueueProperty NioDirectOnly clWaitForEvents - #NioDirectOnly clCreateContext #NioDirectOnly clBuildProgram +#extensions +NioDirectOnly clGetGLContextInfoKHR #common rename emitted struct accessors #struct cl_image_format diff --git a/resources/cl-impl.cfg b/resources/cl-impl.cfg index c2af12cf..ec2718df 100644 --- a/resources/cl-impl.cfg +++ b/resources/cl-impl.cfg @@ -16,6 +16,12 @@ ClassJavadoc CLImpl */ ImplJavaClass CLImpl Implements CLImpl CLGLI +EmitProcAddressTable true +ProcAddressTableClassName CLProcAddressTable +GetProcAddressTableExpr addressTable +ProcAddressNameExpr $UpperCase(arg) +ForceProcAddressGen clGetGLContextInfoKHR + #append to generated c files CustomCCode #include <CL/cl.h> CustomCCode #include <GL3/gl3.h> diff --git a/resources/clImplCustomCode.c b/resources/clImplCustomCode.c index 864edc6b..a0b91f35 100644 --- a/resources/clImplCustomCode.c +++ b/resources/clImplCustomCode.c @@ -28,19 +28,19 @@ JNIEXPORT jlong JNICALL 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; + cl_context_properties* _props_ptr = NULL; int32_t * _errcode_ptr = NULL; cl_context _ctx; if (props != NULL) { - _props_ptr = (void *) (((char*) (*env)->GetPrimitiveArrayCritical(env, props, NULL)) + props_byte_offset); + _props_ptr = (cl_context_properties*) (((char*) (*env)->GetPrimitiveArrayCritical(env, props, NULL)) + props_byte_offset); } if (errcode != NULL) { _errcode_ptr = (void *) (((char*) (*env)->GetPrimitiveArrayCritical(env, errcode, NULL)) + errcode_byte_offset); } //TODO callback; payload - _ctx = clCreateContextFromType((cl_context_properties *) _props_ptr, (uint64_t) device_type, NULL, NULL, (int32_t *) _errcode_ptr); + _ctx = clCreateContextFromType(_props_ptr, (uint64_t) device_type, NULL, NULL, (int32_t *) _errcode_ptr); if (errcode != NULL) { (*env)->ReleasePrimitiveArrayCritical(env, errcode, _errcode_ptr, 0); @@ -49,7 +49,7 @@ Java_com_mbien_opencl_impl_CLImpl_clCreateContextFromType1(JNIEnv *env, jobject (*env)->ReleasePrimitiveArrayCritical(env, props, _props_ptr, 0); } - return (jlong)_ctx; + return (jlong) (intptr_t)_ctx; } /* @@ -66,14 +66,14 @@ JNIEXPORT jlong JNICALL Java_com_mbien_opencl_impl_CLImpl_clCreateContext1(JNIEnv *env, jobject _unused, jobject props, jint props_byte_offset, jint numDevices, jobject deviceList, jobject cb, jobject data, jobject errcode, jint errcode_byte_offset) { - intptr_t * _props_ptr = NULL; + cl_context_properties* _props_ptr = NULL; int32_t * _errcode_ptr = NULL; size_t * _deviceListPtr = NULL; cl_context _ctx; if (props != NULL) { - _props_ptr = (void *) (((char*) (*env)->GetPrimitiveArrayCritical(env, props, NULL)) + props_byte_offset); + _props_ptr = (cl_context_properties*) (((char*) (*env)->GetPrimitiveArrayCritical(env, props, NULL)) + props_byte_offset); } if (deviceList != NULL) { _deviceListPtr = (void *) (((char*) (*env)->GetPrimitiveArrayCritical(env, deviceList, NULL)) /*+ device_byte_offset*/); @@ -83,7 +83,7 @@ Java_com_mbien_opencl_impl_CLImpl_clCreateContext1(JNIEnv *env, jobject _unused, } // TODO payload, callback... - _ctx = clCreateContext((cl_context_properties *) _props_ptr, numDevices, (cl_device_id *)_deviceListPtr, NULL, NULL, (int32_t *) _errcode_ptr); + _ctx = clCreateContext(_props_ptr, numDevices, (cl_device_id *)_deviceListPtr, NULL, NULL, (int32_t *) _errcode_ptr); if (errcode != NULL) { (*env)->ReleasePrimitiveArrayCritical(env, errcode, _errcode_ptr, 0); @@ -95,7 +95,7 @@ Java_com_mbien_opencl_impl_CLImpl_clCreateContext1(JNIEnv *env, jobject _unused, (*env)->ReleasePrimitiveArrayCritical(env, props, _props_ptr, 0); } - return (jlong) _ctx; + return (jlong) (intptr_t)_ctx; } /** @@ -140,5 +140,5 @@ Java_com_mbien_opencl_impl_CLImpl_clBuildProgram1(JNIEnv *env, jobject _unused, (*env)->ReleaseStringUTFChars(env, options, _strchars_options); } - return _res; + return (jint)_res; } diff --git a/resources/clImplCustomCode.java b/resources/clImplCustomCode.java index c0c8365b..0a42cc12 100644 --- a/resources/clImplCustomCode.java +++ b/resources/clImplCustomCode.java @@ -1,4 +1,6 @@ + CLProcAddressTable addressTable = new CLProcAddressTable(); + public long clCreateContext(java.nio.Buffer properties, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret) { if(pfn_notify != null) @@ -51,7 +53,7 @@ /** Entry point to C language function: <code> int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); </code> */ private native int clBuildProgram1(long program, int devices, Object deviceList, String options, BuildProgramCallback cb, Object userData); - + private final static void convert32To64(long[] values) { if(values.length%2 == 1) { values[values.length-1] = values[values.length/2]>>>32; |