Skip to content

JAVACL: Program caching and manually specified binaries don't play nice #453

@dlwh

Description

@dlwh

(scala code)

About as minimal a test case as I can manage:

    implicit val clcontext = JavaCL.createBestContext(CLPlatform.DeviceFeature.GPU)
    val ap = clcontext.createProgram("__kernel void add(int a, int b, __global int* c) { *c = a + b; }")
    ap.createKernel("add")
    val addBins = ap.getBinaries
    val subBins = clcontext.createProgram("__kernel void sub(int a, int b, __global int* c) { *c = a - b; }").getBinaries
    val ap2 = clcontext.createProgram(addBins, "__kernel void add(int a, int b, __global int* c) { *c = a + b; }")
    ap2.createKernel("add")
    val sp2 = clcontext.createProgram(subBins, "__kernel void sub(int a, int b, __global int* c) { *c = a - b; }")
   sp2.setCached(true) // set to false and it works
    sp2.createKernel("sub")

If you don't cache the binaries, everything is fine, but if you do, it looks like the cache always uses the last provided binaries? That is, if you call sp2.getKernels, you get the kernels for ap2.

The error:

 com.nativelibs4java.opencl.CLException$InvalidKernelName: InvalidKernelName (make sure to log all errors with environment variable CL_LOG_ERRORS=stdout)
[info]   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[info]   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
[info]   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[info]   at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
[info]   at java.lang.Class.newInstance0(Class.java:374)
[info]   at java.lang.Class.newInstance(Class.java:327)
[info]   at com.nativelibs4java.opencl.CLException.error(CLException.java:261)
[info]   at com.nativelibs4java.opencl.CLException.failedForLackOfMemory(CLException.java:236)
[info]   at com.nativelibs4java.opencl.CLProgram.createKernel(CLProgram.java:913)
[info]   at puck.parser.CLParserDataTest$$anonfun$1.apply$mcV$sp(CLParserDataTest.scala:45)

Tested against 1.0-SNAPSHOT and 1.0.0-RC3 on OS X 10.8

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