-
Notifications
You must be signed in to change notification settings - Fork 430
Remove "no promotion when by ref" pragmas from array view routines #27386
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
base: main
Are you sure you want to change the base?
Conversation
In trying to understand what these pragmas were doing, Jade and I came to the conclusion that, in the case of array views, they probably aren't doing much, so removing them to avoid being needlessly superstitious. --- Signed-off-by: Brad Chamberlain <bradcray@users.noreply.github.com>
@jabraham17 : No rush to get to this before you're back and settled, but following up on one of our pre-release discussions, I put this cleanup together and it seems to pass testing as expected… |
I don't believe this is the case here. We were discussing functions which return array views which cannot be promoted to return a view. These functions return modifiable array views var B = [0..1, 2..3, 4..5, 6..7, 8..9];
var A = [i in 0..100] i;
writeln(A[B[0]]);
A[B[0]] = 2;
writeln(A[B[0]]); This is a valid program and is not affected by the changes in this PR. But, consider the slight changes for the following program var B = [0..1, 2..3, 4..5, 6..7, 8..9];
var A = [i in 0..100] i;
writeln(A[B]);
A[B] = 2;
writeln(A[B]); This program does not compile today.
If it should compile, then the pragma is absolutely needed here, and this PR would change the behavior of |
I see. Is it the case, then, that any procedure that returns an array by |
The specific case for that pragma is about modifying promoted expressions. So its not about an arbitrary |
Right, but my point is: doesn't any procedure that returns a reference to an existing array — whether by using a |
Any procedure which, when promoted, can return multiple mutable pointers (refs, aliasing arrays, etc) to the same location in memory/array can be a race and falls under Since the original PR/issue was only about indexing expressions, I only added that pragma to those procedures which support indexing for arrays to selectively enable the warning. But in theory, other procedures could suffer from this problem and should also be warned about. We could perhaps try removing this line chapel/compiler/main/checks.cpp Line 209 in 0d8e588
--compopts --warn-potential-races to see what happens
|
In trying to understand what these pragmas were doing as part of the reshape work (#27132), Jade and I came to the conclusion that, in the case of array views, they probably aren't doing much, so removing them to avoid being needlessly superstitious.
TODO: