forked from chapel-lang/chapel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix an ALA bug related to unaligned followers (chapel-lang#25753)
Resolves chapel-lang#25727 The following code would fail because of an ALA bug: ```chpl use BlockDist; var A: [blockDist.createDomain({1..100})] int = 5; var db = {1..50}; var B: [blockDist.createDomain(db)] int = 1; forall (b, i) in zip(B, db) { b = A[i]; } writeln(B); ``` The root cause was that when checking for `A[i]`s alignment, we would check against `db` instead of `B`. What's tricky here is that `db` is actually "aligned" with `A` as it happens to be its local subdomain. However, that only matters if `db` was actually the leader of the loop. This PR fixes the logic in the ALA implementation. The core change is that our static and dynamic checks for ALA would accept (1) accessBase (`A`) and (2) the loop domain (used to be `db`, erroneously). After this PR, they take (1) accessBase (`A`), (2) the loop domain (`B`, correctly), and (3) iterand of the accessBase (`db`). Static and dynamic check logic is adjusted accordingly. While there this PR: - does a very mild refactor to move the common (problematic) logic between static and dynamic checks into a helper function in the compiler. - renames module helpers to have `chpl__ala_` prefix for consistency internally within the module and with other optimizations. [Reviewed by @benharsh] Test - [x] linux64 - [x] gasnet
- Loading branch information
Showing
8 changed files
with
111 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// we want dynamic checks to fail here. The way to check is to make sure that | ||
// `localAccess` is never called. | ||
use BlockDist; | ||
|
||
var A: [blockDist.createDomain({1..10})] int = 5; | ||
|
||
var db = {1..5}; | ||
var B: [blockDist.createDomain(db)] int = 1; | ||
|
||
forall (b, i) in zip(B, db) { | ||
b = A[i]; | ||
} | ||
|
||
writeln(B); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-slogAllArrEltAccess=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
Start analyzing forall (unalignedFollower.chpl:10) | ||
| Found loop domain (unalignedFollower.chpl:8) | ||
| Will attempt static and dynamic optimizations (unalignedFollower.chpl:10) | ||
| | ||
| Start analyzing call (unalignedFollower.chpl:11) | ||
| Can't determine the domain of access base (unalignedFollower.chpl:5) | ||
| This call is a dynamic optimization candidate (unalignedFollower.chpl:11) | ||
| | ||
End analyzing forall (unalignedFollower.chpl:10) | ||
|
||
Static check successful. Using localAccess with dynamic check (unalignedFollower.chpl:11) | ||
Static check successful. Using localAccess with dynamic check (unalignedFollower.chpl:11) | ||
5 5 5 5 5 | ||
|
||
Numbers collected by prediff: | ||
localAccess was called 0 times |
1 change: 1 addition & 0 deletions
1
test/optimizations/autoLocalAccess/unalignedFollower.numlocales
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
./PREDIFF-filter-accessors $1 $2 --no-this |