Data are overwritten automatically without changing?

Any technical questions about the Epiphany chip and Parallella HW Platform.

Moderator: aolofsson

Data are overwritten automatically without changing?

Postby Richardye » Wed Dec 09, 2015 1:43 pm

Hi guys,

I have met a problem with the Epiphany. I have written some code a little bit same as the example fft2D but strange things happen with my data in the program.
I have used SECTION to put several objects in data bank 2 & 3 but data will change automatically. My epiphany has several functions, in the main function they ared called one by one. But when I comment some functions the value in some objects will change without manually changing. That is really weird. Does anybody know why this will happen?

My own assumption would be bacause the stack overwrites my objects but I have clearly specified the placement of the objects with SECTION. So if it's true,does anyone know how to avoid this ?

Hope someone could help me. Thank you all the same !

Best Regards,
Posts: 8
Joined: Mon Sep 07, 2015 6:30 pm

Re: Data are overwritten automatically without changing?

Postby sebraa » Wed Dec 09, 2015 3:13 pm

If I remember correctly, the stack grows from the end of local memory downwards. So, depending on how full your bank 3 is and how much stack your kernels need, the stack may grow into your data.

Assuming it is really the stack, you basically have three choices:
- Relocate the stack (I haven't done this, though), or
- Put your objects in banks 1 & 2 (and hope that bank 3 is free), or
- Leave some free space at the end of bank 3 and reduce your stack usage.
I allocate big data structures globally and avoid recursion to keep the stack requirements low. A nice side-effect of that is that I get linker errors when I try to overflow memory (stack overflows are not detectable on Epiphany). If you have dynamic requirements, you might want to think about implementing a small heap on top of a statically allocated array.

Also, don't discount the possibility of another core (or the host) destroying your data remotely. Bad pointers can point everywhere (including from/to your host).
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Return to Epiphany and Parallella Q & A

Who is online

Users browsing this forum: Google [Bot] and 3 guests