-
Enums Enum Description com.aparapi.Kernel.EXECUTION_MODE It is no longer recommended thatEXECUTION_MODEs are used, as a more sophisticatedDevicepreference mechanism is in place, seeKernelManager. ThoughKernel.setExecutionMode(EXECUTION_MODE)is still honored, the default EXECUTION_MODE is nowKernel.EXECUTION_MODE.AUTO, which indicates that the KernelManager will determine execution behaviours.The execution mode ENUM enumerates the possible modes of executing a kernel. One can request a mode of execution using the values below, and query a kernel after it first executes to determine how it executed.
Aparapi supports 5 execution modes. Default is GPU.
Enum value Execution GPUExecute using OpenCL on first available GPU device ACCExecute using OpenCL on first available Accelerator device CPUExecute using OpenCL on first available CPU device JTPExecute using a Java Thread Pool (one thread spawned per available core) SEQExecute 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.codegen.executionModecan be set to one ofJTP,GPU,ACC,CPU,SEQwhen an application is launched.java -classpath ....;codegen.jar -Dcom.codegen.executionMode=GPU MyApplicationGenerally 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.
-
Fields Field Description com.aparapi.Kernel.currentMode com.aparapi.Kernel.executionMode com.aparapi.Kernel.executionModes
-
Methods Method Description com.aparapi.device.Device.best() com.aparapi.device.Device.bestACC() com.aparapi.device.Device.bestGPU() com.aparapi.device.Device.first(Device.TYPE) com.aparapi.device.Device.firstCPU() com.aparapi.device.Device.firstGPU() com.aparapi.internal.kernel.KernelManager.DeprecatedMethods.bestACC() com.aparapi.internal.kernel.KernelManager.DeprecatedMethods.bestGPU() com.aparapi.internal.kernel.KernelManager.DeprecatedMethods.firstDevice(Device.TYPE) com.aparapi.Kernel.addExecutionModes(Kernel.EXECUTION_MODE...) SeeKernel.EXECUTION_MODE.set possible fallback path for execution modes. for example setExecutionFallbackPath(GPU,CPU,JTP) will try to use the GPU if it fails it will fall back to OpenCL CPU and finally it will try JTP.
com.aparapi.Kernel.EXECUTION_MODE.getDefaultExecutionModes() com.aparapi.Kernel.getExecutionMode() SeeKernel.EXECUTION_MODEReturn the current execution mode. Before a Kernel executes, this return value will be the execution mode as determined by the setting of the EXECUTION_MODE enumeration. By default, this setting is either GPU if OpenCL is available on the target system, or JTP otherwise. This default setting can be changed by calling setExecutionMode().
After a Kernel executes, the return value will be the mode in which the Kernel actually executed.
com.aparapi.Kernel.hasNextExecutionMode() com.aparapi.Kernel.setExecutionMode(Kernel.EXECUTION_MODE) SeeKernel.EXECUTION_MODESet the execution mode.
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.
com.aparapi.Kernel.setFallbackExecutionMode() com.aparapi.Kernel.tryNextExecutionMode() SeeKernel.EXECUTION_MODE. try the next execution path in the list if there aren't any more than give up