Login  Register

Re: jocl.CLProgram.create() line 74

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

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,

  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


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

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

ProgramTest.java (6K) Download Attachment