I think you should revise your code by checking out the Aparapi Java Kernel Guidelines , paying particular attention to other restrictions and Beware of side effects .
Remember to keep the code as simple as possible.
Looking at your code, in the calculate method you widely use the module operator (%). I would advise you to register each calculation in order to be able to compare what you get in JTP mode and what you get in GPU mode to find out if there are any problems with this operator.
EDIT: In your calculation method, you use int variables to store values ββthat can contain numbers up to 2 ^ 31-1, namely 2147483647, as you know, Integer.MAX_VALUE. If you do int value=2147483647; value++; int value=2147483647; value++; , you get the result -2147483648, as you know, Integer.MIN_VALUE.
You can also try your program with lower start numbers or change variable declarations to long, which may contain Long.MAX_VALUE, namely 2 ^ 63-1.
Both long and int are supported by Aparapi.
abarisone
source share