mersenneforum.org Turn off GCC sse-using optimizations?
 Register FAQ Search Today's Posts Mark Forums Read

 2016-09-30, 02:27 #1 ewmayer ∂2ω=0     Sep 2002 República de California 2·13·443 Posts Turn off GCC sse-using optimizations? I am trying to debug some inline-asm used in a loop body, and am running into a problem where a simple bit of print-some-variable-values debug code is clobbering key xmm-register data used in the inline-asm data-processing macro I trying to debug. Examination of an assembler-dump of the source file shows what's gong on - In the following simple print of 3 dereferenced pointer values: Code:  printf("\tax = %20.15f, %20.15f, %20.15f\n",*ax0,*ax1,*ax2); Here is what GCC does to deref these: Code:  movsd (%rax), %xmm0 #* ax0, movsd (%rsi), %xmm1 #* ax1, movsd (%rbx), %xmm2 #* ax2, Note the code in question benefits performance-wise from not writing the data in question back to memory at the end of each loop pass and reading them back at beginning of the next (i.e. it only writes-to-mem after the loop finishes, and thus relies on the fact that GCC's implementation of the loop-logic uses no SSE2) - if there is not a simple compiler-options tweak to solve the clobber problem that is what I will have to do. Things I tried: o I can't simply fiddle the xmm-regs in the inline-asm to avoid using xmm0-2 since the code block in question uses as 16 xmm-regs. o Using -O0 does not solve the problem - apparently this is a non-turn-off-able kind of optimization. o Using -mno-sse2 does not work, since it GCC also applies it to all of my SSE2 inline-asm, this yielding a raft of "error: unknown register name ‘xmm0’ in ‘asm’." Any help is appreciated! Last fiddled with by ewmayer on 2016-09-30 at 02:33
 2016-09-30, 03:39 #2 bsquared     "Ben" Feb 2007 1100110110102 Posts Wrap the printf in a my_printf function that resides in another file, then apply -mno-sse2 to that other file? If you have several such statements you can use vprintf to retain variable length arguments lists in your my_printf function. http://www.cplusplus.com/reference/cstdio/vprintf/
 2016-09-30, 04:35 #3 ldesnogu     Jan 2008 France 24·3·11 Posts The x86-64 function calling convention uses xmm registers to pass FP numbers arguments to functions, so I'm afraid there's little you can do :( The only simple way to get around the problem I can think of is to call a function with no parameter, save all regs in that function and then do whatever call you want. Not sure you can do that at gcc level, or if you'll have to write your wrapping function in assembly. Last fiddled with by ldesnogu on 2016-09-30 at 04:38
 2016-09-30, 07:15 #4 ewmayer ∂2ω=0     Sep 2002 República de California 2·13·443 Posts Thanks, guys - I ended up just adding extra load/store code to my inline-asm, as that is the most straightforward of any of the workarounds proposed so far.

 Similar Threads Thread Thread Starter Forum Replies Last Post heliosh Lounge 7 2018-02-02 18:19 Carlo Msieve 1 2011-09-09 20:44 ixfd64 Software 7 2011-02-25 20:05 E_tron Software 8 2006-01-08 15:15 nngs Hardware 0 2005-05-20 01:31

All times are UTC. The time now is 14:25.

Sun Sep 20 14:25:14 UTC 2020 up 10 days, 11:36, 1 user, load averages: 1.48, 1.49, 1.48