-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix overflow when calling parsec_data_create #646
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think that the right approach is to make bsiz
size_t
.
Also, the build failure is legit (stemming from the added assert):
/tmp/parsec/parsec/parsec/data_dist/matrix/matrix.c: In function 'parsec_tiled_matrix_init':
/tmp/parsec/parsec/parsec/data_dist/matrix/matrix.c:98:31: error: 'INT_MAX' undeclared (first use in this function)
98 | assert((size_t)mb * nb <= INT_MAX);
| ^~~~~~~
/tmp/parsec/parsec/parsec/data_dist/matrix/matrix.c:19:1: note: 'INT_MAX' is defined in header '<limits.h>'; did you forget to '#include <limits.h>'?
18 | #include "parsec/data_dist/matrix/two_dim_tabular.h"
+++ |+#include <limits.h>
149097d
to
6daca66
Compare
I'm not sure whether there is potential side-effect as @abouteiller pointed out. |
INT_MAX is not a size_t so even with the correct header the compiler will generate a warning and the comparison will be done in the lesser precisions. You really intend to create data that is over 2GB ? |
Unless we pass a pointer to
The |
A quick grep showed no place where we pass a pointer to
and in |
Rule 6.3.1.1 applies here:
The conversion will always work here because we are dealing with a constant with a positive value. |
Yeah, each timeslot includes L^2/2 ZGEMV. the size of each vector is L. Those L^2/2 number of vectors are stored in a file, so I'm loading them together. L can be 720 or 1440. If L = 720, then 720^2/2 * 720 * sizeof(complex double) = 2,985,984,000 |
Yes, others directly related to |
Any suggestions? Changing |
Let's run through this text:
So yes, this rule applies:
This requires that Now, if we were to compare
Things that encode counts should be |
@devreal I'm confused by your comment, because it started as a stark contradiction to my statement in the end it basically states exactly the same thing. 😕 Anyway, this PR looks good as it is. |
@bosilca You said:
I don't think that is what the standard says and I hope I did not convey that in my comment :) |
If the right-hand side was of a different signedness and not a constant, where the compiler can verify that the conversion is safe, then the compiler should have warned that the conversion is unsafe. |
Yeah, in my case, it's local without communication involved. Well, |
Indeed, that was my first reaction reading all this. The drawback is that we have to use the large count variants for everything, not just the types. |
I'm not sure how the patch fixes your issue (at best it delays it to when you want to load a matrix that is 8x larger?), bsiz is still in int and will still be truncated for some (apparently, since less than 1 order of magnitude to the one you use now) reasonable sizes. What is our reasoning for not promoting bsiz to a size_t overall? |
I will change |
d609ada
to
b7acf0f
Compare
The matrix size is already cast in the high-level distribution API, e.g., parsec_matrix_sym_block_cyclic_init, so this PR is only about |
b7acf0f
to
8d07869
Compare
#645