CFD-GO / TCLB

TCLB - Templated MPI+CUDA/CPU Lattice Boltzmann code
https://tclb.io
GNU General Public License v3.0
177 stars 70 forks source link

Correcting the size calculation in allocation of CartLattice's FTabs #497

Closed llaniewski closed 7 months ago

llaniewski commented 7 months ago

If one want to calculate (potentially) huge product of int-s, you should do:

int nx,ny,nz;
size_t n = (size_t) nx*ny*nz;

which is equivalent to:

size_t n = ((((size_t) nx)*ny)*nz);

which is different than:

size_t n = (size_t) (nx*ny*nz);

which first multiplied (overflows) and then converts.

Fixes #496

codecov-commenter commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (928c436) 39.64% compared to head (ee66429) 88.92%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #497 +/- ## ============================================ + Coverage 39.64% 88.92% +49.27% ============================================ Files 184 4 -180 Lines 8483 343 -8140 ============================================ - Hits 3363 305 -3058 + Misses 5120 38 -5082 ``` | [Flag](https://app.codecov.io/gh/CFD-GO/TCLB/pull/497/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CFD-GO) | Coverage Δ | | |---|---|---| | [d2q9](https://app.codecov.io/gh/CFD-GO/TCLB/pull/497/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CFD-GO) | `?` | | | [d3q27_PSM_NEBB](https://app.codecov.io/gh/CFD-GO/TCLB/pull/497/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CFD-GO) | `?` | | | [d3q27_pf_velocity](https://app.codecov.io/gh/CFD-GO/TCLB/pull/497/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CFD-GO) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CFD-GO#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.