Coder Social home page Coder Social logo

Comments (8)

bassoy avatar bassoy commented on August 20, 2024

Thanks @Faaux.
This should not happen. We will review this bug.

I have a simplified version with no extra additional type using the tensor type: godbolt

Seems that our tests do not include optimization:
travis.yml

from ublas.

bassoy avatar bassoy commented on August 20, 2024

Dear @Faaux
We have discussed this matter in our gitter channel.
This bug is caused by not applying the rule of three for expression template types. With optimization flags, a compiler can optimize the implicitly defined constructors such that const& to values are not copied.

You can prevent such behavior by not copy-constructing expression template objects, as you already have presented in your example.

We will fix this bug with the next releases by restructing and revisiting expression templates with tensors, matrices and vectors. Either we will use Boost.Yap as already presented in our GSoC19 project or fully get rid of expression templates. The GSoC20 project will provide the latest changes for Boost.uBlas.

Thanks.

from ublas.

Faaux avatar Faaux commented on August 20, 2024

Hey @bassoy
Good to hear :)

I was wondering if there is a quick way to determine when this is happening? I am working with a pre-existing code-base and there are possibly quite a lot of situations where this could occur. I have found (by now) three situations where this is happening. This is new to us since we are currently in the process of upgrading Boost to 1.73. This could be breaking for us!

Maybe a patch that deletes the copy-constructor, just to determine where we are using it?

Best,
Faaux

from ublas.

Faaux avatar Faaux commented on August 20, 2024
template<class E1, class E2, class F>
    struct vector_binary_scalar2_traits {
        typedef vector_binary_scalar2<E1, E2, F> expression_type;   // allow E2 to be builtin type
#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG
        typedef expression_type result_type;
#else
        typedef typename E1::vector_temporary_type result_type;
#endif
    };

As in the inital bug report defining BOOST_UBLAS_SIMPLE_ET_DEBUG got rid of the problem as well (even though this might just be in the presented case). Could you confirm this? What would the implications be when we compile with BOOST_UBLAS_SIMPLE_ET_DEBUG?

Thanks again!

Edit: For our use-case it might be possible to overload the according operators. Something like: https://godbolt.org/z/BHLwV9

Am I missing something?

from ublas.

bassoy avatar bassoy commented on August 20, 2024

Hey @bassoy
Good to hear :)

I was wondering if there is a quick way to determine when this is happening?

As you have already found out, the problem occurs when you copy construct an expression template.
I recommend to evaluate the expression instantaneously.

I am working with a pre-existing code-base and there are possibly quite a lot of situations where this could occur. I have found > (by now) three situations where this is happening. This is new to us since we are currently in the process of upgrading Boost to > 1.73. This could be breaking for us!

Maybe a patch that deletes the copy-constructor, just to determine where we are using it?

We are working on a completely new stable solution using Boost.Yap which will be thoroughly tested and more powerful.

Best,
Faaux

from ublas.

Faaux avatar Faaux commented on August 20, 2024

Hey @bassoy,

any update or timeline on this?

from ublas.

bassoy avatar bassoy commented on August 20, 2024

@Faaux thanks for asking.

Yes, we have found the root cause and propose two possible solutions, see #125.
We might fixing this issue for tensor expressions in the develop branch in the next two months.
However, I do not want to promise any timeline for the release in the master branch as we are still in the transition phase from matrix to tensor.

A quick solution is to directly use tensor, matrix or vector objects on the lhs of the expression. This will not slow down your program and you program will produce the correct results.

Hope this helps.

from ublas.

Faaux avatar Faaux commented on August 20, 2024

Thanks for letting me know and glad you found a fix.

Sadly that still is not an option to change a larger codebase and find all instances to change the auto. I have a workaround in place, thanks for your work :)

from ublas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.