-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Python sub-interpreters (#26597)
- Loading branch information
Showing
14 changed files
with
401 additions
and
24 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
1 change: 1 addition & 0 deletions
1
test/library/packages/Python/correctness/compareIterationPatterns.good
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
data: 1 2 3 4 5 6 7 8 9 10 | ||
Serial Python result: 2 2 4 4 6 6 8 8 10 10 | ||
Parallel Python result: 2 2 4 4 6 6 8 8 10 10 | ||
Parallel Python SubInterpreter result: 2 2 4 4 6 6 8 8 10 10 | ||
Serial Chapel result: 2 2 4 4 6 6 8 8 10 10 | ||
Parallel Chapel result: 2 2 4 4 6 6 8 8 10 10 |
16 changes: 16 additions & 0 deletions
16
test/library/packages/Python/correctness/compareIterationPatterns.skipif
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,16 @@ | ||
#!/usr/bin/env bash | ||
# requires python 3.12+ | ||
|
||
# respect CHPL_TEST_VENV_DIR if it is set and not none | ||
if [ -n "$CHPL_TEST_VENV_DIR" ] && [ "$CHPL_TEST_VENV_DIR" != "none" ]; then | ||
chpl_python=$CHPL_TEST_VENV_DIR/bin/python3 | ||
else | ||
chpl_python=$($CHPL_HOME/util/config/find-python.sh) | ||
fi | ||
|
||
minor_version=$($chpl_python -c "import sys; print(sys.version_info.minor)") | ||
if [ $minor_version -ge 12 ]; then | ||
echo "False" | ||
else | ||
echo "True" | ||
fi |
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,27 @@ | ||
use Python; | ||
|
||
config const tasks = here.maxTaskPar; | ||
config const itersPerTask = 100; | ||
|
||
var code = """ | ||
import sys | ||
def hello(tid, idx): | ||
print("Hello from thread", tid, "index", idx) | ||
sys.stdout.flush() | ||
"""; | ||
|
||
proc main() { | ||
|
||
var interp = new Interpreter(); | ||
|
||
coforall tid in 0..#tasks { | ||
var localInterp = new SubInterpreter(interp); | ||
|
||
var m = new Module(localInterp, '__empty__', code); | ||
var f = new Function(m, 'hello'); | ||
for i in 1..#itersPerTask { | ||
f(NoneType, tid, i); | ||
} | ||
} | ||
|
||
} |
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 @@ | ||
--tasks=4 --itersPerTask=20 |
Oops, something went wrong.