You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i skimmed through the tests and i have the impression that vector and matrices are initialized to zero at construction.
in many cases this initialization is unwanted, as assignement will happen at a later stage.
this is crucial for example if one wants to do first touching on the entries of the vector to ensure numa locality (that's one of the reasons for which std::vector cannot be used in HPC code)
is there any way of avoiding it?
The text was updated successfully, but these errors were encountered:
I agree that zero initialization of arrays is unnecessary in many cases, even if it goes against STL common practice (misguided in my opinion).
This is particularly true for trivially constructible types, doubles, float, ints, and some user defined types.
(std::complex also, except that STL's complex is defective for not being trivially default constructible).
This is very important for performance of numeric software and also to detect use of uninitialized memory with runtime tests (e.g. with Valgrind).
In my library for arrays https://gitlab.com/correaa/boost-multi , which I am currently testing as storage engine for this proposal, zero initialization is optional for trivially constructible types.
If it serves as a example for this proposal, here it is some behavior example
multi::array<double, 2> A({100, 100}); // array of dimension 2 with uninitialized data, this is ok because double is trivial
multi::array<double, 2> B({100, 100}, {}); // array of dimension 2 with initialized data (to zero)
multi::array<double, 2> C({100, 100}, 99.); // array of dimension 2 with initialized data to 99.
multi::array<std::complex<double>, 2> D({100, 100}); // array of dimension 2 with initialized data (to zero) because std::complex is not trivially constructible
Please let me know if I am missing something. I hope this idiom catches on.
dear developers,
i skimmed through the tests and i have the impression that vector and matrices are initialized to zero at construction.
in many cases this initialization is unwanted, as assignement will happen at a later stage.
this is crucial for example if one wants to do first touching on the entries of the vector to ensure numa locality (that's one of the reasons for which std::vector cannot be used in HPC code)
is there any way of avoiding it?
The text was updated successfully, but these errors were encountered: