diff --git a/OpenCL/src/main/scala/com/thoughtworks/compute/OpenCL.scala b/OpenCL/src/main/scala/com/thoughtworks/compute/OpenCL.scala index d922ae39..b283eeef 100644 --- a/OpenCL/src/main/scala/com/thoughtworks/compute/OpenCL.scala +++ b/OpenCL/src/main/scala/com/thoughtworks/compute/OpenCL.scala @@ -881,6 +881,20 @@ object OpenCL { def monadicClose = UnitContinuation.delay { OpenCL.checkErrorCode(clReleaseProgram(handle)) } + + def kernelNames(): Seq[String] = { + val stack = stackPush() + try { + val sizeBuffer = stack.mallocPointer(1) + checkErrorCode(clGetProgramInfo(this.handle, CL_PROGRAM_KERNEL_NAMES, null: ByteBuffer, sizeBuffer)) + val nameBuffer = stack.malloc(sizeBuffer.get(0).toInt) + checkErrorCode(clGetProgramInfo(this.handle, CL_PROGRAM_KERNEL_NAMES, nameBuffer, null: PointerBuffer)) + memUTF8(nameBuffer).split(';') + } finally { + stack.close() + } + } + } object Program { @@ -1216,7 +1230,7 @@ trait OpenCL extends MonadicCloseable[UnitContinuation] with ImplicitsSingleton val cl20Properties = (properties.view.flatMap { case (key, value) => Seq(key, value) } ++ Seq(0L)).toArray val a = Array(0) val commandQueue = - clCreateCommandQueueWithProperties(platformId.handle, deviceId.handle, cl20Properties, a) + clCreateCommandQueueWithProperties(context, deviceId.handle, cl20Properties, a) checkErrorCode(a(0)) commandQueue } else {