BoostGSoC18 / tensor

Adding tensor support to boostorg/ublas
4 stars 1 forks source link

Expression Templates #11

Open bassoy opened 6 years ago

bassoy commented 6 years ago

Expression templates are used in uBLAS for avoiding temporary objects to be generated and copied in expressions, finally to reduce the runtime of such expressions.

However, with C++11 and C++14 standards copy elision is possible where the copy and move constructors can be omited by the compiler, resulting in zero-copy pass-by-value semantics. The C++17 standard even guarantees copy elision.

Moreover, the current implementation of matrix-vector and matrix-matrix products in expressions are implemented in a row-by-column style where the spatial and temporal data locality are not preserved for the sake of avoiding temporary objects.

Does this really help to reduce the runtime costs?

stefanseefeld commented 6 years ago

I'm not entirely sure I understand the question, or at least, the scope of the question. Are you asking whether expression templates are useful for Boost.UBlas ? Or are you asking about a specific implementation of matrix/vector and matrix/matrix products ?

(As to your point about expression templates, I don't think that the availability of return-value optimizations renders them useless, as their use goes far beyond the elision of temporaries.)

bassoy commented 6 years ago

I am asking whether expression templates are useful for Boost.uBlas as they are implemented right now.