Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

TBB stack alignment: trouble w/ GCC 4.3

Chris_Newbold
Beginner
701 Views
We're currently using TBB 2.1 and have run into some trouble while upgrading the compiler used to build our product on 32-bit Linux to GCC 4.3.x. The issue appears to be an incompatibility between GCC and Intel ICC (presumably what is used to build TBB).

GCC expects the stack to be maintained with 16-byte alignment across functions calls in order to facilitate the use of SSE, etc. instructions. With the upgrade to GCC 4.3.x, we are now observing crashes in many of our functions when they are invoked via TBB; investigation reveals that our functions have been called with the stack 8-byte aligned, not 16-byte aligned. (Most of the examples we've seen so far occur when GCC uses the movapd instruction on data which is on the stack.)

Some research turned up this posting about differences in stack alignment discipline between GCC and ICC: http://software.intel.com/en-us/forums/showthread.php?t=66267

Is this a known issue with TBB? Has it been fixed in a later release? GCC 4.3.x is on the list of supported compilers for TBB; how is this supposed to work?

Thanks.

-Chris
0 Kudos
6 Replies
TimP
Honored Contributor III
701 Views
It's so late in the lifetime of 32-bit linux that I wouldn't count on these discrepancies being resolved. I can't speak for the developers of TBB. Perhaps they didn't consider the possibility of TBB calling a function compiled by 32-bit gcc with use of SSE parallel instructions as a part of the documented compatibility, given the impracticality of dealing with the issue. I would expect it to work if you avoided use of parallel instructions in those functions, or built the entire TBB with gcc, as you indicated.
A possible work-around would be to insert a gcc-compiled intermediate wrapper function which doesn't put any SSE data on its own stack, but implicitly adjusts the stack which it passes down to the functions which require aligned stack. Wrapper functions would be in a separate file in case you invoked gcc function in-lining (e.g. -O3).
0 Kudos
ARCH_R_Intel
Employee
701 Views
Thanks for reporting the issue. We certainly intend TBB to work with gcc 4.3 and SSE. Evidently we are missing a unit test for the situation.

The TBB team will take a look and figure out a fix.

- Arch Robison




0 Kudos
Alexey-Kukanov
Employee
701 Views
Meanwhile, could you please check if the most recent TBB 2.2 update works for you? It would be good to know whether building with a newer version of ICC avoids the problem.
0 Kudos
Chris_Newbold
Beginner
701 Views
Thanks for reporting the issue. We certainly intend TBB to work with gcc 4.3 and SSE. Evidently we are missing a unit test for the situation.

The TBB team will take a look and figure out a fix.

- Arch Robison





Thanks, Arch. I expect we'll get someone to open a QUAD case in the next couple of days. In the mean time, we'll download the latest 2.2 release and give that a spin.

-Chris

0 Kudos
Chris_Newbold
Beginner
701 Views
Quoting - tim18
It's so late in the lifetime of 32-bit linux that I wouldn't count on these discrepancies being resolved. I can't speak for the developers of TBB. Perhaps they didn't consider the possibility of TBB calling a function compiled by 32-bit gcc with use of SSE parallel instructions as a part of the documented compatibility, given the impracticality of dealing with the issue. I would expect it to work if you avoided use of parallel instructions in those functions, or built the entire TBB with gcc, as you indicated.
A possible work-around would be to insert a gcc-compiled intermediate wrapper function which doesn't put any SSE data on its own stack, but implicitly adjusts the stack which it passes down to the functions which require aligned stack. Wrapper functions would be in a separate file in case you invoked gcc function in-lining (e.g. -O3).

The fix is actually trivial: the TBB shared libraries just need to be compiled with more conservative stack alignment--there's an ICC compiler flag for doing just this.
0 Kudos
mark_fogleman
Beginner
701 Views
Quoting - Chris Newbold

Thanks, Arch. I expect we'll get someone to open a QUAD case in the next couple of days. In the mean time, we'll download the latest 2.2 release and give that a spin.

-Chris


Working with Chris, I have opened Intel premier support issue 575013.

--Mark
0 Kudos
Reply