Dual CPU code

Don nospam at nospam.com
Mon Feb 2 04:28:41 PST 2009


bearophile wrote:
> This comes after a small discussion I've had in the #D IRC channel.
> 
> I have seen that the LDC compiler is much more efficient if you use SSE(2) extensions, while it's not much efficient if you don't use them (GCC/GDC don't seem so much sensitive to the presence of the SSE extensions).
> 
> I often have to switch from an old and a new CPU, so if I compile with SSE2 extensions the program doesn't run on the old CPU, while if I don't use them, I sometimes have a program that goes much slower on the newer CPU.
> 
> So, it may be useful to have a way to build executables able to run well on both CPUs (Apple has done something like this two or more times in the past). There are several ways to do this, a solution is to compile just critical functions for different CPUs, but that may require compiler support.
> My executables are generally small, so doubling their size isn't a problem. So a simple solution is to bundle two whole executables into an executable and add a small header that looks for the current CPU, and runs the right executable.
> 
> Notice that the problem I have shown isn't limited to SSE2, it's more common, for example in the close future you may want code compiled for the GPU and/or CPU, etc.
> 
> Bye,
> bearophile

Is this mostly integer, or floating point code?



More information about the Digitalmars-d mailing list