Login  Register

jocl.CLProgram.create() line 74

Posted by Rick Lentz @ imagejdev.org on Jan 13, 2011; 11:31pm
URL: https://forum.jogamp.org/jocl-CLProgram-create-line-74-tp2250272.html

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