Here is an excerpt from a slightly modified version of ...
http://dev.loci.wisc.edu/svn/software/branches/maven/projects/opencl-decon/src/demos/SobelFilterExample.java ... // begin source reference // Create a context from GPU context = CLContext.create( Type.GPU ); // create the program program = context.createProgram( openCLCodeString ); System.out.println( "My source is : " + program.getSource()); program.build( "" ); ...// end source reference That generates the output ...//begin output Retrieving test image... #pragma OPENCL EXTENSION cl_khr_fp64: enable __kernel void sobel( __global float* input, __global float* output, int width, int height ) { int x = get_global_id(0); int y = get_global_id(1); float p0, p1, p2, p3, p5, p6, p7, p8 = 0; int offset = y * width + x; if( x < 1 || y < 1 || x > width - 2 || y > height - 2 ) { output[offset] = 0; } else { p0 = input[offset - width - 1] ; p1 = input[offset - width] ; p2 = input[offset - width + 1] ; p3 = input[offset - 1] ; p5 = input[offset + 1] ; p6 = input[offset + width - 1] ; p7 = input[offset + width] ; p8 = input[offset + width + 1] ; double sum1 = p0 + 2*p1 + p2 - p6 - 2*p7 - p8; //GY double sum2 = p0 + 2*p3 + p6 - p2 - 2*p5 - p8; //GX output[offset] = sqrt( sum1*sum1 + sum2*sum2 ); } } Starting iteration... 0 My source is : #pragm The average OpenCL set up time is 0 The average OpenCL IO transfer time is 0 The average OpenCL execution time is 0 The average Java execution time is 0 com.jogamp.opencl.CLException$CLBuildProgramFailureException: CLDevice [id: 16918016 name: GeForce 8600M GT type: GPU profile: FULL_PROFILE] build log: <program source>:1:2: error: invalid preprocessing directive #pragm ^ [error: CL_BUILD_PROGRAM_FAILURE] at com.jogamp.opencl.CLException.newException(CLException.java:78) at com.jogamp.opencl.CLProgram.build(CLProgram.java:363) at com.jogamp.opencl.CLProgram.build(CLProgram.java:245) at demos.SobelFilterExample.init(SobelFilterExample.java:69) at demos.SobelFilterExample.runTest(SobelFilterExample.java:244) at demos.SobelFilterExample.main(SobelFilterExample.java:197) ... // end output Executed on OSX 10.6.5 Runs fine on Ubuntu... The static CLProgram create(CLContext context, String src) {} method doesn't seem like it has time to finish copying the string from source before returning since the source available in the output error message is of varied length for independent runs. I would appreciate any thoughts or insight into this issue. Regards, Rick Lentz |
thanks for the report. According to the spec the method should not return until the source is "loaded into the program". The JNI code looks also good at the first glance (proper reference locking etc). Next problem is: i can't reproduce it. Could you try the snippet below once with and once without the with xxx marked line? //... create context using high level api as you did before //... long context = highLevelContext.ID; IntBuffer intBuffer = Buffers.newDirectIntBuffer(1); CL cl = CLPlatform.getLowLevelCLInterface(); PointerBuffer lenght = (PointerBuffer)PointerBuffer.allocateDirect(1).put(programSource.length()); String[] srcArray = new String[] {programSource}; final long program = cl.clCreateProgramWithSource(context, 1, srcArray, lenght, intBuffer); checkError("on clCreateProgramWithSource", intBuffer.get(0)); // Build the program ret = cl.clBuildProgram(program, 0, null, null, null); checkError("on clBuildProgram", ret); xxx System.out.println(length +" "+srcArray); // please ignore, just a artificial reference lock private final void checkError(String msg, int ret) { if(ret != CL.CL_SUCCESS) throw CLException.newException(ret, msg); } thanks and best regards, michael On 01/14/2011 12:31 AM, Rick Lentz @ imagejdev.org [via jogamp] wrote: Here is an excerpt from a slightly modified version of ... -- http://michael-bien.com/ |
In reply to this post by Rick Lentz @ imagejdev.org
Michael,
Thank you for your excellent work on JOCL and for your response to my question. :-) Here is the snippet that I tried: long context = this.context.ID; IntBuffer intBuffer = Buffers.newDirectIntBuffer(1); CL cl = CLPlatform.getLowLevelCLInterface(); PointerBuffer pointBuffer = (PointerBuffer)PointerBuffer.allocateDirect(1).put( openCLCodeString.length() ); String[] srcArray = new String[] { openCLCodeString }; final long programLong = cl.clCreateProgramWithSource( context, 1, srcArray, pointBuffer, intBuffer ); checkError("on clCreateProgramWithSource", intBuffer.get(0) ); // Build the program int ret = cl.clBuildProgram( programLong, 0, null, null, null ); // Print out the point buffer and the srcArray variable (as a String) String outSourceString = ""; for(String sourceString : srcArray ) outSourceString += sourceString; System.out.println( "Result value is " + ret + " pointBuffer is " + pointBuffer + " the input OpenCL code is " + outSourceString ); // please ignore, just a artificial reference lock checkError("on clBuildProgram", ret); And the results are for the uncommented println() version is: Starting iteration... 0 Result value is -11 pointBuffer is PointerBuffer:AbstractBuffer[capacity 1, position 1, elementSize 8, ByteBuffer.capacity 8] the input OpenCL code is #pragma OPENCL EXTENSION cl_khr_fp64: enable __kernel void sobel( __global float* input, __global float* output, int width, int height ) { int x = get_global_id(0); int y = get_global_id(1); int offset = y * width + x; float p0, p1, p2, p3, p5, p6, p7, p8 = 0; if( x < 1 || y < 1 || x > width - 2 || y > height - 2 ) { output[offset] = 0; } else { p0 = input[offset - width - 1] ; p1 = input[offset - width] ; p2 = input[offset - width + 1] ; p3 = input[offset - 1] ; p5 = input[offset + 1] ; p6 = input[offset + width - 1] ; p7 = input[offset + width] ; p8 = input[offset + width + 1] ; double sum1 = p0 + 2*p1 + p2 - p6 - 2*p7 - p8; //GY double sum2 = p0 + 2*p3 + p6 - p2 - 2*p5 - p8; //GX output[offset] = sqrt( sum1*sum1 + sum2*sum2 ); } } The average OpenCL set up time is 0 The average OpenCL IO transfer time is 0 The average OpenCL execution time is 0 The average Java execution time is 0 com.jogamp.opencl.CLException$CLBuildProgramFailureException: on clBuildProgram [error: CL_BUILD_PROGRAM_FAILURE] at com.jogamp.opencl.CLException.newException(CLException.java:78) at demos.SobelFilterExample.checkError(SobelFilterExample.java:62) at demos.SobelFilterExample.init(SobelFilterExample.java:96) at demos.SobelFilterExample.runTest(SobelFilterExample.java:275) at demos.SobelFilterExample.main(SobelFilterExample.java:228) The result for the comment version is: Starting iteration... 0 com.jogamp.opencl.CLException$CLBuildProgramFailureException: on clBuildProgram [error: CL_BUILD_PROGRAM_FAILURE] The average OpenCL set up time is 0 The average OpenCL IO transfer time is 0 The average OpenCL execution time is 0 The average Java execution time is 0 at com.jogamp.opencl.CLException.newException(CLException.java:78) at demos.SobelFilterExample.checkError(SobelFilterExample.java:66) at demos.SobelFilterExample.init(SobelFilterExample.java:100) at demos.SobelFilterExample.runTest(SobelFilterExample.java:275) at demos.SobelFilterExample.main(SobelFilterExample.java:228) I am stuck on what might be causing the compile error. Thank you for sharing your insight. Best regards, Rick Lentz |
please run the attached test. I slightly modified the kernel to use floats to make it portable across implementations. I did a few tests on linux and windows with amd, intel and nv CL implementations and it passed all the time. You mentioned that its working on ubuntu, so its only reproducible on your mac? I have a few exams next week, I am not sure how much time i will be able to spend for this bug the next few days.. regards, michael On 01/14/2011 04:41 AM, Rick Lentz @ imagejdev.org [via jogamp] wrote: Michael, -- http://michael-bien.com/ ProgramTest.java (6K) Download Attachment |
In reply to this post by Rick Lentz @ imagejdev.org
sorry, i uploaded the wrong testcase version, please take this one.
On 01/14/2011 04:41 AM, Rick Lentz @ imagejdev.org [via jogamp] wrote: Michael, -- http://michael-bien.com/ ProgramTest.java (6K) Download Attachment |
Michael,
I have run the test provided: OS: Mac OS X ARCH: x86_64 VM: Java HotSpot(TM) 64-Bit Server VM lib path: /Users/rick/Documents/workspace-sts-2.5.1.RELEASE/OpenCLIterative3DDeconvolution/lib:/Users/rick/Documents/workspace-sts-2.5.1.RELEASE/OpenCLIterative3DDeconvolution/lib/APPLE:/Users/rick/Documents/workspace-sts-2.5.1.RELEASE/OpenCLIterative3DDeconvolution/lib/APPLE CLContext [id: 4301395024, platform: Apple, profile: FULL_PROFILE, devices: 2] OpenCL 1.0 (Aug 22 2010 18:08:16) please ignore [Ljava.lang.String;@604e280cPointerBuffer:AbstractBuffer[capacity 1, position 1, elementSize 8, ByteBuffer.capacity 8] src: __kernel -> success Here is the Junit output (failure trace): com.jogamp.opencl.CLException$CLBuildProgramFailureException: on clBuildProgram [error: CL_BUILD_PROGRAM_FAILURE] at com.jogamp.opencl.CLException.newException(CLException.java:78) at demos.ProgramTest.checkError(ProgramTest.java:109) at demos.ProgramTest.buildProgramTest(ProgramTest.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) |
I tested on another Mac just to ensure that it was not a single case regarding APPLE. Here is the console output /results (Failed):
OS: Mac OS X ARCH: x86_64 VM: Java HotSpot(TM) 64-Bit Server VM lib path: /Users/hinerm/Documents/workspace/OpenCLIterative3DDeconvolution/lib:/Users/hinerm/Documents/workspace/OpenCLIterative3DDeconvolution/lib/APPLE CLContext [id: 4296115824, platform: Apple, profile: FULL_PROFILE, devices: 2] OpenCL 1.0 (Aug 22 2010 18:08:16) please ignore [Ljava.lang.String;@29c56c60PointerBuffer:AbstractBuffer[capacity 1, position 1, elementSize 8, ByteBuffer.capacity 8] src: __kernel vo -> success **JUnit reports the same error as above*** A third test was run on Ubuntu 9.10 x64. This test passed: OS: Linux ARCH: amd64 VM: Java HotSpot(TM) 64-Bit Server VM lib path: /home/chrysalisbiosciencesadmin/workspace/OpenCLIterative3DDeconvolution/lib:/home/chrysalisbiosciencesadmin/workspace/OpenCLIterative3DDeconvolution/lib/LINUX64:/home/chrysalisbiosciencesadmin/workspace/OpenCLIterative3DDeconvolution/lib/LINUX64 CLContext [id: 1093557648, platform: NVIDIA CUDA, profile: FULL_PROFILE, devices: 3] OpenCL 1.0 CUDA 3.2.1 please ignore [Ljava.lang.String;@509ced8ePointerBuffer:AbstractBuffer[capacity 1, position 1, elementSize 8, ByteBuffer.capacity 8] src: __kernel void sobel( __global float* input, __global float* output, int width, int height ) { int x = get_global_id(0); int y = get_global_id(1); int offset = y * width + x; float p0, p1, p2, p3, p5, p6, p7, p8 = 0; if( x < 1 || y < 1 || x > width - 2 || y > height - 2 ) { output[offset] = 0; } else { p0 = input[offset - width - 1] ; p1 = input[offset - width] ; p2 = input[offset - width + 1] ; p3 = input[offset - 1] ; p5 = input[offset + 1] ; p6 = input[offset + width - 1] ; p7 = input[offset + width] ; p8 = input[offset + width + 1] ; float sum1 = p0 + 2*p1 + p2 - p6 - 2*p7 - p8; //GY float sum2 = p0 + 2*p3 + p6 - p2 - 2*p5 - p8; //GX output[offset] = sqrt( sum1*sum1 + sum2*sum2 ); } } -> success |
thank you Rick, i filed a bug report and set its priority to
blocker: https://jogamp.org/bugzilla/show_bug.cgi?id=458
(see description) -michael On 01/14/2011 04:35 PM, Rick Lentz @ imagejdev.org [via jogamp] wrote: I tested on another Mac just to ensure that it was not a single case regarding APPLE. Here is the console output /results (Failed): -- http://michael-bien.com/ |
In reply to this post by Rick Lentz @ imagejdev.org
there are a few options how we could fix this issue.
(the main problem is that we can't pass a String down to OpenCL, we have to convert it first into char**. That is fine as long we can delete the char** right after the function returns) e.g the quickest fix would be to switch from String to (direct) ByteBuffer for the source parameter and document it that the user is responsible to hold a reference on that buffer (and don't modify it) until the program is compiled. This is not very nice from the public api perspective thats why i would like to prevent that somehow. it could quickly lead to bugs if the user would do things like: ByteBuffer src = readSource1(); program1 = createProgramFromSource.. src = readSource2(); program2 = createProgramFromSource.. compile program1 compile program2 The high level binding would be less problematic since its statefull... but this would lead to additional copy of the sources in e.g CLProgram as ByteBuffer if we want to keep the CLProgram.create(String src) api. (Note: the driver stores the sources too...) have to think about that... any feedback appreciated. -michael On 01/15/2011 03:17 AM, Rick Lentz wrote: Hi Michael, -- http://michael-bien.com/ |
Free forum by Nabble | Edit this page |