diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/Kernel.java b/com.amd.aparapi/src/java/com/amd/aparapi/Kernel.java index eeb2ef7ff13469f3fdb2743caf3c29870f3e8d47..708005ccde41337bd9e23bf26fb84043a632e2db 100644 --- a/com.amd.aparapi/src/java/com/amd/aparapi/Kernel.java +++ b/com.amd.aparapi/src/java/com/amd/aparapi/Kernel.java @@ -970,6 +970,9 @@ public abstract class Kernel implements Cloneable { * @see #execute(String, Range, int) */ public void cancelMultiPass() { + if (kernelRunner == null) { + return; + } kernelRunner.cancelMultiPass(); } @@ -982,11 +985,21 @@ public abstract class Kernel implements Cloneable { */ public int getCurrentPass() { if (kernelRunner == null) { - return KernelRunner.PASS_ID_PREPARING_EXECUTION; + return KernelRunner.PASS_ID_COMPLETED_EXECUTION; } return kernelRunner.getCurrentPass(); } + /** + * @see KernelRunner#isExecuting() + */ + public boolean isExecuting() { + if (kernelRunner == null) { + return false; + } + return kernelRunner.isExecuting(); + } + /** * When using a Java Thread Pool Aparapi uses clone to copy the initial instance to each thread. * diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/internal/kernel/KernelRunner.java b/com.amd.aparapi/src/java/com/amd/aparapi/internal/kernel/KernelRunner.java index ddf94ea2643f85127847574a2ae3fcc7e8fadb29..c2b69e44f1cb3564fa00d82c632d861c5ae93986 100644 --- a/com.amd.aparapi/src/java/com/amd/aparapi/internal/kernel/KernelRunner.java +++ b/com.amd.aparapi/src/java/com/amd/aparapi/internal/kernel/KernelRunner.java @@ -1382,8 +1382,9 @@ public class KernelRunner extends KernelRunnerJNI{ /** * Returns the index of the current pass, or one of two special constants with negative values to indicate special progress states. Those constants are - * {@link #PASS_ID_PREPARING_EXECUTION} to indicate that the Kernel has not yet started executing, or {@link #PASS_ID_COMPLETED_EXECUTION} to indicate that - * execution is complete (possibly due to early termination via {@link #cancelMultiPass()}). + * {@link #PASS_ID_PREPARING_EXECUTION} to indicate that the Kernel has started executing but not reached the initial pass, or + * {@link #PASS_ID_COMPLETED_EXECUTION} to indicate that execution is complete (possibly due to early termination via {@link #cancelMultiPass()}), i.e. the Kernel + * is idle. {@link #PASS_ID_COMPLETED_EXECUTION} is also returned before the first execution has been invoked. * * <p>This can be used, for instance, to update a visual progress bar. * @@ -1404,6 +1405,13 @@ public class KernelRunner extends KernelRunnerJNI{ } } + /** + * True while any of the {@code execute()} methods are in progress. + */ + public boolean isExecuting() { + return executing; + } + protected int getCurrentPassRemote() { return outBufferRemoteInt.get(0); }