rogerallen/hello_lwjgl

"omega" OpenCL example code not working

rogerallen opened this issue · 3 comments

Checked in an example for OpenCL. uncomment the omega lines in core.clj & do "lein run omega" to reproduce.

There's no official example that I can find that is supposed to work with 3.0.0b. This blog
http://yarenty.blogspot.com/2015/03/lwjgl3-use-gpu-opencl-for-multithreaded.html
indicates it should work, but I've made enough subtle changes that I don't know if it will ever work...

Giving up for the moment. Anyone feel up to trying to fix this? Or pointing to working example code?

> lein run omega
Hello, Lightweight Java Game Library! V 3.0.0b SNAPSHOT
Run example Omega
  (a simple OpenCL test)
init
CL created
platform created
ctx-props created
errcode created
get devices #object[java.util.ArrayList 0x2320fa6f [CLDevice pointer [0x1024400], CLDevice pointer [0x1022700]]]
device 0 #object[org.lwjgl.opencl.CLDevice 0x4d722ac9 CLDevice pointer [0x1024400]]
context created 140395407619280
queue created 140395407619952
allocated memory
[LWJGL] cl_program_callback
kernel created 0
kernel-work-size created
Exception in thread "main" java.lang.ClassCastException: java.lang.Long cannot be cast to org.lwjgl.PointerBuffer, compiling:(/private/var/folders/zb/w97rn0bn1hl7stfrgk5_04mc0000gn/T/form-init7029757012931126534.clj:1:125)
    at clojure.lang.Compiler.load(Compiler.java:7391)
    at clojure.lang.Compiler.loadFile(Compiler.java:7317)
    at clojure.main$load_script.invokeStatic(main.clj:275)
    at clojure.main$init_opt.invokeStatic(main.clj:277)
    at clojure.main$init_opt.invoke(main.clj:277)
    at clojure.main$initialize.invokeStatic(main.clj:308)
    at clojure.main$null_opt.invokeStatic(main.clj:342)
    at clojure.main$null_opt.invoke(main.clj:339)
    at clojure.main$main.invokeStatic(main.clj:421)
    at clojure.main$main.doInvoke(main.clj:384)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:383)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)
Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to org.lwjgl.PointerBuffer
    at hello_lwjgl.omega$main.invokeStatic(omega.clj:115)
    at hello_lwjgl.omega$main.invoke(omega.clj:29)
    at hello_lwjgl.core$_main.invokeStatic(core.clj:17)
    at hello_lwjgl.core$_main.doInvoke(core.clj:10)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.lang.Var.invoke(Var.java:379)
    at user$eval5.invokeStatic(form-init7029757012931126534.clj:1)
    at user$eval5.invoke(form-init7029757012931126534.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6927)
    at clojure.lang.Compiler.eval(Compiler.java:6917)
    at clojure.lang.Compiler.load(Compiler.java:7379)
    ... 14 more

Indicates a failure near this line:

(CL10/clSetKernelArg1p kernel 0 a-mem)

and that call http://javadoc.lwjgl.org/org/lwjgl/opencl/CL10.html#clSetKernelArg1p(long,%20int,%20long)

public static int clSetKernelArg1p(long kernel,
               int arg_index,
               long arg0)

does not ask for a org.lwjgl.PointerBuffer

Found this code in the src

    /** Single pointer value version of: {@link #clSetKernelArg SetKernelArg} */
    public static int clSetKernelArg1p(long kernel, int arg_index, long arg0) {
        APIBuffer __buffer = apiBuffer();
        int arg_value = __buffer.pointerParam(arg0);
        return nclSetKernelArg(kernel, arg_index, (1 << POINTER_SHIFT) * 1, __buffer.address(arg_value));
    }