Open timmoon10 opened 7 years ago
With these changes, I'm getting a lot of warnings about narrowing casts.
(Background/refresher: fundamental C++ types and fixed-width integer types)
Just to add some context for this discussion, these are our main sources/issues with integers, as far as I can recall:
El::Int
to be either int
or long long
depending on our compile-time flags. (There is also El::Unsigned
.) We want to use El::Int
when interacting with Elemental matrices.std::vector
) tends to use size_t
for just about any size-related quantity. This can lead to us either narrowing a size_t
or comparing signed/unsigned integers.int
.int
.Ideally, we should come up with a consistent use of integers that satisfies all of these.
Edit: An additional thought: while we don't want to do it for production, we could compile with -ftrapv
, which will trap for signed overflow on addition, subtraction, and multiplication.
As of d2c414a1846b072ea6607c85a0254c5b1277d4e7,
int
is the standard integer data type. However, we may need 64-bit integers for very large matrices. Variables susceptible to overflow should be changed toEl::Int
. As a rule of thumb, indices into Elemental matrices should beEl::Int
s.