Aparapi Data Types

I have the following code to learn.

My calculation function gives unexpected results when run on aparapi.

Is there a problem with my code or aparapi?

Results:

Result Num Expected 2026982348 406816880 40681688012 2026982516 406816881 40681688180 2026982594 406816882 40681688258 2026982662 406816883 40681688326 2026982830 406816884 40681688494 2026982898 406816885 40681688562 2026982966 406816886 40681688630 2026983044 406816887 40681688708 2026983212 406816888 40681688876 2026983280 406816889 40681688944 2026983338 406816890 40681689002 2026983506 406816891 40681689170 2026983584 406816892 40681689248 2026983652 406816893 40681689316 2026983820 406816894 40681689484 2026983888 406816895 40681689552 2026983956 406816896 40681689620 2026984134 406816897 40681689798 2026984202 406816898 40681689866 2026984270 406816899 40681689934 

Edit: if I install jQuery executeMode or CPU, I get true results (result == expected), but in GPU mode there is a problem. I am using the latest macbook pro retina with windows 10.

Edit2: The return line of the calculation method causes a problem. If I return Long.MAX_VALUE , it will work. But (long) tc * 100 (or ((long) tc) * 100 ) does not (for example, 40681688900)

+7
java aparapi
source share
2 answers

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.

+2
source share

Hi, I am the main maintainer on the new Aparapi.com and the new github repository. We are working much more actively on the new home of the project and even have about a dozen issues in the central center. You might want to consider upgrading to the new Aparapi.

With that said, I am the developer of the new Aparapi and ran this test case and confirmed that this is a legit Aparapi error. I will examine what causes the error and hopefully can get a bug fix for you before the next version. A problem has been reported here if you want to track it. Keep this in mind for the new Aparapi project, so fixing the error is unlikely to appear in the older Aparapi project.

+1
source share

All Articles