[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Parallella Community • View topic - Unnecessary Struct Padding?

Unnecessary Struct Padding?

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

Unnecessary Struct Padding?

Postby eoghanoh » Mon Feb 17, 2014 12:58 pm

eoghanoh
 
Posts: 23
Joined: Mon Dec 17, 2012 3:22 am

Re: Unnecessary Struct Padding?

Postby shodruk » Mon Feb 17, 2014 2:11 pm

Last edited by shodruk on Wed Feb 19, 2014 7:54 am, edited 1 time in total.
Shodruky
shodruk
 
Posts: 464
Joined: Mon Apr 08, 2013 7:03 pm

Re: Unnecessary Struct Padding?

Postby ysapir » Mon Feb 17, 2014 3:19 pm

Unfortunately, he GCC does not behave exactly the same on all machines when it comes to aligning structure members. I had the same problem in the past, and one should be aware of that when transferring data between the agents. AFAICT, packing is the only fail-safe mechanism for solving that.

But there is a caveat here as well: if your structure contains pointers, and your host runs a 64-bit system, then pointer sizes on host and device will be different, as the Epiphany uses 32-bit pointers. This can be a major source for headaches and hard to track down. Fortunately, this is not the case on Parallella, where the ARM host is a 32-bit machine.
User avatar
ysapir
 
Posts: 393
Joined: Tue Dec 11, 2012 7:05 pm

Re: Unnecessary Struct Padding?

Postby shodruk » Mon Feb 17, 2014 4:12 pm

Ah, yes. We should look into this more.
Shodruky
shodruk
 
Posts: 464
Joined: Mon Apr 08, 2013 7:03 pm

Re: Unnecessary Struct Padding?

Postby 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.
eoghanoh
 
Posts: 23
Joined: Mon Dec 17, 2012 3:22 am

Re: Unnecessary Struct Padding?

Postby timpart » Tue Feb 18, 2014 12:21 pm

If structs are aligned on 8 byte boundaries then the compiler can do a double word load to get both of the first two words at once for instance. Does this issue have any connection with the workaround fixes for ? Just speculation on my part.

Tim
timpart
 
Posts: 302
Joined: Mon Dec 17, 2012 3:25 am
Location: UK

Re: Unnecessary Struct Padding?

Postby amylaar » Wed Feb 19, 2014 4:36 pm

Structs of size 8 bytes or larger are aligned to 8 bytes (in the absence of an attribute that says otherwise) precisely to allow the use of ldrd / strd.
amylaar
 
Posts: 31
Joined: Thu Jan 10, 2013 3:06 pm

Re: Unnecessary Struct Padding?

Postby jeremybennett » Wed Feb 19, 2014 5:33 pm

User avatar
jeremybennett
 
Posts: 61
Joined: Mon Dec 17, 2012 9:06 am


Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 12 guests

cron