summaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/clImplCustomCode.c60
-rw-r--r--resources/clImplCustomCode.java23
2 files changed, 59 insertions, 24 deletions
diff --git a/resources/clImplCustomCode.c b/resources/clImplCustomCode.c
index a35328dc..57d1c3e3 100644
--- a/resources/clImplCustomCode.c
+++ b/resources/clImplCustomCode.c
@@ -52,40 +52,64 @@ Java_com_mbien_opencl_impl_CLImpl_clCreateContextFromType1(JNIEnv *env, jobject
return (jlong)_ctx;
}
-
/*
+ * 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_mbien_opencl_impl_CLImpl_clCreateContext0(JNIEnv *env, jobject _unused,
- jobject props, jint props_byte_offset, jlong device_type, jobject cb, jobject data, jobject errcode, jint errcode_byte_offset) {
+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;
int32_t * _errcode_ptr = NULL;
- void * _device_ptr = NULL;
+ size_t * _deviceListPtr = NULL;
- cl_context _res;
+ cl_context _ctx;
if (props != NULL) {
- _props_ptr = (intptr_t *) (((char*) (*env)->GetDirectBufferAddress(env, props)) + props_byte_offset);
+ _props_ptr = (void *) (((char*) (*env)->GetPrimitiveArrayCritical(env, props, NULL)) + props_byte_offset);
+ }
+ if (deviceList != NULL) {
+ _deviceListPtr = (void *) (((char*) (*env)->GetPrimitiveArrayCritical(env, deviceList, NULL)) /*+ device_byte_offset*/);
+ }
+ if (errcode != NULL) {
+ _errcode_ptr = (void *) (((char*) (*env)->GetPrimitiveArrayCritical(env, errcode, NULL)) + errcode_byte_offset);
}
- if (device_type != NULL) {
- _device_ptr = (void *) (((char*) (*env)->GetPrimitiveArrayCritical(env, device_type, NULL)));
- }
+ // TODO payload, callback...
+ _ctx = clCreateContext((cl_context_properties *) _props_ptr, numDevices, (cl_device_id *)_deviceListPtr, NULL, NULL, (int32_t *) _errcode_ptr);
- _res = clCreateContext();
+ if (errcode != NULL) {
+ (*env)->ReleasePrimitiveArrayCritical(env, errcode, _errcode_ptr, 0);
+ }
+ if (deviceList != NULL) {
+ (*env)->ReleasePrimitiveArrayCritical(env, deviceList, _deviceListPtr, 0);
+ }
+ if (props != NULL) {
+ (*env)->ReleasePrimitiveArrayCritical(env, props, _props_ptr, 0);
+ }
- if (device_type != NULL) {
- (*env)->ReleasePrimitiveArrayCritical(env, device_type, _device_ptr, 0);
- }
- return (jlong) (intptr_t) _res;
+ return (jlong) _ctx;
}
-*/
/**
- * Entry point to C language function: <code> int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void (*pfn_notify)(cl_program, void *user_data), void * );
+ * 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_mbien_opencl_impl_CLImpl_clBuildProgram0(JNIEnv *env, jobject _unused,
+Java_com_mbien_opencl_impl_CLImpl_clBuildProgram1(JNIEnv *env, jobject _unused,
jlong program, jint deviceCount, jobject deviceList, jint offset, jstring options, jobject cb, jobject data) {
const char* _strchars_options = NULL;
@@ -106,7 +130,7 @@ Java_com_mbien_opencl_impl_CLImpl_clBuildProgram0(JNIEnv *env, jobject _unused,
}
// TODO payload, callback...
- _res = clBuildProgram((cl_program)program, (cl_uint)deviceCount, _deviceListPtr, _strchars_options, NULL, NULL);
+ _res = clBuildProgram((cl_program)program, (cl_uint)deviceCount, (cl_device_id *)_deviceListPtr, _strchars_options, NULL, NULL);
if (deviceList != NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, deviceList, _deviceListPtr, 0);
diff --git a/resources/clImplCustomCode.java b/resources/clImplCustomCode.java
index 0d25ddb6..d74d5b82 100644
--- a/resources/clImplCustomCode.java
+++ b/resources/clImplCustomCode.java
@@ -1,10 +1,21 @@
- public long clCreateContext(IntBuffer properties, long[] devices, CreateContextCallback cb, Object userData, IntBuffer errcode_ret) {
+ public long clCreateContext(IntBuffer properties, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret) {
- throw new RuntimeException("not yet implemented, use clCreateContextFromType instead");
-// return this.clCreateContext0(properties, offset1, devices, cb, null, errcode_ret, offset2);
+ if(pfn_notify != null)
+ throw new RuntimeException("asynchronous execution with callback is not yet implemented, pass null through this method to block until complete.");
+
+ if(userData != null)
+ System.err.println("WARNING: userData not yet implemented... ignoring");
+
+ int listLength = 0;
+ if(devices != null)
+ listLength = devices.length;
+
+ return this.clCreateContext1(
+ BufferFactory.getArray(properties), BufferFactory.getIndirectBufferByteOffset(properties), listLength, devices, null, null,
+ BufferFactory.getArray(errcode_ret), BufferFactory.getIndirectBufferByteOffset(errcode_ret) );
}
- private native long clCreateContext0(Object cl_context_properties, int props_offset, long[] devices, CreateContextCallback pfn_notify, Object userData, Object errcode_ret, int err_offset);
+ 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) {
@@ -35,8 +46,8 @@
if(deviceList != null)
listLength = deviceList.length;
- return clBuildProgram0(program, listLength, deviceList, 0, options, cb, userData);
+ return clBuildProgram1(program, listLength, deviceList, 0, options, cb, userData);
}
/** Entry point to C language function: <code> int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); </code> */
- private native int clBuildProgram0(long program, int devices, Object deviceList, int arg2_byte_offset, String options, BuildProgramCallback cb, Object userData);
+ private native int clBuildProgram1(long program, int devices, Object deviceList, int arg2_byte_offset, String options, BuildProgramCallback cb, Object userData);