Giter Site home page Giter Site logo

Comments (10)

lindsayad avatar lindsayad commented on June 29, 2024 3

@NamjaeChoi is a relatively new member of the Griffin team, so he works pretty closely with @YaqiWang

from libmesh.

jwpeterson avatar jwpeterson commented on June 29, 2024 1
#include <iostream>
#include <limits>
#include <cmath>

// This is a test to see if there is overflow in a temporary
// calculation used to initialize a member variable.
// https://github.com/libMesh/libmesh/issues/3541
struct Test
{
public:
  Test(unsigned int row_i, unsigned int size) :
    end_location(row_i * size + size - 1)
    {}
  
  const std::size_t end_location;
};

int main()
{
  Test t0(128, 128);
  std::cout << t0.end_location << std::endl; // prints 16511

  unsigned int large = std::sqrt(std::numeric_limits<unsigned int>::max()) - 1;
  Test t1(large, large); 
  std::cout << t1.end_location << std::endl; // prints 4294770689

  Test t2(65536, 65536); 
  std::cout << t2.end_location << std::endl; // should print 4295032831, but prints 65535 instead
  
  return 0;
}

OK, I think I am wrong. I tried this test, and the intermediate row_i * size calculation is apparently done as an unsigned int and overflows.

from libmesh.

jwpeterson avatar jwpeterson commented on June 29, 2024

We could probably switch to using std::size_t when referring to the number of variables, but I think you will likely run into lots of other issues if you try to solve an actual problem with > 65536 vars.

from libmesh.

NamjaeChoi avatar NamjaeChoi commented on June 29, 2024

What could be the other issues than overflow?

from libmesh.

jwpeterson avatar jwpeterson commented on June 29, 2024

I think just general slowness mostly. @YaqiWang could possibly comment further on this, since he has used libMesh (via MOOSE) to solve problems with thousands (but I think not 10s of thousands) of variables. We fixed some of the slowness issues for him, but I'd be willing to bet there are others.

from libmesh.

jwpeterson avatar jwpeterson commented on June 29, 2024

Also, just to mention so that we are on the same page, the number of variables in libMesh is not the same thing as the number of unknowns (DOFs) you can solve for, which can obviously be much more.

from libmesh.

NamjaeChoi avatar NamjaeChoi commented on June 29, 2024

Yeah, we are on the same page. The number of variables is fairly large in neutronics applications, which is determined as the number of directions multiplied by the number of energy groups.

from libmesh.

YaqiWang avatar YaqiWang commented on June 29, 2024

The number of variables itself does not cause overflow. The places we need to be careful where square of it appears for example should be limited. I think with a test case, we can find those places.

from libmesh.

jwpeterson avatar jwpeterson commented on June 29, 2024

OK, so in the specific line you mentioned,

    _end_location(_row_i*_mat.size()+_mat.size()-1)

I don't think there is overflow because _end_location is already std::size_t:

  const std::size_t _end_location;

Even though _row_i is an unsigned int, the compiler "upgrades" the temporary result of _row_i*_mat.size() to a std::size_t.

from libmesh.

YaqiWang avatar YaqiWang commented on June 29, 2024

@NamjaeChoi can you double check this?

from libmesh.

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.