Dual CPU code

Tim M a at b.com
Mon Feb 2 16:29:57 PST 2009


On Tue, 03 Feb 2009 00:31:17 +1300, bearophile <bearophileHUGS at lycos.com>  
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 the sort thing you are looking for:  
http://www.songho.ca/misc/sse/sse.html




More information about the Digitalmars-d mailing list