64-bit and SSE

Robert Jacques sandford at jhu.edu
Tue Mar 2 20:07:17 PST 2010


On Tue, 02 Mar 2010 23:01:01 -0500, Rainer Deyke <rainerd at eldwood.com>  
wrote:

> On 3/2/2010 14:28, Don wrote:
>> retard wrote:
>>> Why not dynamic code path selection:
>>>
>>> if (cpu_capabilities && SSE4_2)
>>>   run_fast_method();
>>> else if (cpu_capabilities && SSE2)
>>>   run_medium_fast_method();
>>> else
>>>   run_slow_method();
>>>
>>> One could also use higher level design patterns like abstract
>>> factories here.
>>
>> The method needs to be fairly large for that to be beneficial. For
>> fine-grained stuff, like basic operations on 3D vectors, it doesn't work
>> at all. And that's one of the primary use cases for SSE.
>
> Why not do it at the largest possible level of granularity?
>
> int main() {
>   if (cpu_capabilities && SSE4_2) {
>     return run_fast_main();
>   } else if (cpu_capabilities && SSE2) {
>     return run_medium_fast_main();
>   } else {
>     return run_slow_main();
>   }
> }
>
> The compiler should be able to do this automatically by compiling every
> single function in the program N times with N different code generation
> setting.  Executable size will skyrocket, but it won't matter because
> executable size is rarely a significant concern.
>
>

That's great until you start linking, or worse, dynamically linking. Then  
you run into some major problems.



More information about the Digitalmars-d mailing list