|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.amd.aparapi.Kernel
public abstract class Kernel
A kernel encapsulates a data parallel algorithm that will execute either on a GPU (through conversion to OpenCL) or on a CPU via a Java Thread Pool.
To write a new kernel, a developer extends the Kernel class and overrides the Kernel.run() method.
To execute this kernel, the developer creates a new instance of it and calls Kernel.execute(int globalSize) with a suitable 'global size'. At runtime
Aparapi will attempt to convert the Kernel.run() method (and any method called directly or indirectly
by Kernel.run()) into OpenCL for execution on GPU devices made available via the OpenCL platform.
Note that Kernel.run() is not called directly. Instead,
the Kernel.execute(int globalSize) method will cause the overridden Kernel.run()
method to be invoked once for each value in the range 0...globalSize.
On the first call to Kernel.execute(int _globalSize), Aparapi will determine the EXECUTION_MODE of the kernel.
This decision is made dynamically based on two factors:
run() method (and every method that can be called directly or indirectly from the run() method)
can be converted into OpenCL.Below is an example Kernel that calculates the square of a set of input values.
class SquareKernel extends Kernel{
private int values[];
private int squares[];
public SquareKernel(int values[]){
this.values = values;
squares = new int[values.length];
}
public void run() {
int gid = getGlobalID();
squares[gid] = values[gid]*values[gid];
}
public int[] getSquares(){
return(squares);
}
}
To execute this kernel, first create a new instance of it and then call execute(int globalSize).
int[] values = new int[1024];
// fill values array
SquareKernel kernel = new SquareKernel(values);
kernel.execute(values.length);
When execute() returns, all the executions of Kernel.run() have completed and the results are available in the squares array.
int[] squares = kernel.getSquares();
for (int i=0; i< values.length; i++){
System.out.printf("%4d %4d %8d\n", i, values[i], squares[i]);
}
A different approach to creating kernels that avoids extending Kernel is to write an anonymous inner class:
final int[] values = new int[1024];
// fill values array
final int[] squares = new int[values.length];
Kernel kernel = new Kernel(){
public void run() {
int gid = getGlobalID();
squares[gid] = values[gid]*values[gid];
}
};
kernel.execute(values.length);
for (int i=0; i< values.length; i++){
System.out.printf("%4d %4d %8d\n", i, values[i], squares[i]);
}
| Nested Class Summary | |
|---|---|
static class |
Kernel.EXECUTION_MODE
The execution mode ENUM enumerates the possible modes of executing a kernel. |
| Constructor Summary | |
|---|---|
Kernel()
|
|
| Method Summary | |
|---|---|
protected double |
abs(double _d)
Delegates to either Math.abs(double) (Java) or fabs(double) (OpenCL). |
protected float |
abs(float _f)
Delegates to either Math.abs(float) (Java) or fabs(float) (OpenCL). |
protected int |
abs(int n)
Delegates to either Math.abs(int) (Java) or abs(int) (OpenCL). |
protected long |
abs(long n)
Delegates to either Math.abs(long) (Java) or abs(long) (OpenCL). |
protected double |
acos(double a)
Delegates to either Math.acos(double) (Java) or acos(double) (OpenCL). |
protected float |
acos(float a)
Delegates to either Math.acos(double) (Java) or acos(float) (OpenCL). |
protected double |
asin(double _d)
Delegates to either Math.asin(double) (Java) or asin(double) (OpenCL). |
protected float |
asin(float _f)
Delegates to either Math.asin(double) (Java) or asin(float) (OpenCL). |
protected double |
atan(double _d)
Delegates to either Math.atan(double) (Java) or atan(double) (OpenCL). |
protected float |
atan(float _f)
Delegates to either Math.atan(double) (Java) or atan(float) (OpenCL). |
protected double |
atan2(double _d1,
double _d2)
Delegates to either Math.atan2(double, double) (Java) or atan2(double, double) (OpenCL). |
protected float |
atan2(float _f1,
float _f2)
Delegates to either Math.atan2(double, double) (Java) or atan2(float, float) (OpenCL). |
protected int |
atomicAdd(int[] _arr,
int _index,
int _delta)
Atomically adds _delta value to _index element of array _arr (Java) or delegates to atomic_add(volatile int*, int) (OpenCL). |
protected double |
ceil(double _d)
Delegates to either Math.ceil(double) (Java) or ceil(double) (OpenCL). |
protected float |
ceil(float _f)
Delegates to either Math.ceil(double) (Java) or ceil(float) (OpenCL). |
protected Object |
clone()
When using a Java Thread Pool Aparapi uses clone to copy the initial instance to each thread. |
protected double |
cos(double _d)
Delegates to either Math.cos(double) (Java) or cos(double) (OpenCL). |
protected float |
cos(float _f)
Delegates to either Math.cos(double) (Java) or cos(float) (OpenCL). |
void |
dispose()
Release any resources associated with this Kernel. |
long |
execute(int _globalSize)
Start execution of globalSize kernels. |
protected double |
exp(double _d)
Delegates to either Math.exp(double) (Java) or exp(double) (OpenCL). |
protected float |
exp(float _f)
Delegates to either Math.exp(double) (Java) or exp(float) (OpenCL). |
protected double |
floor(double _d)
Delegates to either Math.floor(double) (Java) or floor(double) (OpenCL). |
protected float |
floor(float _f)
Delegates to either Math.floor(double) (Java) or floor(float) (OpenCL). |
Kernel.EXECUTION_MODE |
getExecutionMode()
Return the current execution mode. |
protected int |
getGlobalId()
Determine the globalId of an executing kernel. |
protected int |
getGlobalSize()
Determine the value that was passed to Kernel.execute(int globalSize) method. |
protected int |
getGroupId()
Determine the groupId of an executing kernel. |
protected int |
getLocalId()
Determine the local id of an executing kernel. |
protected int |
getLocalSize()
Determine the size of the group that an executing kernel is a member of. |
protected int |
getNumGroups()
Determine the number of groups that will be used to execute a kernel |
protected double |
IEEEremainder(double _d1,
double _d2)
Delegates to either Math.IEEEremainder(double, double) (Java) or remainder(double, double) (OpenCL). |
protected float |
IEEEremainder(float _f1,
float _f2)
Delegates to either Math.IEEEremainder(double, double) (Java) or remainder(float, float) (OpenCL). |
protected void |
localBarrier()
Wait for all kernels in the current group to rendezvous at this call before continuing execution. |
protected double |
log(double _d)
Delegates to either Math.log(double) (Java) or log(double) (OpenCL). |
protected float |
log(float _f)
Delegates to either Math.log(double) (Java) or log(float) (OpenCL). |
protected double |
max(double _d1,
double _d2)
Delegates to either Math.max(double, double) (Java) or fmax(double, double) (OpenCL). |
protected float |
max(float _f1,
float _f2)
Delegates to either Math.max(float, float) (Java) or fmax(float, float) (OpenCL). |
protected int |
max(int n1,
int n2)
Delegates to either Math.max(int, int) (Java) or max(int, int) (OpenCL). |
protected long |
max(long n1,
long n2)
Delegates to either Math.max(long, long) (Java) or max(long, long) (OpenCL). |
protected double |
min(double _d1,
double _d2)
Delegates to either Math.min(double, double) (Java) or fmin(double, double) (OpenCL). |
protected float |
min(float _f1,
float _f2)
Delegates to either Math.min(float, float) (Java) or fmin(float, float) (OpenCL). |
protected int |
min(int n1,
int n2)
Delegates to either Math.min(int, int) (Java) or min(int, int) (OpenCL). |
protected long |
min(long n1,
long n2)
Delegates to either Math.min(long, long) (Java) or min(long, long) (OpenCL). |
protected double |
pow(double _d1,
double _d2)
Delegates to either Math.pow(double, double) (Java) or pow(double, double) (OpenCL). |
protected float |
pow(float _f1,
float _f2)
Delegates to either Math.pow(double, double) (Java) or pow(float, float) (OpenCL). |
protected double |
rint(double _d)
Delegates to either Math.rint(double) (Java) or rint(double) (OpenCL). |
protected float |
rint(float _f)
Delegates to either Math.rint(double) (Java) or rint(float) (OpenCL). |
protected long |
round(double _d)
Delegates to either Math.round(double) (Java) or round(double) (OpenCL). |
protected int |
round(float _f)
Delegates to either Math.round(float) (Java) or round(float) (OpenCL). |
protected double |
rsqrt(double _d)
Computes inverse square root using Math.sqrt(double) (Java) or delegates to rsqrt(double) (OpenCL). |
protected float |
rsqrt(float _f)
Computes inverse square root using Math.sqrt(double) (Java) or delegates to rsqrt(double) (OpenCL). |
abstract void |
run()
The entry point of a kernel. |
void |
setExecutionMode(Kernel.EXECUTION_MODE _executionMode)
Set the execution mode. |
protected void |
setSizes(int _globalSize,
int _localSize)
A callback that Aparapi will invoke before executing a kernel to set the values of globalSize and localSize. |
protected double |
sin(double _d)
Delegates to either Math.sin(double) (Java) or sin(double) (OpenCL). |
protected float |
sin(float _f)
Delegates to either Math.sin(double) (Java) or sin(float) (OpenCL). |
protected double |
sqrt(double _d)
Delegates to either Math.sqrt(double) (Java) or sqrt(double) (OpenCL). |
protected float |
sqrt(float _f)
Delegates to either Math.sqrt(double) (Java) or sqrt(float) (OpenCL). |
protected double |
tan(double _d)
Delegates to either Math.tan(double) (Java) or tan(double) (OpenCL). |
protected float |
tan(float _f)
Delegates to either Math.tan(double) (Java) or tan(float) (OpenCL). |
protected double |
toDegrees(double _d)
Delegates to either Math.toDegrees(double) (Java) or degrees(double) (OpenCL). |
protected float |
toDegrees(float _f)
Delegates to either Math.toDegrees(double) (Java) or degrees(float) (OpenCL). |
protected double |
toRadians(double _d)
Delegates to either Math.toRadians(double) (Java) or radians(double) (OpenCL). |
protected float |
toRadians(float _f)
Delegates to either Math.toRadians(double) (Java) or radians(float) (OpenCL). |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Kernel()
| Method Detail |
|---|
protected final int getGlobalId()
The kernel implementation uses the globalId to determine which of the executing kernels (in the global domain space) this invocation is expected to deal with.
For example in a SquareKernel implementation:
class SquareKernel extends Kernel{
private int values[];
private int squares[];
public SquareKernel(int values[]){
this.values = values;
squares = new int[values.length];
}
public void run() {
int gid = getGlobalID();
squares[gid] = values[gid]*values[gid];
}
public int[] getSquares(){
return(squares);
}
}
Each invocation of SquareKernel.run() retrieves it's globalId by calling getGlobalId(), and then computes the value of square[gid] for a given value of value[gid].
getLocalId(),
getGroupId(),
getGlobalSize(),
getNumGroups(),
getLocalSize()protected final int getGroupId()
When a Kernel.execute(int globalSize) is invoked for a particular kernel, the runtime will break the work into various 'groups'.
A kernel can use getGroupId() to determine which group a kernel is currently
dispatched to
The following code would capture the groupId for each kernel and map it against globalId.
final int[] groupIds = new int[1024];
Kernel kernel = new Kernel(){
public void run() {
int gid = getGlobalId();
groupIds[gid] = getGroupId();
}
};
kernel.execute(groupIds.length);
for (int i=0; i< values.length; i++){
System.out.printf("%4d %4d\n", i, groupIds[i]);
}
getLocalId(),
getGlobalId(),
getGlobalSize(),
getNumGroups(),
getLocalSize()protected final int getLocalId()
When a Kernel.execute(int globalSize) is invoked for a particular kernel, the runtime will break the work into
various 'groups'.
getLocalId() can be used to determine the relative id of the current kernel within a specific group.
The following code would capture the groupId for each kernel and map it against globalId.
final int[] localIds = new int[1024];
Kernel kernel = new Kernel(){
public void run() {
int gid = getGlobalId();
localIds[gid] = getLocalId();
}
};
kernel.execute(localIds.length);
for (int i=0; i< values.length; i++){
System.out.printf("%4d %4d\n", i, localIds[i]);
}
getGroupId(),
getGlobalId(),
getGlobalSize(),
getNumGroups(),
getLocalSize()protected final int getLocalSize()
When a Kernel.execute(int globalSize) is invoked for a particular kernel, the runtime will break the work into
various 'groups'. getLocalSize() allows a kernel to determine the size of the current group.
Note groups may not all be the same size. In particular, if (global size)%(# of compute devices)!=0, the runtime can choose to dispatch kernels to
groups with differing sizes.
getGroupId(),
getGlobalId(),
getGlobalSize(),
getNumGroups(),
getLocalSize()protected final int getGlobalSize()
Kernel.execute(int globalSize) method.
Kernel.execute(int globalSize) causing the current execution.getGroupId(),
getGlobalId(),
getNumGroups(),
getLocalSize()protected final int getNumGroups()
When Kernel.execute(int globalSize) is invoked, the runtime will split the work into
multiple 'groups'. getNumGroups() returns the total number of groups that will be used.
getGroupId(),
getGlobalId(),
getGlobalSize(),
getNumGroups(),
getLocalSize()public abstract void run()
Every kernel must override this method.
protected Object clone()
If you choose to override clone() you are responsible for delegating to super.clone();
clone in class Objectprotected float acos(float a)
Math.acos(double) (Java) or acos(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
a - value to delegate to Math.acos(double)/acos(float)
Math.acos(double) casted to float/acos(float)Math.acos(double),
acos(float)protected double acos(double a)
Math.acos(double) (Java) or acos(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
a - value to delegate to Math.acos(double)/acos(double)
Math.acos(double)/acos(double)Math.acos(double),
acos(double)protected float asin(float _f)
Math.asin(double) (Java) or asin(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.asin(double)/asin(float)
Math.asin(double) casted to float/asin(float)Math.asin(double),
asin(float)protected double asin(double _d)
Math.asin(double) (Java) or asin(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.asin(double)/asin(double)
Math.asin(double)/asin(double)Math.asin(double),
asin(double)protected float atan(float _f)
Math.atan(double) (Java) or atan(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.atan(double)/atan(float)
Math.atan(double) casted to float/atan(float)Math.atan(double),
atan(float)protected double atan(double _d)
Math.atan(double) (Java) or atan(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.atan(double)/atan(double)
Math.atan(double)/atan(double)Math.atan(double),
atan(double)
protected float atan2(float _f1,
float _f2)
Math.atan2(double, double) (Java) or atan2(float, float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f1 - value to delegate to first argument of Math.atan2(double, double)/atan2(float, float)_f2 - value to delegate to second argument of Math.atan2(double, double)/atan2(float, float)
Math.atan2(double, double) casted to float/atan2(float, float)Math.atan2(double, double),
atan2(float, float)
protected double atan2(double _d1,
double _d2)
Math.atan2(double, double) (Java) or atan2(double, double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d1 - value to delegate to first argument of Math.atan2(double, double)/atan2(double, double)_d2 - value to delegate to second argument of Math.atan2(double, double)/atan2(double, double)
Math.atan2(double, double)/atan2(double, double)Math.atan2(double, double),
atan2(double, double)protected float ceil(float _f)
Math.ceil(double) (Java) or ceil(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.ceil(double)/ceil(float)
Math.ceil(double) casted to float/ceil(float)Math.ceil(double),
ceil(float)protected double ceil(double _d)
Math.ceil(double) (Java) or ceil(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.ceil(double)/ceil(double)
Math.ceil(double)/ceil(double)Math.ceil(double),
ceil(double)protected float cos(float _f)
Math.cos(double) (Java) or cos(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.cos(double)/cos(float)
Math.cos(double) casted to float/cos(float)Math.cos(double),
cos(float)protected double cos(double _d)
Math.cos(double) (Java) or cos(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.cos(double)/cos(double)
Math.cos(double)/cos(double)Math.cos(double),
cos(double)protected float exp(float _f)
Math.exp(double) (Java) or exp(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.exp(double)/exp(float)
Math.exp(double) casted to float/exp(float)Math.exp(double),
exp(float)protected double exp(double _d)
Math.exp(double) (Java) or exp(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.exp(double)/exp(double)
Math.exp(double)/exp(double)Math.exp(double),
exp(double)protected float abs(float _f)
Math.abs(float) (Java) or fabs(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.abs(float)/fabs(float)
Math.abs(float)/fabs(float)Math.abs(float),
fabs(float)protected double abs(double _d)
Math.abs(double) (Java) or fabs(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.abs(double)/fabs(double)
Math.abs(double)/fabs(double)Math.abs(double),
fabs(double)protected int abs(int n)
Math.abs(int) (Java) or abs(int) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
n - value to delegate to Math.abs(int)/abs(int)
Math.abs(int)/abs(int)Math.abs(int),
abs(int)protected long abs(long n)
Math.abs(long) (Java) or abs(long) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
n - value to delegate to Math.abs(long)/abs(long)
Math.abs(long)/abs(long)Math.abs(long),
abs(long)protected float floor(float _f)
Math.floor(double) (Java) or floor(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.floor(double)/floor(float)
Math.floor(double) casted to float/floor(float)Math.floor(double),
floor(float)protected double floor(double _d)
Math.floor(double) (Java) or floor(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.floor(double)/floor(double)
Math.floor(double)/floor(double)Math.floor(double),
floor(double)
protected float max(float _f1,
float _f2)
Math.max(float, float) (Java) or fmax(float, float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f1 - value to delegate to first argument of Math.max(float, float)/fmax(float, float)_f2 - value to delegate to second argument of Math.max(float, float)/fmax(float, float)
Math.max(float, float)/fmax(float, float)Math.max(float, float),
fmax(float, float)
protected double max(double _d1,
double _d2)
Math.max(double, double) (Java) or fmax(double, double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d1 - value to delegate to first argument of Math.max(double, double)/fmax(double, double)_d2 - value to delegate to second argument of Math.max(double, double)/fmax(double, double)
Math.max(double, double)/fmax(double, double)Math.max(double, double),
fmax(double, double)
protected int max(int n1,
int n2)
Math.max(int, int) (Java) or max(int, int) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
n1 - value to delegate to Math.max(int, int)/max(int, int)n2 - value to delegate to Math.max(int, int)/max(int, int)
Math.max(int, int)/max(int, int)Math.max(int, int),
max(int, int)
protected long max(long n1,
long n2)
Math.max(long, long) (Java) or max(long, long) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
n1 - value to delegate to first argument of Math.max(long, long)/max(long, long)n2 - value to delegate to second argument of Math.max(long, long)/max(long, long)
Math.max(long, long)/max(long, long)Math.max(long, long),
max(long, long)
protected float min(float _f1,
float _f2)
Math.min(float, float) (Java) or fmin(float, float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f1 - value to delegate to first argument of Math.min(float, float)/fmin(float, float)_f2 - value to delegate to second argument of Math.min(float, float)/fmin(float, float)
Math.min(float, float)/fmin(float, float)Math.min(float, float),
fmin(float, float)
protected double min(double _d1,
double _d2)
Math.min(double, double) (Java) or fmin(double, double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d1 - value to delegate to first argument of Math.min(double, double)/fmin(double, double)_d2 - value to delegate to second argument of Math.min(double, double)/fmin(double, double)
Math.min(double, double)/fmin(double, double)Math.min(double, double),
fmin(double, double)
protected int min(int n1,
int n2)
Math.min(int, int) (Java) or min(int, int) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
n1 - value to delegate to first argument of Math.min(int, int)/min(int, int)n2 - value to delegate to second argument of Math.min(int, int)/min(int, int)
Math.min(int, int)/min(int, int)Math.min(int, int),
min(int, int)
protected long min(long n1,
long n2)
Math.min(long, long) (Java) or min(long, long) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
n1 - value to delegate to first argument of Math.min(long, long)/min(long, long)n2 - value to delegate to second argument of Math.min(long, long)/min(long, long)
Math.min(long, long)/min(long, long)Math.min(long, long),
min(long, long)protected float log(float _f)
Math.log(double) (Java) or log(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.log(double)/log(float)
Math.log(double) casted to float/log(float)Math.log(double),
log(float)protected double log(double _d)
Math.log(double) (Java) or log(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.log(double)/log(double)
Math.log(double)/log(double)Math.log(double),
log(double)
protected float pow(float _f1,
float _f2)
Math.pow(double, double) (Java) or pow(float, float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f1 - value to delegate to first argument of Math.pow(double, double)/pow(float, float)_f2 - value to delegate to second argument of Math.pow(double, double)/pow(float, float)
Math.pow(double, double) casted to float/pow(float, float)Math.pow(double, double),
pow(float, float)
protected double pow(double _d1,
double _d2)
Math.pow(double, double) (Java) or pow(double, double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d1 - value to delegate to first argument of Math.pow(double, double)/pow(double, double)_d2 - value to delegate to second argument of Math.pow(double, double)/pow(double, double)
Math.pow(double, double)/pow(double, double)Math.pow(double, double),
pow(double, double)
protected float IEEEremainder(float _f1,
float _f2)
Math.IEEEremainder(double, double) (Java) or remainder(float, float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f1 - value to delegate to first argument of Math.IEEEremainder(double, double)/remainder(float, float)_f2 - value to delegate to second argument of Math.IEEEremainder(double, double)/remainder(float, float)
Math.IEEEremainder(double, double) casted to float/remainder(float, float)Math.IEEEremainder(double, double),
remainder(float, float)
protected double IEEEremainder(double _d1,
double _d2)
Math.IEEEremainder(double, double) (Java) or remainder(double, double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d1 - value to delegate to first argument of Math.IEEEremainder(double, double)/remainder(double, double)_d2 - value to delegate to second argument of Math.IEEEremainder(double, double)/remainder(double, double)
Math.IEEEremainder(double, double)/remainder(double, double)Math.IEEEremainder(double, double),
remainder(double, double)protected float toRadians(float _f)
Math.toRadians(double) (Java) or radians(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.toRadians(double)/radians(float)
Math.toRadians(double) casted to float/radians(float)Math.toRadians(double),
radians(float)protected double toRadians(double _d)
Math.toRadians(double) (Java) or radians(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.toRadians(double)/radians(double)
Math.toRadians(double)/radians(double)Math.toRadians(double),
radians(double)protected float toDegrees(float _f)
Math.toDegrees(double) (Java) or degrees(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.toDegrees(double)/degrees(float)
Math.toDegrees(double) casted to float/degrees(float)Math.toDegrees(double),
degrees(float)protected double toDegrees(double _d)
Math.toDegrees(double) (Java) or degrees(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.toDegrees(double)/degrees(double)
Math.toDegrees(double)/degrees(double)Math.toDegrees(double),
degrees(double)protected float rint(float _f)
Math.rint(double) (Java) or rint(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.rint(double)/rint(float)
Math.rint(double) casted to float/rint(float)Math.rint(double),
rint(float)protected double rint(double _d)
Math.rint(double) (Java) or rint(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.rint(double)/rint(double)
Math.rint(double)/rint(double)Math.rint(double),
rint(double)protected int round(float _f)
Math.round(float) (Java) or round(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.round(float)/round(float)
Math.round(float)/round(float)Math.round(float),
round(float)protected long round(double _d)
Math.round(double) (Java) or round(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.round(double)/round(double)
Math.round(double)/round(double)Math.round(double),
round(double)protected float sin(float _f)
Math.sin(double) (Java) or sin(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.sin(double)/sin(float)
Math.sin(double) casted to float/sin(float)Math.sin(double),
sin(float)protected double sin(double _d)
Math.sin(double) (Java) or sin(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.sin(double)/sin(double)
Math.sin(double)/sin(double)Math.sin(double),
sin(double)protected float sqrt(float _f)
Math.sqrt(double) (Java) or sqrt(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.sqrt(double)/sqrt(float)
Math.sqrt(double) casted to float/sqrt(float)Math.sqrt(double),
sqrt(float)protected double sqrt(double _d)
Math.sqrt(double) (Java) or sqrt(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.sqrt(double)/sqrt(double)
Math.sqrt(double)/sqrt(double)Math.sqrt(double),
sqrt(double)protected float tan(float _f)
Math.tan(double) (Java) or tan(float) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.tan(double)/tan(float)
Math.tan(double) casted to float/tan(float)Math.tan(double),
tan(float)protected double tan(double _d)
Math.tan(double) (Java) or tan(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.tan(double)/tan(double)
Math.tan(double)/tan(double)Math.tan(double),
tan(double)protected float rsqrt(float _f)
Math.sqrt(double) (Java) or delegates to rsqrt(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_f - value to delegate to Math.sqrt(double)/rsqrt(double)
( 1.0f / Math.sqrt(double) casted to float )/rsqrt(double)Math.sqrt(double),
rsqrt(double)protected double rsqrt(double _d)
Math.sqrt(double) (Java) or delegates to rsqrt(double) (OpenCL).
User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable.
_d - value to delegate to Math.sqrt(double)/rsqrt(double)
( 1.0f / Math.sqrt(double) ) /rsqrt(double)Math.sqrt(double),
rsqrt(double)
protected int atomicAdd(int[] _arr,
int _index,
int _delta)
_delta value to _index element of array _arr (Java) or delegates to atomic_add(volatile int*, int) (OpenCL).
_arr - array for which an element value needs to be atomically incremented by _delta_index - index of the _arr array that needs to be atomically incremented by _delta_delta - value by which _index element of _arr array needs to be atomically incremented
_index element of _arr arrayatomic_add(volatile int*, int)protected final void localBarrier()
protected void setSizes(int _globalSize,
int _localSize)
globalSize and localSize.
When kernel.execute(globalsSize) is invoked, Aparapi will determine the localSize based on the execution mode
and the globalSize. If you override setSizes( int _globalSize, int _localSize) your overridden method will be called. Your method must call super.setSize(_globalSize, _localSize)
to ensure that the kernel receives the correct value for localSize.
This callback is also useful for initializing arrays based on the known global and local sizes.
_globalSize - _localSize - public long execute(int _globalSize)
globalSize kernels.
When kernel.execute(globalSize) is invoked, Aparapi will schedule the execution of globalSize kernels. If the execution mode is GPU then
the kernels will execute as OpenCL code on the GPU device. Otherwise, if the mode is JTP, the kernels will execute as a pool of Java threads on the CPU.
_globalSize - The number of Kernels that we would like to initiate.public void dispose()
When the execution mode is CPU or GPU, Aparapi stores some OpenCL resources in a data structure associated with the kernel instance. The
dispose() method must be called to release these resources.
If execute(int _globalSize) is called after dispose() is called the results are undefined.
public Kernel.EXECUTION_MODE getExecutionMode()
After a Kernel executes, the return value will be the mode in which the Kernel actually executed.
setExecutionMode(EXECUTION_MODE)public void setExecutionMode(Kernel.EXECUTION_MODE _executionMode)
This should be regarded as a request. The real mode will be determined at runtime based on the availability of OpenCL and the characteristics of the workload.
_executionMode - the requested execution mode.getExecutionMode()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||