diff options
author | Wade Walker <[email protected]> | 2015-09-19 15:20:23 -0500 |
---|---|---|
committer | Wade Walker <[email protected]> | 2015-11-08 14:05:29 -0600 |
commit | 4638f4b3fdf4c946bda0b290a83652e4db00edea (patch) | |
tree | 7d027b893fbf1d55d578e2f156186075a092810c | |
parent | 9a90181ed1fb596275fee9ebca0f3d1093722ca9 (diff) |
Factor out common custom C and Java code to reduce duplication
Consolidated C custom code so common functions are only defined once in
the 1.1 version, then are called from the 1.2 and 2.0 version. Pulled
common code in CLImpl up into the autogenerated implementation class and
removed the hand-written implementation (since it was left empty).
Factored custom Java code out so there was as little duplication as
possible across the three CLImpl versions, with common code for all
three versions in clImplCustomCode.java.
-rw-r--r-- | make/build.xml | 8 | ||||
-rw-r--r-- | make/config/cl-impl-11.cfg | 30 | ||||
-rw-r--r-- | make/config/cl-impl-12.cfg | 31 | ||||
-rw-r--r-- | make/config/cl-impl-20.cfg | 31 | ||||
-rw-r--r-- | make/config/clImplCustomCode.c | 31 | ||||
-rw-r--r-- | make/config/clImplCustomCode.java (renamed from src/com/jogamp/opencl/llb/impl/CLImpl11.java) | 163 | ||||
-rw-r--r-- | make/config/clImplCustomCode11.c | 2 | ||||
-rw-r--r-- | make/config/clImplCustomCode11.java | 55 | ||||
-rw-r--r-- | make/config/clImplCustomCode12.c | 317 | ||||
-rw-r--r-- | make/config/clImplCustomCode12.java | 54 | ||||
-rw-r--r-- | make/config/clImplCustomCode20.c | 317 | ||||
-rw-r--r-- | make/config/clImplCustomCode20.java | 54 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLPlatform.java | 5 | ||||
-rw-r--r-- | src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java | 2 | ||||
-rw-r--r-- | test/com/jogamp/opencl/test/util/MiscUtils.java | 2 |
15 files changed, 221 insertions, 881 deletions
diff --git a/make/build.xml b/make/build.xml index b1bb7091..d08614a9 100644 --- a/make/build.xml +++ b/make/build.xml @@ -288,7 +288,7 @@ <!-- Now check for the presence of one well-known file --> <uptodate property="java.generate.skip" - targetfile="${src.generated.c}/CLAbstractImpl_JNI.c"> + targetfile="${src.generated.c}/CLImpl11_JNI.c"> <srcfiles refid="stub.includes.dependencies.fileset.1" /> <srcfiles refid="stub.includes.dependencies.fileset.2" /> <srcfiles refid="stub.includes.dependencies.fileset.3" /> @@ -553,7 +553,7 @@ <classpath refid="gluegen.classpath" /> </gluegen> - <echo message="Generating CLAbstractImpl.java, CLAbstractImpl_JNI.c, and CLProcAddressTable.java for OpenCL version 1.1"/> + <echo message="Generating CLImpl.java, CLImpl_JNI.c, and CLProcAddressTable.java for OpenCL version 1.1"/> <gluegen src="${stub.includes}/opencl.h" outputRootDir="${build}" config="${config}/cl-impl-11.cfg" @@ -568,7 +568,7 @@ <include name="${gen.includes.dir}/CL12"/> </dirset> <echo message="OpenCL stub include path for OpenCL version 1.2: ${toString:stub.includes.fileset.all.12}"/> - <echo message="Generating CLAbstractImpl.java, CLAbstractImpl_JNI.c, and CLProcAddressTable.java for OpenCL version 1.2"/> + <echo message="Generating CLImpl.java, CLImpl_JNI.c, and CLProcAddressTable.java for OpenCL version 1.2"/> <gluegen src="${stub.includes}/opencl.h" outputRootDir="${build}" config="${config}/cl-impl-12.cfg" @@ -583,7 +583,7 @@ <include name="${gen.includes.dir}/CL20"/> </dirset> <echo message="OpenCL stub include path for OpenCL version 2.0: ${toString:stub.includes.fileset.all.20}"/> - <echo message="Generating CLAbstractImpl.java, CLAbstractImpl_JNI.c, and CLProcAddressTable.java for OpenCL version 2.0"/> + <echo message="Generating CLImpl.java, CLImpl_JNI.c, and CLProcAddressTable.java for OpenCL version 2.0"/> <gluegen src="${stub.includes}/opencl.h" outputRootDir="${build}" config="${config}/cl-impl-20.cfg" diff --git a/make/config/cl-impl-11.cfg b/make/config/cl-impl-11.cfg index 9a49ea64..34d48424 100644 --- a/make/config/cl-impl-11.cfg +++ b/make/config/cl-impl-11.cfg @@ -7,15 +7,22 @@ Style ImplOnly Import com.jogamp.opencl.llb.gl.CLGL Import java.security.AccessController Import java.security.PrivilegedAction - -ClassJavadoc CLAbstractImpl11 /** -ClassJavadoc CLAbstractImpl11 * Java bindings to OpenCL, the Open Computing Language (generated). -ClassJavadoc CLAbstractImpl11 * @author Michael Bien, GlueGen, et al. -ClassJavadoc CLAbstractImpl11 */ - -ImplJavaClass CLAbstractImpl11 -AccessControl CLAbstractImpl11 PUBLIC_ABSTRACT -Implements CLAbstractImpl11 CLGL +Import com.jogamp.common.nio.PointerBuffer +Import com.jogamp.common.util.LongLongHashMap +Import com.jogamp.opencl.CLErrorHandler +Import com.jogamp.opencl.CLException +Import java.nio.ByteBuffer +Import java.nio.IntBuffer +Import com.jogamp.common.nio.Buffers + +ClassJavadoc CLImpl11 /** +ClassJavadoc CLImpl11 * Java bindings to OpenCL, the Open Computing Language (generated). +ClassJavadoc CLImpl11 * @author Michael Bien, GlueGen, et al. +ClassJavadoc CLImpl11 */ + +ImplJavaClass CLImpl11 +AccessControl CLImpl11 PUBLIC +Implements CLImpl11 CLGL LocalProcAddressCallingConvention __ALL__ CL_API_CALL @@ -93,7 +100,8 @@ ManuallyImplement clEnqueueMapImage ForceProcAddressGen clEnqueueMapImage #include custom code -IncludeAs CustomJavaCode CLAbstractImpl11 clImplCustomCode11.java -ManualStaticInitCall CLAbstractImpl11 +IncludeAs CustomJavaCode CLImpl11 clImplCustomCode11.java +IncludeAs CustomJavaCode CLImpl11 clImplCustomCode.java +ManualStaticInitCall CLImpl11 IncludeAs CustomCCode clImplCustomCode11.c diff --git a/make/config/cl-impl-12.cfg b/make/config/cl-impl-12.cfg index 01b9ea28..2f8e8dd1 100644 --- a/make/config/cl-impl-12.cfg +++ b/make/config/cl-impl-12.cfg @@ -7,15 +7,22 @@ Style ImplOnly Import com.jogamp.opencl.llb.gl.CLGL Import java.security.AccessController Import java.security.PrivilegedAction - -ClassJavadoc CLAbstractImpl12 /** -ClassJavadoc CLAbstractImpl12 * Java bindings to OpenCL, the Open Computing Language (generated). -ClassJavadoc CLAbstractImpl12 * @author Michael Bien, GlueGen, et al. -ClassJavadoc CLAbstractImpl12 */ - -ImplJavaClass CLAbstractImpl12 -AccessControl CLAbstractImpl12 PUBLIC_ABSTRACT -Implements CLAbstractImpl12 CLGL +Import com.jogamp.common.nio.PointerBuffer +Import com.jogamp.common.util.LongLongHashMap +Import com.jogamp.opencl.CLErrorHandler +Import com.jogamp.opencl.CLException +Import java.nio.ByteBuffer +Import java.nio.IntBuffer +Import com.jogamp.common.nio.Buffers + +ClassJavadoc CLImpl12 /** +ClassJavadoc CLImpl12 * Java bindings to OpenCL, the Open Computing Language (generated). +ClassJavadoc CLImpl12 * @author Michael Bien, GlueGen, et al. +ClassJavadoc CLImpl12 */ + +ImplJavaClass CLImpl12 +AccessControl CLImpl12 PUBLIC +Implements CLImpl12 CLGL LocalProcAddressCallingConvention __ALL__ CL_API_CALL @@ -99,7 +106,9 @@ ManuallyImplement clEnqueueMapImage ForceProcAddressGen clEnqueueMapImage #include custom code -IncludeAs CustomJavaCode CLAbstractImpl12 clImplCustomCode12.java -ManualStaticInitCall CLAbstractImpl12 +IncludeAs CustomJavaCode CLImpl12 clImplCustomCode12.java +IncludeAs CustomJavaCode CLImpl12 clImplCustomCode.java +ManualStaticInitCall CLImpl12 +IncludeAs CustomCCode clImplCustomCode.c IncludeAs CustomCCode clImplCustomCode12.c diff --git a/make/config/cl-impl-20.cfg b/make/config/cl-impl-20.cfg index 5b0a9125..8f8358ed 100644 --- a/make/config/cl-impl-20.cfg +++ b/make/config/cl-impl-20.cfg @@ -7,15 +7,22 @@ Style ImplOnly Import com.jogamp.opencl.llb.gl.CLGL Import java.security.AccessController Import java.security.PrivilegedAction - -ClassJavadoc CLAbstractImpl20 /** -ClassJavadoc CLAbstractImpl20 * Java bindings to OpenCL, the Open Computing Language (generated). -ClassJavadoc CLAbstractImpl20 * @author Michael Bien, GlueGen, et al. -ClassJavadoc CLAbstractImpl20 */ - -ImplJavaClass CLAbstractImpl20 -AccessControl CLAbstractImpl20 PUBLIC_ABSTRACT -Implements CLAbstractImpl20 CLGL +Import com.jogamp.common.nio.PointerBuffer +Import com.jogamp.common.util.LongLongHashMap +Import com.jogamp.opencl.CLErrorHandler +Import com.jogamp.opencl.CLException +Import java.nio.ByteBuffer +Import java.nio.IntBuffer +Import com.jogamp.common.nio.Buffers + +ClassJavadoc CLImpl20 /** +ClassJavadoc CLImpl20 * Java bindings to OpenCL, the Open Computing Language (generated). +ClassJavadoc CLImpl20 * @author Michael Bien, GlueGen, et al. +ClassJavadoc CLImpl20 */ + +ImplJavaClass CLImpl20 +AccessControl CLImpl20 PUBLIC +Implements CLImpl20 CLGL LocalProcAddressCallingConvention __ALL__ CL_API_CALL @@ -99,7 +106,9 @@ ManuallyImplement clEnqueueMapImage ForceProcAddressGen clEnqueueMapImage #include custom code -IncludeAs CustomJavaCode CLAbstractImpl20 clImplCustomCode20.java -ManualStaticInitCall CLAbstractImpl20 +IncludeAs CustomJavaCode CLImpl20 clImplCustomCode20.java +IncludeAs CustomJavaCode CLImpl20 clImplCustomCode.java +ManualStaticInitCall CLImpl20 +IncludeAs CustomCCode clImplCustomCode.c IncludeAs CustomCCode clImplCustomCode20.c diff --git a/make/config/clImplCustomCode.c b/make/config/clImplCustomCode.c new file mode 100644 index 00000000..30c55363 --- /dev/null +++ b/make/config/clImplCustomCode.c @@ -0,0 +1,31 @@ +// Extern declarations of functions. The earliest version of OpenCL defines them, and the later versions use them. + +extern JNIEXPORT jlong JNICALL +Java_com_jogamp_opencl_llb_impl_CLImpl11_dispatch_1clGetExtensionFunctionAddressStatic(JNIEnv *env, jclass _unused, jstring fname, jlong procAddress); + +extern JNIEXPORT jlong JNICALL +Java_com_jogamp_opencl_llb_impl_CLImpl11_clCreateContextFromType0(JNIEnv *env, jobject _unused, jobject props, jint props_byte_offset, jlong device_type, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset, jlong procAddress); + +extern JNIEXPORT jlong JNICALL +Java_com_jogamp_opencl_llb_impl_CLImpl11_clCreateContext0(JNIEnv *env, jobject _unused, jobject props, jint props_byte_offset, jint numDevices, jobject deviceList, jint device_type_offset, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset, jlong procAddress); + +extern JNIEXPORT jint JNICALL +Java_com_jogamp_opencl_llb_impl_CLImpl11_clReleaseContextImpl(JNIEnv *env, jobject _unused, jlong context, jlong global, jlong procAddress); + +extern JNIEXPORT jint JNICALL +Java_com_jogamp_opencl_llb_impl_CLImpl11_clBuildProgram0(JNIEnv *env, jobject _unused, jlong program, jint deviceCount, jobject deviceList, jint device_type_offset, jstring options, jobject cb, jlong procAddress); + +extern JNIEXPORT jobject JNICALL +Java_com_jogamp_opencl_llb_impl_CLImpl11_clEnqueueMapImage0__JJIJLjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2IILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2I(JNIEnv *env, jobject _unused, + jlong command_queue, jlong image, jint blocking_map, jlong map_flags, + jobject origin, jint origin_byte_offset, jobject range, jint range_byte_offset, + jobject image_row_pitch, jint image_row_pitch_byte_offset, jobject image_slice_pitch, + jint image_slice_pitch_byte_offset, jint num_events_in_wait_list, jobject event_wait_list, + jint event_wait_list_byte_offset, jobject event, jint event_byte_offset, jobject errcode_ret, jint errcode_ret_byte_offset, + jlong imageInfoAddress, jlong mapImageAddress); + +extern JNIEXPORT jint JNICALL +Java_com_jogamp_opencl_llb_impl_CLImpl11_clSetEventCallback0(JNIEnv *env, jobject _unused, jlong event, jint trigger, jobject listener, jlong procAddress); + +extern JNIEXPORT jint JNICALL +Java_com_jogamp_opencl_llb_impl_CLImpl11_clSetMemObjectDestructorCallback0(JNIEnv *env, jobject _unused, jlong mem, jobject listener, jlong procAddress); diff --git a/src/com/jogamp/opencl/llb/impl/CLImpl11.java b/make/config/clImplCustomCode.java index fc335ec8..a863bffb 100644 --- a/src/com/jogamp/opencl/llb/impl/CLImpl11.java +++ b/make/config/clImplCustomCode.java @@ -1,60 +1,64 @@ -/* - * Copyright (c) 2009 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -/* - * Created on Monday, June 07 2010 at 04:25 - */ -package com.jogamp.opencl.llb.impl; - -import com.jogamp.common.nio.PointerBuffer; -import com.jogamp.common.util.LongLongHashMap; -import com.jogamp.opencl.CLErrorHandler; -import com.jogamp.opencl.CLException; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; - -import static com.jogamp.common.nio.Buffers.*; - -/** - * Java bindings to OpenCL, the Open Computing Language. - * @author Michael Bien, et al. - */ -public class CLImpl11 extends CLAbstractImpl11 { - - //maps the context id to its error handler's global object pointer - private final LongLongHashMap contextCallbackMap; - - public CLImpl11() { - super(); - this.contextCallbackMap = new LongLongHashMap(); +/** If null, OpenCL is not available on this machine. */ + static final DynamicLibraryBundle dynamicLookupHelper; + + static { + dynamicLookupHelper = AccessController.doPrivileged(new PrivilegedAction<DynamicLibraryBundle>() { + public DynamicLibraryBundle run() { + final DynamicLibraryBundle bundle = new DynamicLibraryBundle(new CLDynamicLibraryBundleInfo()); + if(!bundle.isToolLibLoaded()) { + // couldn't load native CL library + // TODO: log this? + return null; + } + if(!bundle.isLibComplete()) { + System.err.println("Couln't load native CL/JNI glue library"); + return null; + } + addressTable.reset(bundle); + /** Not required nor forced + if( !initializeImpl() ) { + System.err.println("Native initialization failure of CL/JNI glue library"); + return null; + } */ + return bundle; + } } ); + } + + // maps the context id to its error handler's global object pointer + private final LongLongHashMap contextCallbackMap = new LongLongHashMap(); + + // to use in subclass constructors + protected void init() { this.contextCallbackMap.setKeyNotFoundValue(0); } + /** + * Accessor. + * @returns true if OpenCL is available on this machine. + */ + public static boolean isAvailable() { return dynamicLookupHelper != null; } + + static long clGetExtensionFunctionAddress(long clGetExtensionFunctionAddressHandle, java.lang.String procname) + { + if (clGetExtensionFunctionAddressHandle == 0) { + throw new RuntimeException("Passed null pointer for method \"clGetExtensionFunctionAddress\""); + } + return dispatch_clGetExtensionFunctionAddressStatic(procname, clGetExtensionFunctionAddressHandle); + } + + /** Entry point (through function pointer) to C language function: <br> <code> void* clGetExtensionFunctionAddress(const char * fname); </code> */ + long clGetExtensionFunctionAddress(String fname) { + + final long __addr_ = addressTable._addressof_clGetExtensionFunctionAddress; + if (__addr_ == 0) { + throw new UnsupportedOperationException("Method \"clGetExtensionFunctionAddress\" not available"); + } + return dispatch_clGetExtensionFunctionAddressStatic(fname, __addr_); + } + + /** Entry point (through function pointer) to C language function: <br> <code> void* clGetExtensionFunctionAddress(const char * fname); </code> */ + private static native long dispatch_clGetExtensionFunctionAddressStatic(String fname, long procAddress); + @Override public long clCreateContext(final PointerBuffer properties, final PointerBuffer devices, final CLErrorHandler pfn_notify, final IntBuffer errcode_ret) { @@ -73,9 +77,9 @@ public class CLImpl11 extends CLAbstractImpl11 { final long[] global = new long[1]; final long ctx = this.clCreateContext0( - properties != null ? properties.getBuffer() : null, getDirectBufferByteOffset(properties), - devices != null ? devices.remaining() : 0, devices != null ? devices.getBuffer() : null, getDirectBufferByteOffset(devices), - pfn_notify, global, errcode_ret, getDirectBufferByteOffset(errcode_ret), address); + properties != null ? properties.getBuffer() : null, Buffers.getDirectBufferByteOffset(properties), + devices != null ? devices.remaining() : 0, devices != null ? devices.getBuffer() : null, Buffers.getDirectBufferByteOffset(devices), + pfn_notify, global, errcode_ret, Buffers.getDirectBufferByteOffset(errcode_ret), address); if (pfn_notify != null && global[0] != 0) { synchronized (contextCallbackMap) { @@ -104,8 +108,8 @@ public class CLImpl11 extends CLAbstractImpl11 { final long[] global = new long[1]; final long ctx = this.clCreateContextFromType0( - properties != null ? properties.getBuffer() : null, getDirectBufferByteOffset(properties), - device_type, pfn_notify, global, errcode_ret, getDirectBufferByteOffset(errcode_ret), address); + properties != null ? properties.getBuffer() : null, Buffers.getDirectBufferByteOffset(properties), + device_type, pfn_notify, global, errcode_ret, Buffers.getDirectBufferByteOffset(errcode_ret), address); if (pfn_notify != null && global[0] != 0) { synchronized (contextCallbackMap) { @@ -146,7 +150,7 @@ public class CLImpl11 extends CLAbstractImpl11 { throw new UnsupportedOperationException("Method not available"); } return clBuildProgram0(program, deviceCount, deviceList != null ? deviceList.getBuffer() : null, - getDirectBufferByteOffset(deviceList), options, cb, address); + Buffers.getDirectBufferByteOffset(deviceList), options, cb, address); } /** Entry point to C language function: <code> int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); </code> */ @@ -224,17 +228,17 @@ public class CLImpl11 extends CLAbstractImpl11 { } ByteBuffer _res; _res = clEnqueueMapImage0(command_queue, image, blocking_map, map_flags, origin != null ? origin.getBuffer() : null, - getDirectBufferByteOffset(origin), range != null ? range.getBuffer() : null, - getDirectBufferByteOffset(range), image_row_pitch != null ? image_row_pitch.getBuffer() : null, - getDirectBufferByteOffset(image_row_pitch), image_slice_pitch != null ? image_slice_pitch.getBuffer() : null, - getDirectBufferByteOffset(image_slice_pitch), num_events_in_wait_list, - event_wait_list != null ? event_wait_list.getBuffer() : null, getDirectBufferByteOffset(event_wait_list), - event != null ? event.getBuffer() : null, getDirectBufferByteOffset(event), errcode_ret, - getDirectBufferByteOffset(errcode_ret), getImageInfoAddress, mapImageAddress); + Buffers.getDirectBufferByteOffset(origin), range != null ? range.getBuffer() : null, + Buffers.getDirectBufferByteOffset(range), image_row_pitch != null ? image_row_pitch.getBuffer() : null, + Buffers.getDirectBufferByteOffset(image_row_pitch), image_slice_pitch != null ? image_slice_pitch.getBuffer() : null, + Buffers.getDirectBufferByteOffset(image_slice_pitch), num_events_in_wait_list, + event_wait_list != null ? event_wait_list.getBuffer() : null, Buffers.getDirectBufferByteOffset(event_wait_list), + event != null ? event.getBuffer() : null, Buffers.getDirectBufferByteOffset(event), errcode_ret, + Buffers.getDirectBufferByteOffset(errcode_ret), getImageInfoAddress, mapImageAddress); if (_res == null) { return null; } - nativeOrder(_res); + Buffers.nativeOrder(_res); return _res; } @@ -251,25 +255,4 @@ public class CLImpl11 extends CLAbstractImpl11 { int image_row_pitch_byte_offset, Object image_slice_pitch, int image_slice_pitch_byte_offset, int num_events_in_wait_list, Object event_wait_list, int event_wait_list_byte_offset, Object event, int event_byte_offset, Object errcode_ret, int errcode_ret_byte_offset, - long getImageInfoAddress, long mapImageAddress); - - public CLProcAddressTable11 getAddressTable() { - return addressTable; - } - - /* - private static void convert32To64(long[] values) { - if (values.length % 2 == 1) { - values[values.length - 1] = values[values.length / 2] >>> 32; - } - for (int i = values.length - 1 - values.length % 2; i >= 0; i -= 2) { - long temp = values[i / 2]; - values[i - 1] = temp >>> 32; - values[i] = temp & 0x00000000FFFFFFFFL; - } - } - */ - - - -} + long getImageInfoAddress, long mapImageAddress);
\ No newline at end of file diff --git a/make/config/clImplCustomCode11.c b/make/config/clImplCustomCode11.c index 1e772d9e..243e73cb 100644 --- a/make/config/clImplCustomCode11.c +++ b/make/config/clImplCustomCode11.c @@ -115,7 +115,7 @@ CL_CALLBACK void memObjDestructorCallback(cl_mem mem, void * object) { // extern CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddress(const char * /* func_name */) CL_API_SUFFIX__VERSION_1_0; JNIEXPORT jlong JNICALL -Java_com_jogamp_opencl_llb_impl_CLAbstractImpl11_dispatch_1clGetExtensionFunctionAddressStatic(JNIEnv *env, jclass _unused, jstring fname, jlong procAddress) { +Java_com_jogamp_opencl_llb_impl_CLImpl11_dispatch_1clGetExtensionFunctionAddressStatic(JNIEnv *env, jclass _unused, jstring fname, jlong procAddress) { typedef void* (CL_API_CALL * _local_LPCLGETPROCADDRESS)(const char * fname); _local_LPCLGETPROCADDRESS ptr_clGetExtensionFunctionAddress; const char* _strchars_fname = NULL; diff --git a/make/config/clImplCustomCode11.java b/make/config/clImplCustomCode11.java index 0dcb770f..bc1cfdda 100644 --- a/make/config/clImplCustomCode11.java +++ b/make/config/clImplCustomCode11.java @@ -1,60 +1,11 @@ - - /** If null, OpenCL is not available on this machine. */ - static final DynamicLibraryBundle dynamicLookupHelper; protected static final CLProcAddressTable11 addressTable; static { addressTable = new CLProcAddressTable11(); - dynamicLookupHelper = AccessController.doPrivileged(new PrivilegedAction<DynamicLibraryBundle>() { - public DynamicLibraryBundle run() { - final DynamicLibraryBundle bundle = new DynamicLibraryBundle(new CLDynamicLibraryBundleInfo()); - if(!bundle.isToolLibLoaded()) { - // couldn't load native CL library - // TODO: log this? - return null; - } - if(!bundle.isLibComplete()) { - System.err.println("Couln't load native CL/JNI glue library"); - return null; - } - addressTable.reset(bundle); - /** Not required nor forced - if( !initializeImpl() ) { - System.err.println("Native initialization failure of CL/JNI glue library"); - return null; - } */ - return bundle; - } } ); - } - - /** - * Accessor. - * @returns true if OpenCL is available on this machine. - */ - public static boolean isAvailable() { return dynamicLookupHelper != null; } - public static CLProcAddressTable11 getCLProcAddressTable() { return addressTable; } - - static long clGetExtensionFunctionAddress(long clGetExtensionFunctionAddressHandle, java.lang.String procname) - { - if (clGetExtensionFunctionAddressHandle == 0) { - throw new RuntimeException("Passed null pointer for method \"clGetExtensionFunctionAddress\""); - } - return dispatch_clGetExtensionFunctionAddressStatic(procname, clGetExtensionFunctionAddressHandle); } - public CLAbstractImpl11() { - } - - /** Entry point (through function pointer) to C language function: <br> <code> void* clGetExtensionFunctionAddress(const char * fname); </code> */ - long clGetExtensionFunctionAddress(String fname) { + public static CLProcAddressTable11 getAddressTable() { return addressTable; } - final long __addr_ = addressTable._addressof_clGetExtensionFunctionAddress; - if (__addr_ == 0) { - throw new UnsupportedOperationException("Method \"clGetExtensionFunctionAddress\" not available"); - } - return dispatch_clGetExtensionFunctionAddressStatic(fname, __addr_); + public CLImpl11() { + init(); } - - /** Entry point (through function pointer) to C language function: <br> <code> void* clGetExtensionFunctionAddress(const char * fname); </code> */ - private static native long dispatch_clGetExtensionFunctionAddressStatic(String fname, long procAddress); - diff --git a/make/config/clImplCustomCode12.c b/make/config/clImplCustomCode12.c index bea531a1..6bdae621 100644 --- a/make/config/clImplCustomCode12.c +++ b/make/config/clImplCustomCode12.c @@ -1,224 +1,28 @@ -// callbacks -typedef void (CL_CALLBACK * cccallback)(const char *, const void *, size_t, void *); -typedef void (CL_CALLBACK * bpcallback)(cl_program, void *); - -CL_CALLBACK void buildProgramCallback(cl_program id, void * object); -CL_CALLBACK void createContextCallback(const char * errinfo, const void * private_info, size_t cb, void * object); -CL_CALLBACK void eventCallback(cl_event event, cl_int status, void * object); -CL_CALLBACK void memObjDestructorCallback(cl_mem mem, void * object); - JNIEXPORT jlong JNICALL -Java_com_jogamp_opencl_llb_impl_CLAbstractImpl12_dispatch_1clGetExtensionFunctionAddressStatic(JNIEnv *env, jclass _unused, jstring fname, jlong procAddress) { - typedef void* (CL_API_CALL * _local_LPCLGETPROCADDRESS)(const char * fname); - _local_LPCLGETPROCADDRESS ptr_clGetExtensionFunctionAddress; - const char* _strchars_fname = NULL; - void* _res; - if ( NULL != fname ) { - _strchars_fname = (*env)->GetStringUTFChars(env, fname, (jboolean*)NULL); - if ( NULL == _strchars_fname ) { - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"), - "Failed to get UTF-8 chars for argument \"fname\" in native dispatcher for \"dispatch_clGetExtensionFunctionAddress\""); - return 0; - } - } - ptr_clGetExtensionFunctionAddress = (_local_LPCLGETPROCADDRESS) (intptr_t) procAddress; - assert(ptr_clGetExtensionFunctionAddress != NULL); - _res = (* ptr_clGetExtensionFunctionAddress) (_strchars_fname); - if ( NULL != fname ) { - (*env)->ReleaseStringUTFChars(env, fname, _strchars_fname); - } - return (jlong) (intptr_t) _res; +Java_com_jogamp_opencl_llb_impl_CLImpl12_dispatch_1clGetExtensionFunctionAddressStatic(JNIEnv *env, jclass _unused, jstring fname, jlong procAddress) { + return Java_com_jogamp_opencl_llb_impl_CLImpl11_dispatch_1clGetExtensionFunctionAddressStatic(env, _unused, fname, procAddress); } -/* Java->C glue code: - * Java package: com.jogamp.opencl.impl.CLImpl - * Java method: long clCreateContextFromType(java.nio.IntBuffer props, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret) - * C function: cl_context clCreateContextFromType( const cl_context_properties * properties , - * cl_device_type device_type , - * void (CL_CALLBACK * pfn_notify )(const char *, const void *, size_t, void *), - * void * user_data , - * cl_int * errcode_ret); - */ JNIEXPORT jlong JNICALL -Java_com_jogamp_opencl_llb_impl_CLImpl12_clCreateContextFromType0(JNIEnv *env, jobject _unused, - jobject props, jint props_byte_offset, jlong device_type, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset, jlong procAddress) { - - cl_context_properties* _props_ptr = NULL; - cl_int * _errcode_ptr = NULL; - cl_context _ctx = NULL; - cccallback _pfn_notify = NULL; - jobject globalCB = NULL; - - typedef cl_context (*function)(const cl_context_properties *, cl_device_type, void (*pfn_notify)(const char *, const void *, size_t, void *), void *, cl_int *); - function clCreateContextFromType = (function)(intptr_t) procAddress; - - if (props != NULL) { - _props_ptr = (cl_context_properties*) (((char*) (*env)->GetDirectBufferAddress(env, props)) + props_byte_offset); - } - - if (errcode != NULL) { - _errcode_ptr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, errcode)) + errcode_byte_offset); - } - - if (cb != NULL) { - _pfn_notify = &createContextCallback; - globalCB = (*env)->NewGlobalRef(env, cb); - } - - _ctx = (*clCreateContextFromType)(_props_ptr, (uint64_t) device_type, _pfn_notify, globalCB, _errcode_ptr); - - if(globalCB != NULL) { - jlong *g = (*env)->GetPrimitiveArrayCritical(env, global, NULL); - // if something went wrong - if(_ctx == NULL) { - g[0] = 0; - (*env)->DeleteGlobalRef(env, globalCB); - }else{ - g[0] = (jlong)globalCB; - } - (*env)->ReleasePrimitiveArrayCritical(env, global, g, 0); - } - - return (jlong) (intptr_t)_ctx; +Java_com_jogamp_opencl_llb_impl_CLImpl12_clCreateContextFromType0(JNIEnv *env, jobject _unused, jobject props, jint props_byte_offset, jlong device_type, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset, jlong procAddress) { + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clCreateContextFromType0(env, _unused, props, props_byte_offset, device_type, cb, global, errcode, errcode_byte_offset, procAddress); } -/* - * Entry point to C language function: - *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 , - * cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0; - */ JNIEXPORT jlong JNICALL -Java_com_jogamp_opencl_llb_impl_CLImpl12_clCreateContext0(JNIEnv *env, jobject _unused, - jobject props, jint props_byte_offset, jint numDevices, jobject deviceList, jint device_type_offset, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset, jlong procAddress) { - - cl_context_properties* _props_ptr = NULL; - cl_int * _errcode_ptr = NULL; - cl_device_id * _deviceListPtr = NULL; - cl_context _ctx = NULL; - cccallback _pfn_notify = NULL; - jobject globalCB = NULL; - - typedef cl_context (CL_API_CALL * function)(cl_context_properties *, cl_uint, const cl_device_id *, void (*pfn_notify)(const char *, const void *, size_t, void *), void *, cl_int *); - function clCreateContext = (function)(intptr_t) procAddress; - - if (props != NULL) { - _props_ptr = (cl_context_properties*) (((char*) (*env)->GetDirectBufferAddress(env, props)) + props_byte_offset); - } - if (deviceList != NULL) { - _deviceListPtr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, deviceList)) + device_type_offset); - } - if (errcode != NULL) { - _errcode_ptr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, errcode)) + errcode_byte_offset); - } - - if (cb != NULL) { - _pfn_notify = &createContextCallback; - globalCB = (*env)->NewGlobalRef(env, cb); - } - - _ctx = (*clCreateContext)(_props_ptr, numDevices, _deviceListPtr, _pfn_notify, globalCB, _errcode_ptr); - - if(globalCB != NULL) { - jlong *g = (*env)->GetPrimitiveArrayCritical(env, global, NULL); - // if something went wrong - if(_ctx == NULL) { - g[0] = 0; - (*env)->DeleteGlobalRef(env, globalCB); - }else{ - g[0] = (jlong)globalCB; - } - (*env)->ReleasePrimitiveArrayCritical(env, global, g, 0); - } - - return (jlong) (intptr_t)_ctx; +Java_com_jogamp_opencl_llb_impl_CLImpl12_clCreateContext0(JNIEnv *env, jobject _unused, jobject props, jint props_byte_offset, jint numDevices, jobject deviceList, jint device_type_offset, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset, jlong procAddress) { + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clCreateContext0(env, _unused, props, props_byte_offset, numDevices, deviceList, device_type_offset, cb, global, errcode, errcode_byte_offset, procAddress); } -/* Java->C glue code: - * Java package: com.jogamp.opencl.impl.CLImpl - * Java method: int clReleaseContextImpl(long context) - * C function: int32_t clReleaseContextImpl(cl_context context); - */ JNIEXPORT jint JNICALL Java_com_jogamp_opencl_llb_impl_CLImpl12_clReleaseContextImpl(JNIEnv *env, jobject _unused, jlong context, jlong global, jlong procAddress) { - - int32_t _res; - typedef int32_t (*function)(cl_context); - function clReleaseContext = (function)(intptr_t) procAddress; - - _res = (*clReleaseContext)((cl_context) (intptr_t) context); - // TODO deal with retains - if (global != 0) { - (*env)->DeleteGlobalRef(env, (jobject) global); - } - return _res; + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clReleaseContextImpl(env, _unused, context, global, procAddress); } - -/** - * Entry point to C language function: - * extern CL_API_ENTRY cl_int CL_API_CALL - *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 * user_data ) CL_API_SUFFIX__VERSION_1_0; - */ JNIEXPORT jint JNICALL -Java_com_jogamp_opencl_llb_impl_CLImpl12_clBuildProgram0(JNIEnv *env, jobject _unused, - jlong program, jint deviceCount, jobject deviceList, jint device_type_offset, jstring options, jobject cb, jlong procAddress) { - - const char* _strchars_options = NULL; - cl_int _res; - cl_device_id * _deviceListPtr = NULL; - bpcallback _pfn_notify = NULL; - jobject globalCB = NULL; - - typedef cl_int (CL_API_CALL * function)(cl_program, cl_uint, const cl_device_id *, const char *, void (CL_CALLBACK *)(cl_program, void *), void *); - function clBuildProgram = (function)(intptr_t)procAddress; - - if (options != NULL) { - _strchars_options = (*env)->GetStringUTFChars(env, options, (jboolean*)NULL); - if (_strchars_options == NULL) { - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"), - "Failed to get UTF-8 chars for argument \"options\" in native dispatcher for \"clBuildProgram\""); - return CL_FALSE; - } - } - - if (deviceList != NULL) { - _deviceListPtr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, deviceList)) + device_type_offset); - } - - if (cb != NULL) { - _pfn_notify = &buildProgramCallback; - globalCB = (*env)->NewGlobalRef(env, cb); - } - - _res = (*clBuildProgram)((cl_program)(intptr_t)program, (cl_uint)deviceCount, (cl_device_id *)_deviceListPtr, _strchars_options, _pfn_notify, globalCB); - - // if something went wrong - if(_res != CL_SUCCESS && globalCB != NULL) { - (*env)->DeleteGlobalRef(env, globalCB); - } - - if (options != NULL) { - (*env)->ReleaseStringUTFChars(env, options, _strchars_options); - } - - return (jint)_res; +Java_com_jogamp_opencl_llb_impl_CLImpl12_clBuildProgram0(JNIEnv *env, jobject _unused, jlong program, jint deviceCount, jobject deviceList, jint device_type_offset, jstring options, jobject cb, jlong procAddress) { + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clBuildProgram0(env, _unused, program, deviceCount, deviceList, device_type_offset, options, cb, procAddress); } -/* Java->C glue code: - * Java package: com.jogamp.opencl.impl.CLImpl - * Java method: java.nio.ByteBuffer clEnqueueMapImage(long command_queue, long image, int blocking_map, long map_flags, com.jogamp.gluegen.common.nio.PointerBuffer origin, com.jogamp.gluegen.common.nio.PointerBuffer range, com.jogamp.gluegen.common.nio.PointerBuffer image_row_pitch, com.jogamp.gluegen.common.nio.PointerBuffer image_slice_pitch, int num_events_in_wait_list, com.jogamp.gluegen.common.nio.PointerBuffer event_wait_list, com.jogamp.gluegen.common.nio.PointerBuffer event, java.nio.IntBuffer errcode_ret) - * C function: void * clEnqueueMapImage(cl_command_queue command_queue, cl_mem image, uint32_t blocking_map, uint64_t map_flags, const size_t * , const size_t * , size_t * image_row_pitch, size_t * image_slice_pitch, uint32_t num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, int32_t * errcode_ret); - */ JNIEXPORT jobject JNICALL Java_com_jogamp_opencl_llb_impl_CLImpl12_clEnqueueMapImage0__JJIJLjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2IILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2I(JNIEnv *env, jobject _unused, jlong command_queue, jlong image, jint blocking_map, jlong map_flags, @@ -227,102 +31,21 @@ Java_com_jogamp_opencl_llb_impl_CLImpl12_clEnqueueMapImage0__JJIJLjava_lang_Obje jint image_slice_pitch_byte_offset, jint num_events_in_wait_list, jobject event_wait_list, jint event_wait_list_byte_offset, jobject event, jint event_byte_offset, jobject errcode_ret, jint errcode_ret_byte_offset, jlong imageInfoAddress, jlong mapImageAddress) { - - size_t * _origin_ptr = NULL; - size_t * _range_ptr = NULL; - size_t * _image_row_pitch_ptr = NULL; - size_t * _image_slice_pitch_ptr = NULL; - cl_event * _event_wait_list_ptr = NULL; - cl_event * _event_ptr = NULL; - int32_t * _errcode_ret_ptr = NULL; - size_t * elements = NULL; - size_t * depth = NULL; - size_t pixels; - cl_int status; - - typedef int32_t (*imageInfoFunctionType)(cl_mem, uint32_t, size_t, void *, size_t *); - imageInfoFunctionType clGetImageInfo = (imageInfoFunctionType)(intptr_t)imageInfoAddress; - - typedef void* (*mapInfoFunctionType)(cl_command_queue, cl_mem, uint32_t, uint64_t, const size_t *, - const size_t *, size_t *, size_t *, uint32_t, cl_event *, cl_event *, int32_t *); - mapInfoFunctionType clEnqueueMapImage = (mapInfoFunctionType)(intptr_t)mapImageAddress; - - void * _res; - - if (origin != NULL) { - _origin_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, origin)) + origin_byte_offset); - } - if (range != NULL) { - _range_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, range)) + range_byte_offset); - } - if (image_row_pitch != NULL) { - _image_row_pitch_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, image_row_pitch)) + image_row_pitch_byte_offset); - } - if (image_slice_pitch != NULL) { - _image_slice_pitch_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, image_slice_pitch)) + image_slice_pitch_byte_offset); - } - if (event_wait_list != NULL) { - _event_wait_list_ptr = (cl_event *) (((char*) (*env)->GetDirectBufferAddress(env, event_wait_list)) + event_wait_list_byte_offset); - } - if (event != NULL) { - _event_ptr = (cl_event *) (((char*) (*env)->GetDirectBufferAddress(env, event)) + event_byte_offset); - } - if (errcode_ret != NULL) { - _errcode_ret_ptr = (int32_t *) (((char*) (*env)->GetDirectBufferAddress(env, errcode_ret)) + errcode_ret_byte_offset); - } - - _res = (*clEnqueueMapImage)((cl_command_queue) (intptr_t) command_queue, (cl_mem) (intptr_t) image, - (uint32_t) blocking_map, (uint64_t) map_flags, (size_t *) _origin_ptr, (size_t *) _range_ptr, - (size_t *) _image_row_pitch_ptr, (size_t *) _image_slice_pitch_ptr, (uint32_t) num_events_in_wait_list, - (cl_event *) _event_wait_list_ptr, (cl_event *) _event_ptr, (int32_t *) _errcode_ret_ptr); - if (_res == NULL) return NULL; - - // calculate buffer size - status = (*clGetImageInfo)((cl_mem) (intptr_t) image, CL_IMAGE_ELEMENT_SIZE, sizeof(size_t), (void *) elements, NULL); - status |= (*clGetImageInfo)((cl_mem) (intptr_t) image, CL_IMAGE_DEPTH, sizeof(size_t), (void *) depth, NULL); - - if(status != CL_SUCCESS) { - return NULL; - } - - if(*depth == 0) { // 2D - pixels = (*_image_row_pitch_ptr) * _range_ptr[1] + _range_ptr[0]; - }else{ // 3D - pixels = (*_image_slice_pitch_ptr) * _range_ptr[2] - + (*_image_row_pitch_ptr) * _range_ptr[1] + _range_ptr[0]; - } - - return (*env)->NewDirectByteBuffer(env, _res, pixels * (*elements)); - + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clEnqueueMapImage0__JJIJLjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2IILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2I(env, _unused, + command_queue, image, blocking_map, map_flags, + origin, origin_byte_offset, range, range_byte_offset, + image_row_pitch, image_row_pitch_byte_offset, image_slice_pitch, + image_slice_pitch_byte_offset, num_events_in_wait_list, event_wait_list, + event_wait_list_byte_offset, event, event_byte_offset, errcode_ret, errcode_ret_byte_offset, + imageInfoAddress, mapImageAddress); } JNIEXPORT jint JNICALL -Java_com_jogamp_opencl_llb_impl_CLImpl12_clSetEventCallback0(JNIEnv *env, jobject _unused, - jlong event, jint trigger, jobject listener, jlong procAddress) { - - cl_event _event = (cl_event)event; - cl_int _trigger = trigger; - cl_int _res; - typedef int32_t (*function)(cl_event, cl_int, void (*pfn_event_notify) (cl_event, cl_int, void *), void *); - function clSetEventCallback = (function)(intptr_t) procAddress; - - jobject cb = (*env)->NewGlobalRef(env, listener); - _res = (*clSetEventCallback)(_event, _trigger, &eventCallback, cb); - - return _res; +Java_com_jogamp_opencl_llb_impl_CLImpl12_clSetEventCallback0(JNIEnv *env, jobject _unused, jlong event, jint trigger, jobject listener, jlong procAddress) { + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clSetEventCallback0(env, _unused, event, trigger, listener, procAddress); } JNIEXPORT jint JNICALL -Java_com_jogamp_opencl_llb_impl_CLImpl12_clSetMemObjectDestructorCallback0(JNIEnv *env, jobject _unused, - jlong mem, jobject listener, jlong procAddress) { - - cl_mem _mem = (cl_mem)mem; - cl_int _res; - typedef int32_t (*function)(cl_mem, void (*pfn_event_notify) (cl_mem, void *), void *); - function clSetMemObjectDestructorCallback = (function)(intptr_t) procAddress; - - jobject cb = (*env)->NewGlobalRef(env, listener); - _res = (*clSetMemObjectDestructorCallback)(_mem, &memObjDestructorCallback, cb); - - return _res; +Java_com_jogamp_opencl_llb_impl_CLImpl12_clSetMemObjectDestructorCallback0(JNIEnv *env, jobject _unused, jlong mem, jobject listener, jlong procAddress) { + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clSetMemObjectDestructorCallback0(env, _unused, mem, listener, procAddress); } diff --git a/make/config/clImplCustomCode12.java b/make/config/clImplCustomCode12.java index ff29d5e5..3181749d 100644 --- a/make/config/clImplCustomCode12.java +++ b/make/config/clImplCustomCode12.java @@ -1,60 +1,12 @@ - /** If null, OpenCL is not available on this machine. */ - static final DynamicLibraryBundle dynamicLookupHelper; protected static final CLProcAddressTable12 addressTable; static { addressTable = new CLProcAddressTable12(); - dynamicLookupHelper = AccessController.doPrivileged(new PrivilegedAction<DynamicLibraryBundle>() { - public DynamicLibraryBundle run() { - final DynamicLibraryBundle bundle = new DynamicLibraryBundle(new CLDynamicLibraryBundleInfo()); - if(!bundle.isToolLibLoaded()) { - // couldn't load native CL library - // TODO: log this? - return null; - } - if(!bundle.isLibComplete()) { - System.err.println("Couln't load native CL/JNI glue library"); - return null; - } - addressTable.reset(bundle); - /** Not required nor forced - if( !initializeImpl() ) { - System.err.println("Native initialization failure of CL/JNI glue library"); - return null; - } */ - return bundle; - } } ); } - /** - * Accessor. - * @returns true if OpenCL is available on this machine. - */ - public static boolean isAvailable() { return dynamicLookupHelper != null; } - public static CLProcAddressTable12 getCLProcAddressTable() { return addressTable; } + public static CLProcAddressTable12 getAddressTable() { return addressTable; } - static long clGetExtensionFunctionAddress(long clGetExtensionFunctionAddressHandle, java.lang.String procname) - { - if (clGetExtensionFunctionAddressHandle == 0) { - throw new RuntimeException("Passed null pointer for method \"clGetExtensionFunctionAddress\""); - } - return dispatch_clGetExtensionFunctionAddressStatic(procname, clGetExtensionFunctionAddressHandle); + public CLImpl12() { + init(); } - - public CLAbstractImpl12() { - } - - /** Entry point (through function pointer) to C language function: <br> <code> void* clGetExtensionFunctionAddress(const char * fname); </code> */ - long clGetExtensionFunctionAddress(String fname) { - - final long __addr_ = addressTable._addressof_clGetExtensionFunctionAddress; - if (__addr_ == 0) { - throw new UnsupportedOperationException("Method \"clGetExtensionFunctionAddress\" not available"); - } - return dispatch_clGetExtensionFunctionAddressStatic(fname, __addr_); - } - - /** Entry point (through function pointer) to C language function: <br> <code> void* clGetExtensionFunctionAddress(const char * fname); </code> */ - private static native long dispatch_clGetExtensionFunctionAddressStatic(String fname, long procAddress); - diff --git a/make/config/clImplCustomCode20.c b/make/config/clImplCustomCode20.c index 065aad31..897faec6 100644 --- a/make/config/clImplCustomCode20.c +++ b/make/config/clImplCustomCode20.c @@ -1,224 +1,28 @@ -// callbacks -typedef void (CL_CALLBACK * cccallback)(const char *, const void *, size_t, void *); -typedef void (CL_CALLBACK * bpcallback)(cl_program, void *); - -CL_CALLBACK void buildProgramCallback(cl_program id, void * object); -CL_CALLBACK void createContextCallback(const char * errinfo, const void * private_info, size_t cb, void * object); -CL_CALLBACK void eventCallback(cl_event event, cl_int status, void * object); -CL_CALLBACK void memObjDestructorCallback(cl_mem mem, void * object); - JNIEXPORT jlong JNICALL -Java_com_jogamp_opencl_llb_impl_CLAbstractImpl20_dispatch_1clGetExtensionFunctionAddressStatic(JNIEnv *env, jclass _unused, jstring fname, jlong procAddress) { - typedef void* (CL_API_CALL * _local_LPCLGETPROCADDRESS)(const char * fname); - _local_LPCLGETPROCADDRESS ptr_clGetExtensionFunctionAddress; - const char* _strchars_fname = NULL; - void* _res; - if ( NULL != fname ) { - _strchars_fname = (*env)->GetStringUTFChars(env, fname, (jboolean*)NULL); - if ( NULL == _strchars_fname ) { - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"), - "Failed to get UTF-8 chars for argument \"fname\" in native dispatcher for \"dispatch_clGetExtensionFunctionAddress\""); - return 0; - } - } - ptr_clGetExtensionFunctionAddress = (_local_LPCLGETPROCADDRESS) (intptr_t) procAddress; - assert(ptr_clGetExtensionFunctionAddress != NULL); - _res = (* ptr_clGetExtensionFunctionAddress) (_strchars_fname); - if ( NULL != fname ) { - (*env)->ReleaseStringUTFChars(env, fname, _strchars_fname); - } - return (jlong) (intptr_t) _res; +Java_com_jogamp_opencl_llb_impl_CLImpl20_dispatch_1clGetExtensionFunctionAddressStatic(JNIEnv *env, jclass _unused, jstring fname, jlong procAddress) { + return Java_com_jogamp_opencl_llb_impl_CLImpl11_dispatch_1clGetExtensionFunctionAddressStatic(env, _unused, fname, procAddress); } -/* Java->C glue code: - * Java package: com.jogamp.opencl.impl.CLImpl - * Java method: long clCreateContextFromType(java.nio.IntBuffer props, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret) - * C function: cl_context clCreateContextFromType( const cl_context_properties * properties , - * cl_device_type device_type , - * void (CL_CALLBACK * pfn_notify )(const char *, const void *, size_t, void *), - * void * user_data , - * cl_int * errcode_ret); - */ JNIEXPORT jlong JNICALL -Java_com_jogamp_opencl_llb_impl_CLImpl20_clCreateContextFromType0(JNIEnv *env, jobject _unused, - jobject props, jint props_byte_offset, jlong device_type, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset, jlong procAddress) { - - cl_context_properties* _props_ptr = NULL; - cl_int * _errcode_ptr = NULL; - cl_context _ctx = NULL; - cccallback _pfn_notify = NULL; - jobject globalCB = NULL; - - typedef cl_context (*function)(const cl_context_properties *, cl_device_type, void (*pfn_notify)(const char *, const void *, size_t, void *), void *, cl_int *); - function clCreateContextFromType = (function)(intptr_t) procAddress; - - if (props != NULL) { - _props_ptr = (cl_context_properties*) (((char*) (*env)->GetDirectBufferAddress(env, props)) + props_byte_offset); - } - - if (errcode != NULL) { - _errcode_ptr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, errcode)) + errcode_byte_offset); - } - - if (cb != NULL) { - _pfn_notify = &createContextCallback; - globalCB = (*env)->NewGlobalRef(env, cb); - } - - _ctx = (*clCreateContextFromType)(_props_ptr, (uint64_t) device_type, _pfn_notify, globalCB, _errcode_ptr); - - if(globalCB != NULL) { - jlong *g = (*env)->GetPrimitiveArrayCritical(env, global, NULL); - // if something went wrong - if(_ctx == NULL) { - g[0] = 0; - (*env)->DeleteGlobalRef(env, globalCB); - }else{ - g[0] = (jlong)globalCB; - } - (*env)->ReleasePrimitiveArrayCritical(env, global, g, 0); - } - - return (jlong) (intptr_t)_ctx; +Java_com_jogamp_opencl_llb_impl_CLImpl20_clCreateContextFromType0(JNIEnv *env, jobject _unused, jobject props, jint props_byte_offset, jlong device_type, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset, jlong procAddress) { + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clCreateContextFromType0(env, _unused, props, props_byte_offset, device_type, cb, global, errcode, errcode_byte_offset, procAddress); } -/* - * Entry point to C language function: - *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 , - * cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0; - */ JNIEXPORT jlong JNICALL -Java_com_jogamp_opencl_llb_impl_CLImpl20_clCreateContext0(JNIEnv *env, jobject _unused, - jobject props, jint props_byte_offset, jint numDevices, jobject deviceList, jint device_type_offset, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset, jlong procAddress) { - - cl_context_properties* _props_ptr = NULL; - cl_int * _errcode_ptr = NULL; - cl_device_id * _deviceListPtr = NULL; - cl_context _ctx = NULL; - cccallback _pfn_notify = NULL; - jobject globalCB = NULL; - - typedef cl_context (CL_API_CALL * function)(cl_context_properties *, cl_uint, const cl_device_id *, void (*pfn_notify)(const char *, const void *, size_t, void *), void *, cl_int *); - function clCreateContext = (function)(intptr_t) procAddress; - - if (props != NULL) { - _props_ptr = (cl_context_properties*) (((char*) (*env)->GetDirectBufferAddress(env, props)) + props_byte_offset); - } - if (deviceList != NULL) { - _deviceListPtr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, deviceList)) + device_type_offset); - } - if (errcode != NULL) { - _errcode_ptr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, errcode)) + errcode_byte_offset); - } - - if (cb != NULL) { - _pfn_notify = &createContextCallback; - globalCB = (*env)->NewGlobalRef(env, cb); - } - - _ctx = (*clCreateContext)(_props_ptr, numDevices, _deviceListPtr, _pfn_notify, globalCB, _errcode_ptr); - - if(globalCB != NULL) { - jlong *g = (*env)->GetPrimitiveArrayCritical(env, global, NULL); - // if something went wrong - if(_ctx == NULL) { - g[0] = 0; - (*env)->DeleteGlobalRef(env, globalCB); - }else{ - g[0] = (jlong)globalCB; - } - (*env)->ReleasePrimitiveArrayCritical(env, global, g, 0); - } - - return (jlong) (intptr_t)_ctx; +Java_com_jogamp_opencl_llb_impl_CLImpl20_clCreateContext0(JNIEnv *env, jobject _unused, jobject props, jint props_byte_offset, jint numDevices, jobject deviceList, jint device_type_offset, jobject cb, jobject global, jobject errcode, jint errcode_byte_offset, jlong procAddress) { + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clCreateContext0(env, _unused, props, props_byte_offset, numDevices, deviceList, device_type_offset, cb, global, errcode, errcode_byte_offset, procAddress); } -/* Java->C glue code: - * Java package: com.jogamp.opencl.impl.CLImpl - * Java method: int clReleaseContextImpl(long context) - * C function: int32_t clReleaseContextImpl(cl_context context); - */ JNIEXPORT jint JNICALL Java_com_jogamp_opencl_llb_impl_CLImpl20_clReleaseContextImpl(JNIEnv *env, jobject _unused, jlong context, jlong global, jlong procAddress) { - - int32_t _res; - typedef int32_t (*function)(cl_context); - function clReleaseContext = (function)(intptr_t) procAddress; - - _res = (*clReleaseContext)((cl_context) (intptr_t) context); - // TODO deal with retains - if (global != 0) { - (*env)->DeleteGlobalRef(env, (jobject) global); - } - return _res; + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clReleaseContextImpl(env, _unused, context, global, procAddress); } - -/** - * Entry point to C language function: - * extern CL_API_ENTRY cl_int CL_API_CALL - *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 * user_data ) CL_API_SUFFIX__VERSION_1_0; - */ JNIEXPORT jint JNICALL -Java_com_jogamp_opencl_llb_impl_CLImpl20_clBuildProgram0(JNIEnv *env, jobject _unused, - jlong program, jint deviceCount, jobject deviceList, jint device_type_offset, jstring options, jobject cb, jlong procAddress) { - - const char* _strchars_options = NULL; - cl_int _res; - cl_device_id * _deviceListPtr = NULL; - bpcallback _pfn_notify = NULL; - jobject globalCB = NULL; - - typedef cl_int (CL_API_CALL * function)(cl_program, cl_uint, const cl_device_id *, const char *, void (CL_CALLBACK *)(cl_program, void *), void *); - function clBuildProgram = (function)(intptr_t)procAddress; - - if (options != NULL) { - _strchars_options = (*env)->GetStringUTFChars(env, options, (jboolean*)NULL); - if (_strchars_options == NULL) { - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/OutOfMemoryError"), - "Failed to get UTF-8 chars for argument \"options\" in native dispatcher for \"clBuildProgram\""); - return CL_FALSE; - } - } - - if (deviceList != NULL) { - _deviceListPtr = (void *) (((char*) (*env)->GetDirectBufferAddress(env, deviceList)) + device_type_offset); - } - - if (cb != NULL) { - _pfn_notify = &buildProgramCallback; - globalCB = (*env)->NewGlobalRef(env, cb); - } - - _res = (*clBuildProgram)((cl_program)(intptr_t)program, (cl_uint)deviceCount, (cl_device_id *)_deviceListPtr, _strchars_options, _pfn_notify, globalCB); - - // if something went wrong - if(_res != CL_SUCCESS && globalCB != NULL) { - (*env)->DeleteGlobalRef(env, globalCB); - } - - if (options != NULL) { - (*env)->ReleaseStringUTFChars(env, options, _strchars_options); - } - - return (jint)_res; +Java_com_jogamp_opencl_llb_impl_CLImpl20_clBuildProgram0(JNIEnv *env, jobject _unused, jlong program, jint deviceCount, jobject deviceList, jint device_type_offset, jstring options, jobject cb, jlong procAddress) { + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clBuildProgram0(env, _unused, program, deviceCount, deviceList, device_type_offset, options, cb, procAddress); } -/* Java->C glue code: - * Java package: com.jogamp.opencl.impl.CLImpl - * Java method: java.nio.ByteBuffer clEnqueueMapImage(long command_queue, long image, int blocking_map, long map_flags, com.jogamp.gluegen.common.nio.PointerBuffer origin, com.jogamp.gluegen.common.nio.PointerBuffer range, com.jogamp.gluegen.common.nio.PointerBuffer image_row_pitch, com.jogamp.gluegen.common.nio.PointerBuffer image_slice_pitch, int num_events_in_wait_list, com.jogamp.gluegen.common.nio.PointerBuffer event_wait_list, com.jogamp.gluegen.common.nio.PointerBuffer event, java.nio.IntBuffer errcode_ret) - * C function: void * clEnqueueMapImage(cl_command_queue command_queue, cl_mem image, uint32_t blocking_map, uint64_t map_flags, const size_t * , const size_t * , size_t * image_row_pitch, size_t * image_slice_pitch, uint32_t num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, int32_t * errcode_ret); - */ JNIEXPORT jobject JNICALL Java_com_jogamp_opencl_llb_impl_CLImpl20_clEnqueueMapImage0__JJIJLjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2IILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2I(JNIEnv *env, jobject _unused, jlong command_queue, jlong image, jint blocking_map, jlong map_flags, @@ -227,102 +31,21 @@ Java_com_jogamp_opencl_llb_impl_CLImpl20_clEnqueueMapImage0__JJIJLjava_lang_Obje jint image_slice_pitch_byte_offset, jint num_events_in_wait_list, jobject event_wait_list, jint event_wait_list_byte_offset, jobject event, jint event_byte_offset, jobject errcode_ret, jint errcode_ret_byte_offset, jlong imageInfoAddress, jlong mapImageAddress) { - - size_t * _origin_ptr = NULL; - size_t * _range_ptr = NULL; - size_t * _image_row_pitch_ptr = NULL; - size_t * _image_slice_pitch_ptr = NULL; - cl_event * _event_wait_list_ptr = NULL; - cl_event * _event_ptr = NULL; - int32_t * _errcode_ret_ptr = NULL; - size_t * elements = NULL; - size_t * depth = NULL; - size_t pixels; - cl_int status; - - typedef int32_t (*imageInfoFunctionType)(cl_mem, uint32_t, size_t, void *, size_t *); - imageInfoFunctionType clGetImageInfo = (imageInfoFunctionType)(intptr_t)imageInfoAddress; - - typedef void* (*mapInfoFunctionType)(cl_command_queue, cl_mem, uint32_t, uint64_t, const size_t *, - const size_t *, size_t *, size_t *, uint32_t, cl_event *, cl_event *, int32_t *); - mapInfoFunctionType clEnqueueMapImage = (mapInfoFunctionType)(intptr_t)mapImageAddress; - - void * _res; - - if (origin != NULL) { - _origin_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, origin)) + origin_byte_offset); - } - if (range != NULL) { - _range_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, range)) + range_byte_offset); - } - if (image_row_pitch != NULL) { - _image_row_pitch_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, image_row_pitch)) + image_row_pitch_byte_offset); - } - if (image_slice_pitch != NULL) { - _image_slice_pitch_ptr = (size_t *) (((char*) (*env)->GetDirectBufferAddress(env, image_slice_pitch)) + image_slice_pitch_byte_offset); - } - if (event_wait_list != NULL) { - _event_wait_list_ptr = (cl_event *) (((char*) (*env)->GetDirectBufferAddress(env, event_wait_list)) + event_wait_list_byte_offset); - } - if (event != NULL) { - _event_ptr = (cl_event *) (((char*) (*env)->GetDirectBufferAddress(env, event)) + event_byte_offset); - } - if (errcode_ret != NULL) { - _errcode_ret_ptr = (int32_t *) (((char*) (*env)->GetDirectBufferAddress(env, errcode_ret)) + errcode_ret_byte_offset); - } - - _res = (*clEnqueueMapImage)((cl_command_queue) (intptr_t) command_queue, (cl_mem) (intptr_t) image, - (uint32_t) blocking_map, (uint64_t) map_flags, (size_t *) _origin_ptr, (size_t *) _range_ptr, - (size_t *) _image_row_pitch_ptr, (size_t *) _image_slice_pitch_ptr, (uint32_t) num_events_in_wait_list, - (cl_event *) _event_wait_list_ptr, (cl_event *) _event_ptr, (int32_t *) _errcode_ret_ptr); - if (_res == NULL) return NULL; - - // calculate buffer size - status = (*clGetImageInfo)((cl_mem) (intptr_t) image, CL_IMAGE_ELEMENT_SIZE, sizeof(size_t), (void *) elements, NULL); - status |= (*clGetImageInfo)((cl_mem) (intptr_t) image, CL_IMAGE_DEPTH, sizeof(size_t), (void *) depth, NULL); - - if(status != CL_SUCCESS) { - return NULL; - } - - if(*depth == 0) { // 2D - pixels = (*_image_row_pitch_ptr) * _range_ptr[1] + _range_ptr[0]; - }else{ // 3D - pixels = (*_image_slice_pitch_ptr) * _range_ptr[2] - + (*_image_row_pitch_ptr) * _range_ptr[1] + _range_ptr[0]; - } - - return (*env)->NewDirectByteBuffer(env, _res, pixels * (*elements)); - + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clEnqueueMapImage0__JJIJLjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2IILjava_lang_Object_2ILjava_lang_Object_2ILjava_lang_Object_2I(env, _unused, + command_queue, image, blocking_map, map_flags, + origin, origin_byte_offset, range, range_byte_offset, + image_row_pitch, image_row_pitch_byte_offset, image_slice_pitch, + image_slice_pitch_byte_offset, num_events_in_wait_list, event_wait_list, + event_wait_list_byte_offset, event, event_byte_offset, errcode_ret, errcode_ret_byte_offset, + imageInfoAddress, mapImageAddress); } JNIEXPORT jint JNICALL -Java_com_jogamp_opencl_llb_impl_CLImpl20_clSetEventCallback0(JNIEnv *env, jobject _unused, - jlong event, jint trigger, jobject listener, jlong procAddress) { - - cl_event _event = (cl_event)event; - cl_int _trigger = trigger; - cl_int _res; - typedef int32_t (*function)(cl_event, cl_int, void (*pfn_event_notify) (cl_event, cl_int, void *), void *); - function clSetEventCallback = (function)(intptr_t) procAddress; - - jobject cb = (*env)->NewGlobalRef(env, listener); - _res = (*clSetEventCallback)(_event, _trigger, &eventCallback, cb); - - return _res; +Java_com_jogamp_opencl_llb_impl_CLImpl20_clSetEventCallback0(JNIEnv *env, jobject _unused, jlong event, jint trigger, jobject listener, jlong procAddress) { + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clSetEventCallback0(env, _unused, event, trigger, listener, procAddress); } JNIEXPORT jint JNICALL -Java_com_jogamp_opencl_llb_impl_CLImpl20_clSetMemObjectDestructorCallback0(JNIEnv *env, jobject _unused, - jlong mem, jobject listener, jlong procAddress) { - - cl_mem _mem = (cl_mem)mem; - cl_int _res; - typedef int32_t (*function)(cl_mem, void (*pfn_event_notify) (cl_mem, void *), void *); - function clSetMemObjectDestructorCallback = (function)(intptr_t) procAddress; - - jobject cb = (*env)->NewGlobalRef(env, listener); - _res = (*clSetMemObjectDestructorCallback)(_mem, &memObjDestructorCallback, cb); - - return _res; +Java_com_jogamp_opencl_llb_impl_CLImpl20_clSetMemObjectDestructorCallback0(JNIEnv *env, jobject _unused, jlong mem, jobject listener, jlong procAddress) { + return Java_com_jogamp_opencl_llb_impl_CLImpl11_clSetMemObjectDestructorCallback0(env, _unused, mem, listener, procAddress); } diff --git a/make/config/clImplCustomCode20.java b/make/config/clImplCustomCode20.java index e6c8071c..6247dd6c 100644 --- a/make/config/clImplCustomCode20.java +++ b/make/config/clImplCustomCode20.java @@ -1,60 +1,12 @@ - /** If null, OpenCL is not available on this machine. */ - static final DynamicLibraryBundle dynamicLookupHelper; protected static final CLProcAddressTable20 addressTable; static { addressTable = new CLProcAddressTable20(); - dynamicLookupHelper = AccessController.doPrivileged(new PrivilegedAction<DynamicLibraryBundle>() { - public DynamicLibraryBundle run() { - final DynamicLibraryBundle bundle = new DynamicLibraryBundle(new CLDynamicLibraryBundleInfo()); - if(!bundle.isToolLibLoaded()) { - // couldn't load native CL library - // TODO: log this? - return null; - } - if(!bundle.isLibComplete()) { - System.err.println("Couln't load native CL/JNI glue library"); - return null; - } - addressTable.reset(bundle); - /** Not required nor forced - if( !initializeImpl() ) { - System.err.println("Native initialization failure of CL/JNI glue library"); - return null; - } */ - return bundle; - } } ); } - /** - * Accessor. - * @returns true if OpenCL is available on this machine. - */ - public static boolean isAvailable() { return dynamicLookupHelper != null; } - public static CLProcAddressTable20 getCLProcAddressTable() { return addressTable; } + public static CLProcAddressTable20 getAddressTable() { return addressTable; } - static long clGetExtensionFunctionAddress(long clGetExtensionFunctionAddressHandle, java.lang.String procname) - { - if (clGetExtensionFunctionAddressHandle == 0) { - throw new RuntimeException("Passed null pointer for method \"clGetExtensionFunctionAddress\""); - } - return dispatch_clGetExtensionFunctionAddressStatic(procname, clGetExtensionFunctionAddressHandle); + public CLImpl20() { + init(); } - - public CLAbstractImpl20() { - } - - /** Entry point (through function pointer) to C language function: <br> <code> void* clGetExtensionFunctionAddress(const char * fname); </code> */ - long clGetExtensionFunctionAddress(String fname) { - - final long __addr_ = addressTable._addressof_clGetExtensionFunctionAddress; - if (__addr_ == 0) { - throw new UnsupportedOperationException("Method \"clGetExtensionFunctionAddress\" not available"); - } - return dispatch_clGetExtensionFunctionAddressStatic(fname, __addr_); - } - - /** Entry point (through function pointer) to C language function: <br> <code> void* clGetExtensionFunctionAddress(const char * fname); </code> */ - private static native long dispatch_clGetExtensionFunctionAddressStatic(String fname, long procAddress); - diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java index 17fbe66f..f0faa0fb 100644 --- a/src/com/jogamp/opencl/CLPlatform.java +++ b/src/com/jogamp/opencl/CLPlatform.java @@ -46,7 +46,6 @@ import com.jogamp.opencl.llb.CLEventBinding; import com.jogamp.opencl.llb.CLMemObjBinding; import com.jogamp.opencl.spi.CLPlatformInfoAccessor; import com.jogamp.opencl.util.CLUtil; -import com.jogamp.opencl.llb.impl.CLAbstractImpl11; import com.jogamp.opencl.llb.impl.CLImpl11; import com.jogamp.opencl.spi.CLAccessorFactory; import com.jogamp.opencl.util.Filter; @@ -145,7 +144,7 @@ public class CLPlatform { * @returns true if OpenCL is available on this machine, * i.e. all native libraries could be loaded (CL and CL/JNI). */ - public static boolean isAvailable() { return CLAbstractImpl11.isAvailable(); } + public static boolean isAvailable() { return CLImpl11.isAvailable(); } /** * Eagerly initializes JOCL. Subsequent calls do nothing. @@ -176,7 +175,7 @@ public class CLPlatform { } } - if( !CLAbstractImpl11.isAvailable() ) { + if( !CLImpl11.isAvailable() ) { throw new JogampRuntimeException("JOCL is not available"); } cl = new CLImpl11(); diff --git a/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java b/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java index 709b58a3..4f3e682a 100644 --- a/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java +++ b/src/com/jogamp/opencl/llb/impl/CLDynamicLibraryBundleInfo.java @@ -143,7 +143,7 @@ public final class CLDynamicLibraryBundleInfo implements DynamicLibraryBundleInf funcName = funcName.substring(0, funcName.length() - Impl_len); } if( funcName.endsWith("KHR") || funcName.endsWith("EXT") ) { - return CLAbstractImpl11.clGetExtensionFunctionAddress(toolGetProcAddressHandle, funcName); + return CLImpl11.clGetExtensionFunctionAddress(toolGetProcAddressHandle, funcName); } return 0; // on libs .. } diff --git a/test/com/jogamp/opencl/test/util/MiscUtils.java b/test/com/jogamp/opencl/test/util/MiscUtils.java index 77f09933..2f3ed5dd 100644 --- a/test/com/jogamp/opencl/test/util/MiscUtils.java +++ b/test/com/jogamp/opencl/test/util/MiscUtils.java @@ -94,7 +94,7 @@ public class MiscUtils { * nobody makes one, not just a check that we didn't see one. * <p> * To check whether an OpenCL implementation/library has actually been loaded, - * use {@link CLAbstractImpl#isAvailable()}. + * use {@link CLImpl#isAvailable()}. * </p> */ public static final boolean isKnownOSWithoutCLImpl() { |