[Numpy-discussion] Proposed Roadmap Overview

xavier.gnata@gmai... xavier.gnata@gmai...
Sun Feb 19 10:13:39 CST 2012


On 02/19/2012 04:48 PM, Sturla Molden wrote:
> Den 19.02.2012 10:28, skrev Mark Wiebe:
>> Particular styles of using templates can cause this, yes. To properly
>> do this kind of advanced C++ library work, it's important to think
>> about the big-O notation behavior of your template instantiations, not
>> just the big-O notation of run-time. C++ templates have a
>> turing-complete language (which is said to be quite similar to
>> haskell, but spelled vastly different) running at compile time in
>> them. This is what gives template meta-programming in C++ great power,
>> but since templates weren't designed for this style of programming
>> originally, template meta-programming is not very easy.
>>
>>
> The problem with metaprogramming is that we are doing manually the work
> that belongs to the compiler. Blitz++ was supposed to be a library that
> "thought like a compiler". But then compilers just got better. Today, it
> is no longer possible for a numerical library programmer to outsmart an
> optimizing C++ compiler. All metaprogramming can do today is produce
> error messages noone can understand. And the resulting code will often
> be slower because the compiler has less opportunities to do its work.
>
> Sturla
"Today, it is no longer possible for a numerical library programmer to 
outsmart an optimizing C++ compiler."
I'm no sure. If you want to be able to write A=B+C+D; with decent 
performances, I think you have to use a lib based on expression templates.
It would be great if C++ compilers could automatically optimize out 
spurious copies into temporaries.
However, I don't think the compilers are smart enough to do so...not yet.

Xavier


More information about the NumPy-Discussion mailing list