Skip to content

JavaCL: CLBuildException #21

Description

@ochafik

From @DomenPrestor on March 5, 2014 14:5

Hi,

I'm having a problem with a basic JavaCL example (and with all the other ones aswell). I suppose I should note that I don't have a (sufficient) GPU and that I'm just trying to run my code on CPU (and I'll move on a computer with GPU later on). So this is my host code (it's basically the same as the example from the site):

public class JavacProba {
public static void main(String[] args) throws IOException {

    CLContext context = JavaCL.createBestContext();
    CLQueue queue = context.createDefaultQueue();
    ByteOrder byteOrder = context.getByteOrder();

    int n = 1024;
    Pointer<Float>
        aPtr = allocateFloats(n).order(byteOrder),
        bPtr = allocateFloats(n).order(byteOrder),
        outPtr = allocateFloats(n).order(byteOrder);

    for (int i = 0; i < n; i++) {
        aPtr.set(i, (float)cos(i));
        bPtr.set(i, (float)sin(i));
    }

    // Create OpenCL input buffers (using the native memory pointers aPtr and bPtr) :
    CLBuffer<Float> 
        a = context.createBuffer(Usage.Input, aPtr),
        b = context.createBuffer(Usage.Input, bPtr);

    // Create an OpenCL output buffer :
    CLBuffer<Float> out = context.createBuffer(Usage.Output, outPtr);
    // Read the program sources and compile them :
    String src = IOUtils.readText(new File("TutorialKernels.cl"));
    CLProgram program = context.createProgram(src).build();
    // Get and call the kernel :

    CLKernel addFloatsKernel = program.createKernel("add_floats");

    addFloatsKernel.setArgs(a, b, out, n);
    CLEvent addEvt = addFloatsKernel.enqueueNDRange(queue, new int[] { n });

    outPtr = out.read(queue, addEvt); // blocks until add_floats finished
    // Print the first 10 output values :
    for (int i = 0; i < 10 && i < n; i++)
        System.out.println("out[" + i + "] = " + outPtr.get(i));

}

}

This is my kernel:

__kernel void add_floats(__global float* a, __global float* b, __global float* out, int n)
{
/if(i < n){
int i = get_global_id(0);
out[i] = a[i] + b[i];}
/
}

And this is the output I'm getting:

Exception in thread "main" com.nativelibs4java.opencl.CLBuildException: Compilation failure : CL_INVALID_BUILD_OPTIONS (devices: [Intel(R) Core(TM)2 Duo CPU T8100 @ 2.10GHz (ATI Stream)])

at com.nativelibs4java.opencl.CLProgram.build(CLProgram.java:828)
at javacproba.JavacProba.main(JavacProba.java:55)

Java Result: 1

I'm using this version of JavaCL:

javacl-opengl-demos-1.0.0-rc3-shaded.jar

And am running AMD SDK ... Also, I should mention that I can run the same kernel with JOCL, just not with JavaCL.

Copied from original issue: nativelibs4java/nativelibs4java#483

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions