From e56a17d6d7780b8597c78ce50808c8da68d094b5 Mon Sep 17 00:00:00 2001 From: Wade Walker Date: Mon, 7 Sep 2015 14:46:52 -0500 Subject: Add OpenCL 1.2 and 2.0 headers and CLImpl classes Added stub includes for OpenCL 1.2 and 2.0. Added new CLImpl versions for 1.2 and 2.0 to the build, but left them unused for now. The CL bindings used by JOCL are still generated from OpenCL 1.1, so the existing Java code will be able to stay mostly unchanged in the future. --- make/config/clImplCustomCode12.java | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 make/config/clImplCustomCode12.java (limited to 'make/config/clImplCustomCode12.java') diff --git a/make/config/clImplCustomCode12.java b/make/config/clImplCustomCode12.java new file mode 100644 index 00000000..ff29d5e5 --- /dev/null +++ b/make/config/clImplCustomCode12.java @@ -0,0 +1,60 @@ + + /** 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() { + 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; } + + 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 CLAbstractImpl12() { + } + + /** Entry point (through function pointer) to C language function:
void* clGetExtensionFunctionAddress(const char * fname); */ + 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:
void* clGetExtensionFunctionAddress(const char * fname); */ + private static native long dispatch_clGetExtensionFunctionAddressStatic(String fname, long procAddress); + -- cgit v1.2.3