Class KernelRunnerJNI

  • Direct Known Subclasses:
    KernelRunner

    public abstract class KernelRunnerJNI
    extends java.lang.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 int ARG_APARAPI_BUFFER
      TODO:
      protected static 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.
      protected static 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.
      protected static int ARG_BOOLEAN
      This 'bit' indicates that a particular KernelArg represents a boolean type (array or primitive).
      protected static int ARG_BYTE
      This 'bit' indicates that a particular KernelArg represents a byte type (array or primitive).
      protected static int ARG_CHAR
      This 'bit' indicates that a particular KernelArg represents a char type (array or primitive).
      protected static int ARG_CONSTANT
      This 'bit' indicates that a particular KernelArg resides in constant memory in the generated OpenCL code.
      protected static int ARG_DOUBLE
      This 'bit' indicates that a particular KernelArg represents a double type (array or primitive).
      protected static int ARG_EXPLICIT
      This 'bit' indicates that the arg has been explicitly marked for reading
      protected static int ARG_EXPLICIT_WRITE
      This 'bit' indicates that the arg has been explicitly marked for writing
      protected static int ARG_FLOAT
      This 'bit' indicates that a particular KernelArg represents a float type (array or primitive).
      protected static int ARG_GLOBAL
      This 'bit' indicates that a particular KernelArg resides in global memory in the generated OpenCL code.
      protected static int ARG_INT
      This 'bit' indicates that a particular KernelArg represents a int type (array or primitive).
      protected static int ARG_LOCAL
      This 'bit' indicates that a particular KernelArg resides in local memory in the generated OpenCL code.
      protected static int ARG_LONG
      This 'bit' indicates that a particular KernelArg represents a long type (array or primitive).
      protected static int ARG_OBJ_ARRAY_STRUCT
      TODO:
      protected static 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.
      protected static 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.
      protected static int ARG_SHORT
      TODO:
      protected static int ARG_STATIC
      This 'bit' indicates that a particular KernelArg represents a static field (array or primitive).
      protected static 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.
      protected static int JNI_FLAG_USE_ACC
      This 'bit' indicates that we want to execute on the Acceleratr.
      protected static int JNI_FLAG_USE_GPU
      This 'bit' indicates that we want to execute on the GPU.
    • Constructor Summary

      Constructors 
      Constructor Description
      KernelRunnerJNI()  
    • Field Detail

      • ARG_BOOLEAN

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

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

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

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

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

        protected static final int ARG_LONG
        This 'bit' indicates that a particular KernelArg represents a long type (array or primitive).
        See Also:
        UsedByJNICode, Constant Field Values
      • 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:
        UsedByJNICode, Constant Field Values
      • 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:
        UsedByJNICode, Constant Field Values
      • 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:
        UsedByJNICode, Constant Field Values
      • 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:
        UsedByJNICode, Constant Field Values
      • 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:
        UsedByJNICode, Constant Field Values
      • ARG_EXPLICIT

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

        protected static final int ARG_EXPLICIT_WRITE
        This 'bit' indicates that the arg has been explicitly marked for writing
        See Also:
        UsedByJNICode, Constant Field Values
      • ARG_CHAR

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

        protected static final int ARG_STATIC
        This 'bit' indicates that a particular KernelArg represents a static field (array or primitive).
        See Also:
        UsedByJNICode, Constant Field Values
      • 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:
        UsedByJNICode, Constant Field Values
      • 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:
        UsedByJNICode, Constant Field Values
    • Constructor Detail

      • KernelRunnerJNI

        public KernelRunnerJNI()
    • Method Detail

      • 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,
                             java.lang.Object _array)
      • buildProgramJNI

        protected long buildProgramJNI​(long _jniContextHandle,
                                       java.lang.String _source,
                                       java.lang.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,
                                   java.nio.ByteBuffer _inBuffer,
                                   java.nio.ByteBuffer _outBuffer)
      • disposeJNI

        protected int disposeJNI​(long _jniContextHandle)
      • getExtensionsJNI

        protected java.lang.String getExtensionsJNI​(long _jniContextHandle)
      • getProfileInfoJNI

        protected java.util.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)