by eoghanoh » Mon Feb 17, 2014 5:29 pm
Thanks shodruk and ysapir for the responses.
Some quick mental arithmetic tells me that packing to 8 will indeed work.
I spent a good few hours yesterday trying to track down this low-level bug. I checked the SDK manual and believed this was not the issue because the SDK manual says:
"A.2.2 Composite Types
In additional to the fundamental data types described previously, the Epiphany supports composite types, which are a collection of one or more fundamental data types that can be processed as a single entity during procedure calls. Each one of the composite types may contain composite types and/or fundamental data types as members.
Aggregates
An aggregate is a type with members that are laid out sequentially in memory. The alignment of the aggregate shall be the alignment of its most aligned component. The size of the aggregate shall be the smallest multiple of its alignment that is sufficient to hold all of its members when they are laid out according to these rules.
Unions
A union is a composite type, where each of the members has the same address. The alignment of a union shall be the alignment of its most-aligned component. The size of a union shall be the smallest multiple of its alignment that is sufficient to hold its largest member. Structures and unions are laid out according to the fundamental data types of which they are composed. All members are laid out in declaration order.
Arrays
An array is a repeated sequence of some other type (its base type). The alignment of an array shall be the alignment of its base type. The size of an array shall be the size of the base type multiplied by the number of elements in the array."
Based on this, I didn't think it would be packing as I thought it would be aligning everything to 4 bytes. Can you tell me ysapir, why do structs need to be 8-aligned? Is it something to do with a memory channel bandwidth or such like? I understand that that's how it is and I must code accordingly, but I am curious to know.
Or, if it's the case that they don't actually need to be 8-aligned on Epiphany, but that e-gcc is just doing it, what are the chances of that being changed in e-gcc? These wasted extra padding bytes could add up significantly with arrays of structs etc.
Thanks,
Eoghan.