Login  Register

Re: jocl.CLProgram.create() line 74

Posted by Michael Bien on Jan 14, 2011; 1:19am
URL: https://forum.jogamp.org/jocl-CLProgram-create-line-74-tp2250272p2250459.html

Hello Rick,

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://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






View message @ http://jogamp.762907.n3.nabble.com/jocl-CLProgram-create-line-74-tp2250272p2250272.html
To start a new topic under jogamp, email [hidden email]
To unsubscribe from jogamp, click here.

-- 
http://michael-bien.com/