Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaCL: CLBuildException #21

Open
ochafik opened this issue Mar 18, 2015 · 0 comments
Open

JavaCL: CLBuildException #21

ochafik opened this issue Mar 18, 2015 · 0 comments
Labels

Comments

@ochafik
Copy link
Member

ochafik commented Mar 18, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant