diff options
-rw-r--r-- | build.xml | 3 | ||||
-rw-r--r-- | resources/cl-if.cfg | 5 | ||||
-rw-r--r-- | resources/cl-impl.cfg | 1 | ||||
-rw-r--r-- | resources/clImplCustomCode.java | 4 | ||||
-rw-r--r-- | resources/includes/CL_orig/cl_ext.h | 78 | ||||
-rw-r--r-- | resources/opencl.h | 1 | ||||
-rw-r--r-- | src/com/mbien/opencl/CLContext.java | 17 | ||||
-rw-r--r-- | src/com/mbien/opencl/CLException.java | 6 | ||||
-rw-r--r-- | test/com/mbien/opencl/HighLevelBindingTest.java | 4 |
9 files changed, 103 insertions, 16 deletions
@@ -211,8 +211,9 @@ <uncomment-function-params src="${headers.orig}/cl.h" dest="${headers.dest}/cl.h"/> <uncomment-function-params src="${headers.orig}/cl_gl.h" dest="${headers.dest}/cl_gl.h"/> - <!--nothing to uncomment in cl_platform.h--> + <!--nothing to uncomment in this headers--> <copy file="${headers.orig}/cl_platform.h" toDir="${headers.dest}" overwrite="true"/> + <copy file="${headers.orig}/cl_ext.h" toDir="${headers.dest}" overwrite="true"/> </target> diff --git a/resources/cl-if.cfg b/resources/cl-if.cfg index 8a4d62d..4389854 100644 --- a/resources/cl-if.cfg +++ b/resources/cl-if.cfg @@ -4,6 +4,7 @@ Style InterfaceOnly #imports for all generated java files Import java.nio.IntBuffer +Import java.nio.LongBuffer ClassJavadoc CL /** ClassJavadoc CL * Java bindings to OpenCL, the Open Computing Language. @@ -18,12 +19,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, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret); +CustomJavaCode CL public long clCreateContext(LongBuffer 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, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret); +CustomJavaCode CL public long clCreateContextFromType(LongBuffer 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 cee848c..9dff59b 100644 --- a/resources/cl-impl.cfg +++ b/resources/cl-impl.cfg @@ -5,6 +5,7 @@ Style ImplOnly #imports for all generated java files Import com.mbien.opencl.* Import java.nio.IntBuffer +Import java.nio.LongBuffer Import java.nio.Buffer ClassJavadoc CLImpl /** diff --git a/resources/clImplCustomCode.java b/resources/clImplCustomCode.java index c368fe5..91b1fb4 100644 --- a/resources/clImplCustomCode.java +++ b/resources/clImplCustomCode.java @@ -1,5 +1,5 @@ - public long clCreateContext(IntBuffer properties, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret) { + public long clCreateContext(LongBuffer properties, long[] devices, 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."); @@ -18,7 +18,7 @@ private native long clCreateContext1(Object cl_context_properties, int props_offset, int deviceCount, long[] devices, CreateContextCallback pfn_notify, Object userData, Object errcode_ret, int err_offset); - public long clCreateContextFromType(IntBuffer properties, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret) { + public long clCreateContextFromType(LongBuffer 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."); diff --git a/resources/includes/CL_orig/cl_ext.h b/resources/includes/CL_orig/cl_ext.h new file mode 100644 index 0000000..e94be2a --- /dev/null +++ b/resources/includes/CL_orig/cl_ext.h @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2008-2009 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + ******************************************************************************/ + +#ifndef __CL_EXT_H +#define __CL_EXT_H + +#ifdef __cplusplus +extern "C" { +#endif + +// enum can be used if cl_khr_fp64 extension is supported by the OpenCL implementation. +#define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032 + +// enum can be used if cl_khr_fp16 extension is supported by the OpenCL implementation. +#define CL_DEVICE_HALF_FP_CONFIG 0x1033 + + +#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 +#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 +#define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002 +#define CL_DEVICE_WARP_SIZE_NV 0x4003 +#define CL_DEVICE_GPU_OVERLAP_NV 0x4004 +#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 +#define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006 + + +typedef cl_uint cl_gl_context_info; + +/* cl_khr_gl_sharing */ +typedef cl_int (CL_API_CALL * clGetGLContextInfoKHR_fn) + (const cl_context_properties *properties, + cl_gl_context_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); + +cl_int CL_API_CALL clGetGLContextInfoKHR(const cl_context_properties *properties, + cl_gl_context_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret); + +#define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -63 +#define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006 +#define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007 +#define CL_GL_CONTEXT_KHR 0x2008 +#define CL_EGL_DISPLAY_KHR 0x2009 +#define CL_GLX_DISPLAY_KHR 0x200A +#define CL_WGL_HDC_KHR 0x200B +#define CL_CGL_SHAREGROUP_KHR 0x200C + + +#ifdef __cplusplus +} +#endif + + +#endif /* __CL_EXT_H */ diff --git a/resources/opencl.h b/resources/opencl.h index ab05e15..d1b0c79 100644 --- a/resources/opencl.h +++ b/resources/opencl.h @@ -1,6 +1,7 @@ #include <CL/cl_platform.h> #include <CL/cl.h> +#include <CL/cl_ext.h> #ifdef _WIN32 #include <windows.h> diff --git a/src/com/mbien/opencl/CLContext.java b/src/com/mbien/opencl/CLContext.java index c87f231..2a4bd7d 100644 --- a/src/com/mbien/opencl/CLContext.java +++ b/src/com/mbien/opencl/CLContext.java @@ -11,6 +11,7 @@ import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; +import java.nio.LongBuffer; import java.util.ArrayList; import java.util.Collections; @@ -111,10 +112,10 @@ public final class CLContext { } } - IntBuffer properties = null; + LongBuffer properties = null; if(platform != null) { - properties = IntBuffer.allocate(3); - properties.put(CL.CL_CONTEXT_PLATFORM).put((int)platform.ID).put(0); // TODO check if this has to be int or long + properties = LongBuffer.allocate(3); + properties.put(CL.CL_CONTEXT_PLATFORM).put(platform.ID).put(0); // 0 terminated array properties.rewind(); } @@ -133,17 +134,17 @@ public final class CLContext { deviceIDs[i] = devices[i].ID; } - IntBuffer properties = null; + LongBuffer properties = null; if(platform != null) { - properties = IntBuffer.allocate(3); - properties.put(CL.CL_CONTEXT_PLATFORM).put((int)platform.ID).put(0); // TODO check if this has to be int or long + properties = LongBuffer.allocate(3); + properties.put(CL.CL_CONTEXT_PLATFORM).put(platform.ID).put(0); // 0 terminated array properties.rewind(); } return createContext(properties, deviceIDs); } - private static final CLContext createContextFromType(IntBuffer properties, long deviceType) { + private static final CLContext createContextFromType(LongBuffer properties, long deviceType) { IntBuffer status = IntBuffer.allocate(1); long context = CLPlatform.getLowLevelBinding().clCreateContextFromType(properties, deviceType, null, null, status); @@ -153,7 +154,7 @@ public final class CLContext { return new CLContext(context); } - private static final CLContext createContext(IntBuffer properties, long[] devices) { + private static final CLContext createContext(LongBuffer properties, long[] devices) { IntBuffer status = IntBuffer.allocate(1); long context = CLPlatform.getLowLevelBinding().clCreateContext(properties, devices, null, null, status); diff --git a/src/com/mbien/opencl/CLException.java b/src/com/mbien/opencl/CLException.java index b4a66a9..c080b16 100644 --- a/src/com/mbien/opencl/CLException.java +++ b/src/com/mbien/opencl/CLException.java @@ -167,7 +167,11 @@ public class CLException extends RuntimeException { return "CL_INVALID_MIP_LEVEL"; case CL.CL_INVALID_GLOBAL_WORK_SIZE: - return "CL_INVALID_GLOBAL_WORK_SIZE"; + return "CL_INVALID_GLOBAL_WORK_SIZE or CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR"; + +// error-code conflict with CL_INVALID_GLOBAL_WORK_SIZE +// case CL.CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR: +// return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR"; default: return "unknown cause: error " + error; diff --git a/test/com/mbien/opencl/HighLevelBindingTest.java b/test/com/mbien/opencl/HighLevelBindingTest.java index 4665c27..e871cf9 100644 --- a/test/com/mbien/opencl/HighLevelBindingTest.java +++ b/test/com/mbien/opencl/HighLevelBindingTest.java @@ -86,8 +86,8 @@ public class HighLevelBindingTest { out.println(" - - - highLevelTest; global memory kernel - - - "); -// CLPlatform[] clPlatforms = CLPlatform.listCLPlatforms(); - CLContext context = CLContext.create(/*clPlatforms[0]*/); + CLPlatform[] clPlatforms = CLPlatform.listCLPlatforms(); + CLContext context = CLContext.create(clPlatforms[0]); CLDevice[] contextDevices = context.getCLDevices(); |