summaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/cl-if.cfg6
-rw-r--r--resources/clImplCustomCode.c69
-rw-r--r--resources/clImplCustomCode.java33
3 files changed, 88 insertions, 20 deletions
diff --git a/resources/cl-if.cfg b/resources/cl-if.cfg
index 08e21dcc..4d7d80f1 100644
--- a/resources/cl-if.cfg
+++ b/resources/cl-if.cfg
@@ -16,15 +16,19 @@ Ignore CL_GL_.*|cl.*GL.*
#custom implementations
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, int properties_offset, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int errcode_offset);
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, int properties_offset, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int errcode_offset);
Ignore clBuildProgram
-#TODO..
+CustomJavaCode CL
+CustomJavaCode CL /** Interface to C language function: <br> <code> int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void (*pfn_notify)(cl_program, void *user_data), void * ); </code> */
+CustomJavaCode CL public int clBuildProgram(long program, long[] devices, String options, BuildProgramCallback cb, Object userData);
Ignore clEnqueueNativeKernel
#TODO..
diff --git a/resources/clImplCustomCode.c b/resources/clImplCustomCode.c
index 83d25938..9c87c24a 100644
--- a/resources/clImplCustomCode.c
+++ b/resources/clImplCustomCode.c
@@ -1,3 +1,12 @@
+/*
+void checkStatus(const char* msg, int status) {
+ if (status != CL_SUCCESS) {
+ printf("%s; error: %d \n", msg, status);
+ exit(EXIT_FAILURE);
+ }
+}
+*/
+
/*
void createContextCallback(const char * c, const void * v, size_t s, void * o) {
@@ -22,14 +31,7 @@ Java_com_mbien_opencl_impl_CLImpl_clCreateContextFromType0(JNIEnv *env, jobject
intptr_t * _props_ptr = NULL;
int32_t * _errcode_ptr = NULL;
-
-/*
- printf("jlong: %zu \n", sizeof(jlong) );
- printf("intptr_t: %zu \n", sizeof(intptr_t));
- printf("size_t: %zu \n", sizeof(size_t));
-*/
-
- cl_context _res;
+ cl_context _ctx;
if (props != NULL) {
_props_ptr = (intptr_t *) (((char*) (*env)->GetDirectBufferAddress(env, props)) + props_byte_offset);
@@ -39,9 +41,21 @@ Java_com_mbien_opencl_impl_CLImpl_clCreateContextFromType0(JNIEnv *env, jobject
}
//TODO callback; payload
- _res = clCreateContextFromType((intptr_t *) _props_ptr, (uint64_t) device_type, NULL, NULL, (int32_t *) _errcode_ptr);
+ _ctx = clCreateContextFromType((intptr_t *) _props_ptr, (uint64_t) device_type, NULL, NULL, (int32_t *) _errcode_ptr);
- return (jlong) (intptr_t) _res;
+/*
+ printf(" - - - - test - - - - \n");
+ cl_uint err;
+ size_t deviceListSize;
+
+ // get the list of GPU devices associated with context
+ err = clGetContextInfo(_ctx, CL_CONTEXT_DEVICES, 0, NULL, &deviceListSize); checkStatus("getContextInfo1", err);
+ cl_uint count = (cl_uint)deviceListSize / sizeof(cl_device_id);
+ printf("devices: %d \n", count);
+ printf(" - - - - test end - - - - \n");
+*/
+
+ return (jlong)_ctx;
}
@@ -73,5 +87,40 @@ Java_com_mbien_opencl_impl_CLImpl_clCreateContext0(JNIEnv *env, jobject _unused,
}
*/
+/**
+ * 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 * );
+ */
+JNIEXPORT jint JNICALL
+Java_com_mbien_opencl_impl_CLImpl_clBuildProgram0(JNIEnv *env, jobject _unused,
+ jlong program, jint deviceCount, jobject deviceList, jint offset, jstring options, jobject cb, jobject data) {
+
+ const char* _strchars_options = NULL;
+ cl_int _res;
+ size_t * _deviceListPtr = NULL;
+
+ 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)->GetPrimitiveArrayCritical(env, deviceList, NULL)) + offset);
+ }
+
+ // TODO payload, callback...
+ _res = clBuildProgram((cl_program)program, (cl_uint)deviceCount, _deviceListPtr, _strchars_options, NULL, NULL);
+ if (deviceList != NULL) {
+ (*env)->ReleasePrimitiveArrayCritical(env, deviceList, _deviceListPtr, 0);
+ }
+ if (options != NULL) {
+ (*env)->ReleaseStringUTFChars(env, options, _strchars_options);
+ }
+
+ return _res;
+}
diff --git a/resources/clImplCustomCode.java b/resources/clImplCustomCode.java
index 5ccc3b02..618b03c2 100644
--- a/resources/clImplCustomCode.java
+++ b/resources/clImplCustomCode.java
@@ -1,14 +1,29 @@
- public long clCreateContext(IntBuffer properties, int offset1, long[] devices, CreateContextCallback cb, Object userData, IntBuffer errcode_ret, int offset2) {
- return this.clCreateContext0(properties, offset1, devices, cb, null, errcode_ret, offset2);
- }
- private native long clCreateContext0(IntBuffer properties, int size, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int size2);
+ public long clCreateContext(IntBuffer properties, int offset1, long[] devices, CreateContextCallback cb, Object userData, IntBuffer errcode_ret, int offset2) {
+ throw new RuntimeException("not yet implemented, use clCreateContextFromType instead");
+// return this.clCreateContext0(properties, offset1, devices, cb, null, errcode_ret, offset2);
+ }
+ private native long clCreateContext0(IntBuffer cl_context_properties, int size, long[] devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int size2);
+ public long clCreateContextFromType(IntBuffer properties, int offset1, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int 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.out.println("WARNING: userData not yet implemented... ignoring");
+ return this.clCreateContextFromType0(properties, offset1, device_type, pfn_notify, null, errcode_ret, offset2);
+ }
+ private native long clCreateContextFromType0(IntBuffer properties, int size, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int size2);
- public long clCreateContextFromType(IntBuffer arg0, int offset1, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int offset2) {
- return this.clCreateContextFromType0(arg0, offset1, device_type, pfn_notify, null, errcode_ret, offset2);
- }
- private native long clCreateContextFromType0(IntBuffer arg0, int size, long device_type, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret, int size2);
- \ No newline at end of file
+ /** Interface to C language function: <br> <code> int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); </code> */
+ public int clBuildProgram(long program, long[] deviceList, String options, BuildProgramCallback cb, Object userData) {
+ if(cb != 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.out.println("WARNING: userData not yet implemented... ignoring");
+ return clBuildProgram0(program, deviceList.length, 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);
+