[openbeos] Re: app_server: MMX/SSE help wanted

  • From: Christian Packmann <Christian.Packmann@xxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Mon, 09 Aug 2004 15:49:45 +0200

On 2004-08-09 15:18:31 [+0200], Adi Oanca wrote:

> Now, I have another question(s):
>     If GCC 3, app_server, media_kit and translators will all use MMX, how 
>     can we be sure they won't collide with each other?
>     MMX runs in parallel with the CPU, but which thread has access to MMX 
>     registers? The kernel also 
> manages this? How can MMX be used, do we need a separate thread with MMX 
> loops only?

MMX uses the FP registers to store data; these are saved when a task switch 
occurs. That was the reason to implement MMX this way, so that it would 
work with old operating systems without change.

With SSE and its extra registers, you need special OS support so that the 
registers are correctly stored and recalled during task switches. As long 
as the kernel supports this, no problem.
And if SSE works SSE2 should also work, as it doesn't add new registers, 
but only new commands to work on the 128-bit regs.

>     What about the case where app_server_MMX is compiled with GCC3_MMX ? 
>     Should GCC MMX support be disabled in this case?

Hm? MMX is nothing special, just some new x86 instructions. As long as the 
compiler/assembler supports translating them, there shouldn't be any 
special problems.

Just do not *ever* forget to exit MMX mode with the EMMS instruction after 
using MMX, otherwise the FPU will give useless results on all subsequent 
calls - even if they're not from assembly, but from C++ code. Such a bug 
once took me hours (and a lot of nerves) to find. 

Bye,
Chris

Other related posts: