Comments (10)
@NamjaeChoi is a relatively new member of the Griffin team, so he works pretty closely with @YaqiWang
from libmesh.
#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.
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.
What could be the other issues than overflow?
from libmesh.
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.
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.
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.
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.
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.
@NamjaeChoi can you double check this?
from libmesh.
Related Issues (20)
- XYDG Meshing Around a Single Disjointed Mesh HOT 5
- Need to turn one assertion into error for loading a mesh
- Make mesh stitcher issue warnings or errors HOT 4
- Add shell matrix handling for CondensedEigenSystem
- build fails: error in format-handler HOT 20
- Cannot compile libmesh in dbg mode HOT 9
- PETSc 3.20 warnings HOT 2
- Missing element quality implementations and more informative error message HOT 1
- Adding an absolute tolerance for the `LinearSolver`-s HOT 4
- More fine-grained alternatives to MeshBase::is_prepared()
- Question regarding FE<Dim,T>::reinit() HOT 4
- We can detect different HDF5 C and CXX libraries
- AMR w/ TET14s HOT 2
- Recompile JIT code if the value type changes HOT 1
- Add `Packing` specializations for Eigen matrix types
- Compilation error: cannot find VTK 9.3.0 HOT 3
- PETSC_RELEASE_GREATER_EQUALS is wrong HOT 4
- error when compiling with OpenMPI 4.1.4 and gcc-12.3.0 HOT 11
- Update Nanoflann to v1.5.0
- FE pre-requests for error estimation HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libmesh.