Altera_Forum
Honored Contributor
11 years agoProblems casting from int to uchar in OpenCL kernel
Dear Sirs !
I'm using AOC ver 13.1 (recently updated to ver 14) and Terasic DE5-NET device. I've spent much time trying to solve some unusual problem in Altera OpenCL kernel. In kernel I need to calculate some integer values, that are at last 1-byte long and have leading zeros ('cause they are calculated as a reminder of dividing values by 256). Afterwards I try to assign them to uchar variables (array members, or standalone). I've tried both implicit and explicit cast, but in both cases I face the problem that results of kernel work are not correct. Here is the example of casting : int res = doSomeCalc(); // returns int res = res % 256; uchar ures = res; // or uchar ures = (uchar) res; When I run this kernel on GPU, CPU, or in new Altera's x86 emulator (in 14 version of AOC), in all cases kernel works fine. But when I run it on FPGA (DE5-NET) it works wrong. When I change all types in kernel to int to avoid casting, it works on FPGA, too. But in this case (when I apply needed number of steps in main cycle, much more compared to test, which passes ok) kernel uses too much chip resources and does not fit in FPGA. Maybe I miss some important issues about possibilities of using such casting in AOC ? Thanks, Andy