Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16737 from bradcray/chpl_nodeID_nonvar
Convert `chpl_nodeID` from `extern var` to `extern proc` [reviewed by @mppf] Declaring `chpl_nodeID` as a module-scope extern variable pointed to an issue in which we weren't introducing a shadow variable for it as we do for other module-scope variables. However, it also shows a weakness of using a module-scope extern variable for an external value that is different on each locale: it suggests to Chapel that there's a single extern variable when in fact there's a per-locale variable with a distinct value on each locale. This suggests that an extern var isn't the best way to represent such values in Chapel. In this PR, I change chpl_nodeID to an extern (paren-less) proc so that the Chapel code which refers to it can remain unchanged; and I assign it a new name in the C code so that we can implement it as a static inline function without modifying other C code that refers to the C-level variable. The result is a minimal change to our code that avoids the mismatch between describing such a value as a global variable in Chapel that should result in a nearly identical execution-time implementation. Resolves #16716.
- Loading branch information
Showing
7 changed files
with
50 additions
and
2 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,23 @@ | ||
var s$: sync int = 0; | ||
|
||
writeln("coforall: "); | ||
coforall loc in Locales { | ||
on loc { | ||
while (s$.readFF() != here.id) { } | ||
s$.readFE(); | ||
writeln("chpl_nodeID: ", chpl_nodeID, ", here.id = ", here.id); | ||
s$.writeEF(here.id+1); | ||
} | ||
} | ||
writeln(); | ||
s$.writeXF(0); | ||
|
||
writeln("forall: "); | ||
forall loc in Locales { | ||
on loc { | ||
while (s$.readFF() != here.id) { } | ||
s$.readFE(); | ||
writeln("chpl_nodeID: ", chpl_nodeID, ", here.id = ", here.id); | ||
s$.writeEF(here.id+1); | ||
} | ||
} |
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,5 @@ | ||
coforall: | ||
chpl_nodeID: 0, here.id = 0 | ||
|
||
forall: | ||
chpl_nodeID: 0, here.id = 0 |
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,11 @@ | ||
coforall: | ||
chpl_nodeID: 0, here.id = 0 | ||
chpl_nodeID: 1, here.id = 1 | ||
chpl_nodeID: 2, here.id = 2 | ||
chpl_nodeID: 3, here.id = 3 | ||
|
||
forall: | ||
chpl_nodeID: 0, here.id = 0 | ||
chpl_nodeID: 1, here.id = 1 | ||
chpl_nodeID: 2, here.id = 2 | ||
chpl_nodeID: 3, here.id = 3 |
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 @@ | ||
4 |