Package com.aparapi.internal.jni
Class KernelRunnerJNI
- java.lang.Object
-
- com.aparapi.internal.jni.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 particularKernelArg
represents an array.
SoARG_ARRAY|ARG_INT
tells us this arg is an array ofint
.protected static int
ARG_ARRAYLENGTH
This 'bit' indicates that a particularKernelArg
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 particularKernelArg
represents aboolean
type (array or primitive).protected static int
ARG_BYTE
This 'bit' indicates that a particularKernelArg
represents abyte
type (array or primitive).protected static int
ARG_CHAR
This 'bit' indicates that a particularKernelArg
represents achar
type (array or primitive).protected static int
ARG_CONSTANT
This 'bit' indicates that a particularKernelArg
resides in constant memory in the generated OpenCL code.protected static int
ARG_DOUBLE
This 'bit' indicates that a particularKernelArg
represents adouble
type (array or primitive).protected static int
ARG_EXPLICIT
This 'bit' indicates that the arg has been explicitly marked for readingprotected static int
ARG_EXPLICIT_WRITE
This 'bit' indicates that the arg has been explicitly marked for writingprotected static int
ARG_FLOAT
This 'bit' indicates that a particularKernelArg
represents afloat
type (array or primitive).protected static int
ARG_GLOBAL
This 'bit' indicates that a particularKernelArg
resides in global memory in the generated OpenCL code.protected static int
ARG_INT
This 'bit' indicates that a particularKernelArg
represents aint
type (array or primitive).protected static int
ARG_LOCAL
This 'bit' indicates that a particularKernelArg
resides in local memory in the generated OpenCL code.protected static int
ARG_LONG
This 'bit' indicates that a particularKernelArg
represents along
type (array or primitive).protected static int
ARG_OBJ_ARRAY_STRUCT
TODO:protected static int
ARG_PRIMITIVE
This 'bit' indicates that a particularKernelArg
represents a primitive (non array).
SoARG_PRIMITIVE|ARG_INT
tells us this arg is a primitiveint
.protected static int
ARG_READ
This 'bit' indicates that a particularKernelArg
is read by the Kernel (note from the Kernel's point of view).
SoARG_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 particularKernelArg
represents astatic
field (array or primitive).protected static int
ARG_WRITE
This 'bit' indicates that a particularKernelArg
is mutated by the Kernel (note from the Kernel's point of view).
SoARG_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()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected long
buildProgramJNI(long _jniContextHandle, java.lang.String _source, java.lang.String _binaryKey)
protected int
disposeJNI(long _jniContextHandle)
protected java.lang.String
getExtensionsJNI(long _jniContextHandle)
protected int
getJNI(long _jniContextHandle, java.lang.Object _array)
protected int[]
getKernelCompileWorkGroupSizeJNI(long _jniContextHandle)
protected long
getKernelLocalMemSizeInUseJNI(long _jniContextHandle)
protected int
getKernelMaxWorkGroupSizeJNI(long _jniContextHandle)
protected long
getKernelMinimumPrivateMemSizeInUsePerWorkItemJNI(long _jniContextHandle)
protected int
getKernelPreferredWorkGroupSizeMultipleJNI(long _jniContextHandle)
protected java.util.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 versionprotected int
runKernelJNI(long _jniContextHandle, Range _range, boolean _needSync, int _passes, java.nio.ByteBuffer _inBuffer, java.nio.ByteBuffer _outBuffer)
protected int
setArgsJNI(long _jniContextHandle, KernelArgJNI[] _args, int argc)
-
-
-
Field Detail
-
ARG_BOOLEAN
protected static final int ARG_BOOLEAN
This 'bit' indicates that a particularKernelArg
represents aboolean
type (array or primitive).- See Also:
UsedByJNICode
, Constant Field Values
-
ARG_BYTE
protected static final int ARG_BYTE
This 'bit' indicates that a particularKernelArg
represents abyte
type (array or primitive).- See Also:
UsedByJNICode
, Constant Field Values
-
ARG_FLOAT
protected static final int ARG_FLOAT
This 'bit' indicates that a particularKernelArg
represents afloat
type (array or primitive).- See Also:
UsedByJNICode
, Constant Field Values
-
ARG_INT
protected static final int ARG_INT
This 'bit' indicates that a particularKernelArg
represents aint
type (array or primitive).- See Also:
UsedByJNICode
, Constant Field Values
-
ARG_DOUBLE
protected static final int ARG_DOUBLE
This 'bit' indicates that a particularKernelArg
represents adouble
type (array or primitive).- See Also:
UsedByJNICode
, Constant Field Values
-
ARG_LONG
protected static final int ARG_LONG
This 'bit' indicates that a particularKernelArg
represents along
type (array or primitive).- See Also:
UsedByJNICode
, Constant Field Values
-
ARG_SHORT
protected static final int ARG_SHORT
TODO:- See Also:
UsedByJNICode
, Constant Field Values
-
ARG_ARRAY
protected static final int ARG_ARRAY
This 'bit' indicates that a particularKernelArg
represents an array.
SoARG_ARRAY|ARG_INT
tells us this arg is an array ofint
.- See Also:
UsedByJNICode
, Constant Field Values
-
ARG_PRIMITIVE
protected static final int ARG_PRIMITIVE
This 'bit' indicates that a particularKernelArg
represents a primitive (non array).
SoARG_PRIMITIVE|ARG_INT
tells us this arg is a primitiveint
.- See Also:
UsedByJNICode
, Constant Field Values
-
ARG_READ
protected static final int ARG_READ
This 'bit' indicates that a particularKernelArg
is read by the Kernel (note from the Kernel's point of view).
SoARG_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 particularKernelArg
is mutated by the Kernel (note from the Kernel's point of view).
SoARG_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_LOCAL
protected static final int ARG_LOCAL
This 'bit' indicates that a particularKernelArg
resides in local memory in the generated OpenCL code.- See Also:
UsedByJNICode
,Experimental
, Constant Field Values
-
ARG_GLOBAL
protected static final int ARG_GLOBAL
This 'bit' indicates that a particularKernelArg
resides in global memory in the generated OpenCL code.- See Also:
UsedByJNICode
,Experimental
, Constant Field Values
-
ARG_CONSTANT
protected static final int ARG_CONSTANT
This 'bit' indicates that a particularKernelArg
resides in constant memory in the generated OpenCL code.- See Also:
UsedByJNICode
,Experimental
, Constant Field Values
-
ARG_ARRAYLENGTH
protected static final int ARG_ARRAYLENGTH
This 'bit' indicates that a particularKernelArg
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_APARAPI_BUFFER
protected static final int ARG_APARAPI_BUFFER
TODO:- 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_OBJ_ARRAY_STRUCT
protected static final int ARG_OBJ_ARRAY_STRUCT
TODO:- See Also:
UsedByJNICode
, Constant Field Values
-
ARG_CHAR
protected static final int ARG_CHAR
This 'bit' indicates that a particularKernelArg
represents achar
type (array or primitive).- See Also:
UsedByJNICode
, Constant Field Values
-
ARG_STATIC
protected static final int ARG_STATIC
This 'bit' indicates that a particularKernelArg
represents astatic
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
-
-
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)
-
-