Page 1 of 1
Think I found a bug in the compiler for Epiphany

Posted:
Fri Jul 24, 2015 4:15 pm
by capnrob97
Example
float f = -0.73; // Not this simple, see post below
int d = (int) f;
Looks like d = -1 on the epiphany when it should be 0
(int) should round towards 0, it is behaving like floor() it looks like.
Re: Think I found a bug in the compiler for Epiphany

Posted:
Fri Jul 24, 2015 4:33 pm
by capnrob97
Not quite this simple.
When I pass a float back to the ArM processor in a memory address, I get -0.737241
If I cast that same float variable holding the negative float to an int and pass the int back via a memory address, the ARM shows -1
Similar code running on my Mac has 0 after running the same calcs and that cast, so not sure if the e_read() is to blame, or somewhere else on the epiphany side.
If I hard code a float on the epiphany to -0.737241, and cast to an int and pass it back to arm (arm does an e_read()) I get 0
If I pass that float back to the arm I get -0.737241
If I cast the float variable that passes back -0.737241 to an int and pass back the int, I get -1
Not sure where in the chain something is getting screwed up
Re: Think I found a bug in the compiler for Epiphany

Posted:
Fri Jul 24, 2015 5:02 pm
by aolofsson
Re: Think I found a bug in the compiler for Epiphany

Posted:
Fri Jul 24, 2015 5:16 pm
by capnrob97
Re: Think I found a bug in the compiler for Epiphany

Posted:
Fri Jul 24, 2015 5:27 pm
by aolofsson
Posting a code snippet would be helpful. Not able to reproduce it with any compiler flags on the e-run functional simulator.
(Either there is a mismatch between simulator/hardware or there is something else going on.)
Andreas
Re: Think I found a bug in the compiler for Epiphany

Posted:
Fri Jul 24, 2015 5:43 pm
by capnrob97
I will send it in a little while, work crisis just erupted
Re: Think I found a bug in the compiler for Epiphany

Posted:
Fri Jul 24, 2015 6:23 pm
by capnrob97
Just send a tar gzipped file of the code to andreas at adapteva account.
Probably easier for you to compile it that posting code snippets
You will see I am returning the float var and the (int) var back to the ARM, arm is getting -1
Re: Think I found a bug in the compiler for Epiphany

Posted:
Fri Jul 24, 2015 11:29 pm
by capnrob97
This is where I am returning the float and (int) float
s1 = series (1, pos);
s2 = series (4, pos);
s3 = series (5, pos);
s4 = series (6, pos);
pid = 4.0 * s1 - 2.0 * s2 - s3 - s4;
(*(f)) = pid;
(*(d)) = (int) pid;
When this code prints them out
e_read(&dev, row, col, 0x2000, &d, sizeof(int));
e_read(&dev, row, col, 0x3000, &f, sizeof(float));
printf ("%.8s - %d - %f\n", c, d, f);
fflush(stdout);
I get 00000000 - -1 - -0.737241
Hopefully not just a stupid byte alignement thing I am missing, but I don't think so.
If I add 2.0 to pid before returning the float and the int, I get the expected results
00000000 - 1 - 1.262759
Re: Think I found a bug in the compiler for Epiphany

Posted:
Sat Jul 25, 2015 6:00 pm
by capnrob97
I put some code in for now to get past this.
Until I create a very stripped down program that recreates this with nothing else going on in the code, I am going to assume something in my code going on triggering this.
After I get my program functioning completely the way I want, I will circle around and try to create a simple program that does this issue.