SIMD benchmark

Michel Fortin michel.fortin at michelf.com
Mon Jan 16 11:27:24 PST 2012


On 2012-01-16 17:57:14 +0000, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> On 1/16/12 11:32 AM, Michel Fortin wrote:
>> Andrei's idea could be valid as an optimization when the compiler can
>> see that all the operations can be performed with SIMD ops. In this
>> particular case: if test1a(a) is inlined. But it can't work if the
>> float[4] value crosses a function's boundary.
> 
> In this case it's the exact contrary: the float[4] and the operation 
> are both local to the function. So it all depends on the inlining of 
> the dummy functions that follows. No?

That's exactly what I meant, if everything is local to the function you 
might be able to optimize. In this particular case, if test1a(a) is 
inlined, everything is local.

But the current example has too much isolation for it to be meaningful. 
If you returned the result as a float[4] the the optimization doesn't 
work. If you took an argument as a float[4] it probably wouldn't work 
either (depending on what you do with the argument). So I don't think 
its an optimization you should count on very much.

In fact, the optimization I'd expect the compiler to do in this case is 
just wipe out all the code, as it does nothing other than putting a 
value in a local variable which is never reused later.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list