java - Aparapi data types -


i have following code studying.

my calculate function produces unexpected results when runs on aparapi.

is there problem code, or aparapi?

results are;

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 set executionmode jtp or cpu, true results (result == expected) on gpu mode there problem. i'm using late 2013 macbook pro retina windows 10.

edit2: return line of calculate method causes problem. if return long.max_value, works. (long) tc * 100 (or ((long) tc) * 100) not giving (eg. 40681688900)

i think should review code checking against aparapi java kernel guidelines, expecially paying attention other restrictions , beware of side effects sections.

remember keep code simpler can.

looking code, in calculate method make wide use of modulus (%) operator. suggest log each calculation in order able compare in jtp mode , in gpu mode, in order find out if there issues operator.

edit: in calculate method use int variables hold values, may hold numbers till 2^31-1, namely 2147483647 known integer.max_value. if perform int value=2147483647; value++; result -2147483648 known integer.min_value.

you can alternatively try program lower starting numbers or change variable declarations long, may hold long.max_value, namely 2^63-1.

both long , int values supported aparapi.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -