Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Alignment in Named Segments

jim_dempsey
Beginner
375 Views

For Steve Lionel,

I have an alignment problem. Aart suggest I contact you. (getting even for something). Because this problem may affect others I thought it would be suitable for posting on this forum

The crux of the problem is I can specify alignment to the compiler via

!dir$ attributes align: boundary :: symbol

The problem is that the alignment is properly made to a boundary multiple offset from the beginning of a data segment, however the compiler is not outputting an alignment requirement for the data segment itself. This may require closer explanation. When you compile a program or module the compiler generates several output streams. Due to historical reasons these streams are (were in my days) called segments. One would be for code, one for uninitialized data, one for initialized data, one for constants, one for comments (debug symbols), etc

Depending on compilation options these segments would be either unnamed or named. If unnamed then a default name was given but different for each type of segment. And for all programs and modules compiled using unnamed segments they all receive the same name for each of the type of segments. The Linker, collates the input files by segment group name and then name.

If separate names are used for same type of group then the linker dumps the additional members of the group into the same section where the first unnamed segment was loaded. The first unnamed segment was conveniently loaded on a 4KB page boundary (for debugging reasons) or in older days to a paragraph boundary (16Byte). Therefore the alignment directives, which align relative to the start of the (named/unnamed) segment will be aligned as intended provided the data was in an unnamed segment. If the data resides in a named segment then this segment is concatenated with other segments of the same group, but by default moved up to a 4-byte boundary. If the preceding groups were not of a size of a multiple of the alignment requirements of the named segment then the alignment requirements are violated.

So if the aligned structure is in the 1st named (or unnamed) data segment then alignment happens (by luck of draw). If the aligned structure is in a later named data segment then the alignment of the later loaded data segments loads depending on the size of the preceding segments.

Snip from Disassembly (variables are 3 element vectors of REAL(8))

TVXUNT = TOSVX1
004252E2 66 0F 29 05 38 7A 5E 00 movapd xmmword ptr [_MOD_ALL_mp_ALL+20h (5E7A38h)],xmm0
004252EA F2 0F 11 0D 48 7A 5E 00 movsd mmword ptr [_MOD_ALL_mp_ALL+30h (5E7A48h)],xmm1

Note TVXUNT is aligned at 20h relative to _MOD_ALL_mp_ALL but the named data segment _MOD_ALL_mp_ALL is not aligned. deduced by .

_MOD_ALL_mp_ALL+20h = 5E7A38h

By looking at a .MAP file and finding what loads prior to the named data segment _MOD_ALL_mp_ALL I can insert a pad variable in a preceding segment to coerce the alignment. Hack, but it works.

I have been waiting for the Premier Support specialist to have their epiphany.

Jim Dempsey

0 Kudos
2 Replies
Steven_L_Intel1
Employee
375 Views
What's your support case number?
0 Kudos
jim_dempsey
Beginner
375 Views
303116
0 Kudos
Reply