public static enum Kernel.EXECUTION_MODE extends java.lang.Enum<Kernel.EXECUTION_MODE>
Aparapi supports 4 execution modes.
Enum value | Execution |
---|---|
GPU | Execute using OpenCL on first available GPU device |
CPU | Execute using OpenCL on first available CPU device |
JTP | Execute using a Java Thread Pool (one thread spawned per available core) |
SEQ | Execute using a single loop. This is useful for debugging but will be less performant than the other modes |
To request that a kernel is executed in a specific mode, call Kernel.setExecutionMode(EXECUTION_MODE)
before the
kernel first executes.
int[] values = new int[1024]; // fill values array SquareKernel kernel = new SquareKernel(values); kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); kernel.execute(values.length);
Alternatively, the property com.amd.aparapi.executionMode
can be set to one of JTP,GPU,CPU,SEQ
when an application is launched.
java -classpath ....;aparapi.jar -Dcom.amd.aparapi.executionMode=GPU MyApplication
Generally setting the execution mode is not recommended (it is best to let Aparapi decide automatically) but the option provides a way to compare a kernel's performance under multiple execution modes.
Enum Constant and Description |
---|
CPU
The value representing execution on a CPU device via OpenCL.
|
GPU
The value representing execution on a GPU device via OpenCL.
|
JTP
The value representing execution on a Java Thread Pool.
|
NONE
A dummy value to indicate an unknown state.
|
SEQ
The value representing execution sequentially in a single loop.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isOpenCL() |
static Kernel.EXECUTION_MODE |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static Kernel.EXECUTION_MODE[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Kernel.EXECUTION_MODE NONE
public static final Kernel.EXECUTION_MODE GPU
public static final Kernel.EXECUTION_MODE CPU
Note not all OpenCL implementations support OpenCL compute on the CPU.
public static final Kernel.EXECUTION_MODE JTP
By default one Java thread is started for each available core and each core will execute globalSize/cores
work items.
This creates a total of globalSize%cores
threads to complete the work.
Choose suitable values for globalSize
to minimize the number of threads that are spawned.
public static final Kernel.EXECUTION_MODE SEQ
This is meant to be used for debugging a kernel.
public static Kernel.EXECUTION_MODE[] values()
for (Kernel.EXECUTION_MODE c : Kernel.EXECUTION_MODE.values()) System.out.println(c);
public static Kernel.EXECUTION_MODE valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant
with the specified namejava.lang.NullPointerException
- if the argument is nullpublic boolean isOpenCL()