Class KernelRunnerJNI

java.lang.Object
com.aparapi.internal.jni.KernelRunnerJNI
Direct Known Subclasses:
KernelRunner

public abstract class KernelRunnerJNI extends Object
This class is intended to be used as a 'proxy' or 'facade' object for Java code to interact with JNI
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final int
    TODO:
    protected static final int
    This 'bit' indicates that a particular KernelArg represents an array.
    So ARG_ARRAY|ARG_INT tells us this arg is an array of int.
    protected static final int
    This 'bit' indicates that a particular KernelArg has it's length reference, in which case a synthetic arg is passed (name mangled) to the OpenCL kernel.
    protected static final int
    This 'bit' indicates that a particular KernelArg represents a boolean type (array or primitive).
    protected static final int
    This 'bit' indicates that a particular KernelArg represents a byte type (array or primitive).
    protected static final int
    This 'bit' indicates that a particular KernelArg represents a char type (array or primitive).
    protected static final int
    This 'bit' indicates that a particular KernelArg resides in constant memory in the generated OpenCL code.
    protected static final int
    This 'bit' indicates that a particular KernelArg represents a double type (array or primitive).
    protected static final int
    This 'bit' indicates that the arg has been explicitly marked for reading
    protected static final int
    This 'bit' indicates that the arg has been explicitly marked for writing
    protected static final int
    This 'bit' indicates that a particular KernelArg represents a float type (array or primitive).
    protected static final int
    This 'bit' indicates that a particular KernelArg resides in global memory in the generated OpenCL code.
    protected static final int
    This 'bit' indicates that a particular KernelArg represents a int type (array or primitive).
    protected static final int
    This 'bit' indicates that a particular KernelArg resides in local memory in the generated OpenCL code.
    protected static final int
    This 'bit' indicates that a particular KernelArg represents a long type (array or primitive).
    protected static final int
    TODO:
    protected static final int
    This 'bit' indicates that a particular KernelArg represents a primitive (non array).
    So ARG_PRIMITIVE|ARG_INT tells us this arg is a primitive int.
    protected static final int
    This 'bit' indicates that a particular KernelArg is read by the Kernel (note from the Kernel's point of view).
    So ARG_ARRAY|ARG_INT|ARG_READ tells us this arg is an array of int's that are read by the kernel.
    protected static final int
    TODO:
    protected static final int
    This 'bit' indicates that a particular KernelArg represents a static field (array or primitive).
    protected static final int
    This 'bit' indicates that a particular KernelArg is mutated by the Kernel (note from the Kernel's point of view).
    So ARG_ARRAY|ARG_INT|ARG_WRITE tells us this arg is an array of int's that we expect the kernel to mutate.
    protected static final int
    This 'bit' indicates that we want to execute on the Acceleratr.
    protected static final int
    This 'bit' indicates that we want to execute on the GPU.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected long
    buildProgramJNI(long _jniContextHandle, String _source, String _binaryKey)
     
    protected int
    disposeJNI(long _jniContextHandle)
     
    protected String
    getExtensionsJNI(long _jniContextHandle)
     
    protected int
    getJNI(long _jniContextHandle, Object _array)
     
    protected int[]
    getKernelCompileWorkGroupSizeJNI(long _jniContextHandle)
     
    protected long
    getKernelLocalMemSizeInUseJNI(long _jniContextHandle)
     
    protected int
    getKernelMaxWorkGroupSizeJNI(long _jniContextHandle)
     
    protected long
     
    protected int
     
    protected List<ProfileInfo>
    getProfileInfoJNI(long _jniContextHandle)
     
    protected long
    initJNI(Kernel _kernel, OpenCLDevice _device, int _flags)
    TODO: synchronized to avoid race in clGetPlatformIDs() in OpenCL lib problem should fixed in some future OpenCL version
    protected int
    runKernelJNI(long _jniContextHandle, Range _range, boolean _needSync, int _passes, ByteBuffer _inBuffer, ByteBuffer _outBuffer)
     
    protected int
    setArgsJNI(long _jniContextHandle, KernelArgJNI[] _args, int argc)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ARG_BOOLEAN

      protected static final int ARG_BOOLEAN
      This 'bit' indicates that a particular KernelArg represents a boolean type (array or primitive).
      See Also:
    • ARG_BYTE

      protected static final int ARG_BYTE
      This 'bit' indicates that a particular KernelArg represents a byte type (array or primitive).
      See Also:
    • ARG_FLOAT

      protected static final int ARG_FLOAT
      This 'bit' indicates that a particular KernelArg represents a float type (array or primitive).
      See Also:
    • ARG_INT

      protected static final int ARG_INT
      This 'bit' indicates that a particular KernelArg represents a int type (array or primitive).
      See Also:
    • ARG_DOUBLE

      protected static final int ARG_DOUBLE
      This 'bit' indicates that a particular KernelArg represents a double type (array or primitive).
      See Also:
    • ARG_LONG

      protected static final int ARG_LONG
      This 'bit' indicates that a particular KernelArg represents a long type (array or primitive).
      See Also:
    • ARG_SHORT

      protected static final int ARG_SHORT
      TODO:
      See Also:
    • ARG_ARRAY

      protected static final int ARG_ARRAY
      This 'bit' indicates that a particular KernelArg represents an array.
      So ARG_ARRAY|ARG_INT tells us this arg is an array of int.
      See Also:
    • ARG_PRIMITIVE

      protected static final int ARG_PRIMITIVE
      This 'bit' indicates that a particular KernelArg represents a primitive (non array).
      So ARG_PRIMITIVE|ARG_INT tells us this arg is a primitive int.
      See Also:
    • ARG_READ

      protected static final int ARG_READ
      This 'bit' indicates that a particular KernelArg is read by the Kernel (note from the Kernel's point of view).
      So ARG_ARRAY|ARG_INT|ARG_READ tells us this arg is an array of int's that are read by the kernel.
      See Also:
    • ARG_WRITE

      protected static final int ARG_WRITE
      This 'bit' indicates that a particular KernelArg is mutated by the Kernel (note from the Kernel's point of view).
      So ARG_ARRAY|ARG_INT|ARG_WRITE tells us this arg is an array of int's that we expect the kernel to mutate.
      See Also:
    • ARG_LOCAL

      protected static final int ARG_LOCAL
      This 'bit' indicates that a particular KernelArg resides in local memory in the generated OpenCL code.
      See Also:
    • ARG_GLOBAL

      protected static final int ARG_GLOBAL
      This 'bit' indicates that a particular KernelArg resides in global memory in the generated OpenCL code.
      See Also:
    • ARG_CONSTANT

      protected static final int ARG_CONSTANT
      This 'bit' indicates that a particular KernelArg resides in constant memory in the generated OpenCL code.
      See Also:
    • ARG_ARRAYLENGTH

      protected static final int ARG_ARRAYLENGTH
      This 'bit' indicates that a particular KernelArg has it's length reference, in which case a synthetic arg is passed (name mangled) to the OpenCL kernel.
      See Also:
    • ARG_APARAPI_BUFFER

      protected static final int ARG_APARAPI_BUFFER
      TODO:
      See Also:
    • ARG_EXPLICIT

      protected static final int ARG_EXPLICIT
      This 'bit' indicates that the arg has been explicitly marked for reading
      See Also:
    • ARG_EXPLICIT_WRITE

      protected static final int ARG_EXPLICIT_WRITE
      This 'bit' indicates that the arg has been explicitly marked for writing
      See Also:
    • ARG_OBJ_ARRAY_STRUCT

      protected static final int ARG_OBJ_ARRAY_STRUCT
      TODO:
      See Also:
    • ARG_CHAR

      protected static final int ARG_CHAR
      This 'bit' indicates that a particular KernelArg represents a char type (array or primitive).
      See Also:
    • ARG_STATIC

      protected static final int ARG_STATIC
      This 'bit' indicates that a particular KernelArg represents a static field (array or primitive).
      See Also:
    • JNI_FLAG_USE_GPU

      protected static final int JNI_FLAG_USE_GPU
      This 'bit' indicates that we want to execute on the GPU. Be careful changing final constants starting with JNI.
      See Also:
    • JNI_FLAG_USE_ACC

      protected static final int JNI_FLAG_USE_ACC
      This 'bit' indicates that we want to execute on the Acceleratr. Be careful changing final constants starting with JNI.
      See Also:
  • Constructor Details

    • KernelRunnerJNI

      public KernelRunnerJNI()
  • Method Details

    • initJNI

      protected long initJNI(Kernel _kernel, OpenCLDevice _device, int _flags)
      TODO: synchronized to avoid race in clGetPlatformIDs() in OpenCL lib problem should fixed in some future OpenCL version
      Parameters:
      _kernel -
      _device -
      _flags -
      Returns:
    • getJNI

      protected int getJNI(long _jniContextHandle, Object _array)
    • buildProgramJNI

      protected long buildProgramJNI(long _jniContextHandle, String _source, String _binaryKey)
      Parameters:
      _source - The OpenCL source code to compile, which may be sent empty if the binary for that source code is known to be cached on the JNI side under the key _binaryKey.
      _binaryKey - A key which embodies a Kernel class and a Device, under which the JNI side will cache the compiled binary corresponding to that Kernel/Device pair. Once a certain _binaryKey has been passed to this method once, further calls to this method with that key will ignore the _source (which can be passed empty) andused the cached binary.

      By passing an empty String as the _binaryKey, the entire JNI-side binary caching apparatus can be disabled.

    • setArgsJNI

      protected int setArgsJNI(long _jniContextHandle, KernelArgJNI[] _args, int argc)
    • runKernelJNI

      protected int runKernelJNI(long _jniContextHandle, Range _range, boolean _needSync, int _passes, ByteBuffer _inBuffer, ByteBuffer _outBuffer)
    • disposeJNI

      protected int disposeJNI(long _jniContextHandle)
    • getExtensionsJNI

      protected String getExtensionsJNI(long _jniContextHandle)
    • getProfileInfoJNI

      protected List<ProfileInfo> getProfileInfoJNI(long _jniContextHandle)
    • getKernelMinimumPrivateMemSizeInUsePerWorkItemJNI

      protected long getKernelMinimumPrivateMemSizeInUsePerWorkItemJNI(long _jniContextHandle)
    • getKernelLocalMemSizeInUseJNI

      protected long getKernelLocalMemSizeInUseJNI(long _jniContextHandle)
    • getKernelPreferredWorkGroupSizeMultipleJNI

      protected int getKernelPreferredWorkGroupSizeMultipleJNI(long _jniContextHandle)
    • getKernelMaxWorkGroupSizeJNI

      protected int getKernelMaxWorkGroupSizeJNI(long _jniContextHandle)
    • getKernelCompileWorkGroupSizeJNI

      protected int[] getKernelCompileWorkGroupSizeJNI(long _jniContextHandle)