Re: Re: Misalignment of local SSE variables in thread function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




-----Original Message-----
From: Jonathan Kinsey <jon_kinsey@xxxxxxxxxxx>
To: Tim Prince <tprince@xxxxxxxxxxxxx>
Date: Thu, 18 Jan 2007 11:44:46 +0000
Subject: Re: Misalignment of local SSE variables in thread function

Tim Prince wrote:
> Jonathan Kinsey wrote:
>> Tim Prince wrote:
>>  
>>> I don't remember what was said in the past, but any gcc function which
>>> uses SSE parallel instructions must be called from a gcc function which
>>> passes a 16-byte aligned stack.  So you may be able to overcome it by
>>> interposing a wrapper function at the thread entry point (which does not
>>> use parallel SSE), with all gcc functions compiled with normal options
>>> (not -Os, which sets a smaller value in -mpreferred-stack-alignment).
>>> To speculate further, possibly your pthreads library was compiled with
>>> options which don't pass 16-byte aligned stack.
>>>     
>>
>> Thanks for the reply - no help though:
>>
>> By a wrapper function, if you mean for f() to call say g() - this makes
>> no difference (command line: gcc -msse test.c -otest.exe).
>>
>> gcc doesn't seem to recognize -mpreferred-stack-alignment=8 as a valid
>> option.
>>
>> I'm not using pthreads, so it's not that either.
>>
>>
>>   
> Sorry, you should have checked me.  'info gcc'
> -mpreferred-stack-boundary=4     (2^4 == 16) is needed, and would be set
> by options other than -O2.  So, not specifying any relevant options
> should be OK, but the function you call first in the thread must not
> have any sse, if this is the problem.
> I guess I don't understand where you got your function to start a thread.

I found -mpreferred-stack-boundary and -falign-functions options, I
think they both default to 4, so it's not relevant to set these (I'm not
using any optimizations).

I'll take a look at the assembly code and see if anything is different
(between gcc and msvc) for the thread function.  It looks like gcc is
getting the stack four bytes off alignment in the thread function for
some reason.

Jon
_________
As to the question of binutils, if my smtp is working now, cygwin used to build binutils with alignment limited to 4 bytes.  binutils 2.16 gives some encouragement that didn't happen to you, but I haven't seen how it is built for mingw.



Tim Prince


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux