Related articles |
---|
Re: alignment of data-types gah@ugcs.caltech.edu (Glen Herrmannsfeldt) (2003-02-06) |
RE: alignment of data-types onderkarpat@yahoo.com (Onder Karpat) (2003-02-11) |
From: | Onder Karpat <onderkarpat@yahoo.com> |
Newsgroups: | comp.compilers |
Date: | 11 Feb 2003 01:14:29 -0500 |
Organization: | Compilers Central |
References: | 03-02-033 |
Keywords: | architecture, performance |
Posted-Date: | 11 Feb 2003 01:14:29 EST |
Alignment performance depends on target architecture. If architecture
has a set of instructions that has no penalty on accessing unaligned
data you do not need to optimize your code.
If architecture has some specifications on data alignment then it
could be wise to code your program accordingly, see the ABI of
architecture that you are coding for.
Compilers can locate global data in an optimum way but you had better
set the alignment of data explicitly. There might be compiler
extensions to set the alignment of data, both for global and structure
members. GNU has aligned attribute extension. See your compiler
extensions.
Alignment is an issue for not only global variables but also structure
members. For the alignment of structure members just insert the
necessary padding-members for the recommended alignment for a specific
data type that is best as described in the ABI of the
architecture. You can put all your global data in to a structure and
align them with out using alignment extension of compiler.
If your compiler generates "natural alignment", data that is aligned
to its types size, for structure members you do not need to do this
padding at all.
Oender
Return to the
comp.compilers page.
Search the
comp.compilers archives again.