Misalignment of local SSE variables in thread function

Tim Prince tprince@myrealbox.com
Thu Jan 18 11:29:00 GMT 2007


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.



More information about the Gcc-help mailing list