Skip to content
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

Pygion projection functor #970

Open
wants to merge 1,917 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1917 commits
Select commit Hold shift + click to select a range
c4f6558
Merge branch 'master' into control_replication
lightsighter Mar 26, 2020
d1a52e7
Merge branch 'master' into control_replication
lightsighter Mar 26, 2020
5b3b0ea
legion: more logging for legion spy for control replication
lightsighter Mar 26, 2020
aed0714
legion: bug fix for debug deserializers for trace capture
lightsighter Mar 26, 2020
1650c34
Merge branch 'master' into control_replication
lightsighter Mar 26, 2020
deabc58
legion: bug fix for predication with control replication
lightsighter Mar 26, 2020
e692a56
Merge branch 'master' into control_replication
lightsighter Mar 26, 2020
50a92ce
legion: fix for verifying partition by field with control replication
lightsighter Mar 26, 2020
ad86bef
Merge branch 'master' into control_replication
lightsighter Mar 27, 2020
0c8de3b
legion: support for uncoupled index space copy operations with contro…
lightsighter Mar 27, 2020
09b055c
legion: support for getting the domain for a future map
lightsighter Mar 27, 2020
a8e19bd
Merge branch 'master' into control_replication
lightsighter Mar 28, 2020
76c2d9f
legion: small name tweak
lightsighter Mar 28, 2020
143109d
Merge branch 'master' into control_replication
lightsighter Mar 28, 2020
70ee56d
legion: bug fix for tracing with control replication
lightsighter Mar 28, 2020
1cda965
Merge branch 'master' into control_replication
lightsighter Mar 29, 2020
79e0b04
legion: small fix for view reference counting
lightsighter Mar 29, 2020
2499362
legion: have the runtime recognize pending collectables for control r…
lightsighter Mar 29, 2020
992bb07
legion: fix for pending distributed collectables
lightsighter Mar 29, 2020
354ab62
Merge branch 'master' into control_replication
lightsighter Mar 29, 2020
40ee355
Merge branch 'master' into control_replication
lightsighter Mar 29, 2020
35020dc
Merge branch 'master' into control_replication
lightsighter Mar 29, 2020
e2a4e85
legion: merge master into control replication and resolve conflicts
lightsighter Mar 31, 2020
76824c7
legion: fix for legion spy with control replication
lightsighter Mar 31, 2020
6673d98
Merge branch 'master' into control_replication
lightsighter Apr 1, 2020
67dba76
Merge branch 'master' into control_replication
magnatelee Apr 1, 2020
0cea07d
Merge branch 'master' into control_replication
lightsighter Apr 1, 2020
c88de05
Merge branch 'master' into control_replication
magnatelee Apr 1, 2020
cbbcdda
Merge branch 'master' into control_replication
magnatelee Apr 1, 2020
e40f5ae
Merge branch 'master' into control_replication
magnatelee Apr 1, 2020
b383bcc
legion: merge master into control replication and resolve conflicts
lightsighter Apr 1, 2020
66f031a
Merge branch 'master' into control_replication
lightsighter Apr 2, 2020
cdf90fe
Merge branch 'master' into control_replication
lightsighter Apr 2, 2020
00294b1
legion: merge master into control replication and resolve conflicts
lightsighter Apr 2, 2020
e5898da
Merge branch 'master' into control_replication
magnatelee Apr 3, 2020
c20f9d9
Merge branch 'master' into control_replication
magnatelee Apr 3, 2020
87bb2cd
Merge branch 'master' into control_replication
lightsighter Apr 3, 2020
8f441f3
legion: fix for partcheck with control replication
lightsighter Apr 3, 2020
ee3bab2
legion: merge master into control replication and resolve conflicts
lightsighter Apr 4, 2020
bb51c65
Merge branch 'master' into control_replication
lightsighter Apr 5, 2020
a94f899
Merge branch 'master' into control_replication
lightsighter Apr 5, 2020
c3817b7
Merge branch 'master' into control_replication
lightsighter Apr 5, 2020
be8835d
Merge branch 'master' into control_replication
elliottslaughter Apr 6, 2020
b2adf5b
Merge branch 'master' into control_replication
magnatelee Apr 7, 2020
fbd0f70
legion: merge master into control replication and resolve conflicts
lightsighter Apr 7, 2020
7956226
Merge branch 'control_replication' of gitlab.com:StanfordLegion/legio…
lightsighter Apr 7, 2020
ef3d09e
Merge branch 'master' into control_replication
lightsighter Apr 7, 2020
9b837ea
Merge branch 'master' into control_replication
lightsighter Apr 8, 2020
3722fd2
legion: updates for dynamic callback registration
lightsighter Apr 8, 2020
ceeec44
Merge branch 'master' into control_replication
lightsighter Apr 8, 2020
db98618
legion: another doc update
lightsighter Apr 8, 2020
97b50c8
legion: bug fixes for implicit top level tasks with control replication
lightsighter Apr 8, 2020
d31626b
Merge branch 'master' into control_replication
magnatelee Apr 8, 2020
0542f8b
Merge branch 'master' into control_replication
magnatelee Apr 8, 2020
e1dc778
legion: merge master into control replication and resolve conflicts
lightsighter Apr 8, 2020
5480fb0
Merge branch 'master' into control_replication
magnatelee Apr 8, 2020
0bef1e9
legion: merge master into control replication and resolve conflicts
lightsighter Apr 9, 2020
cd6b1bc
Merge branch 'master' into control_replication
lightsighter Apr 9, 2020
2fcbfd1
Merge branch 'master' into control_replication
lightsighter Apr 9, 2020
cd303f9
legion: merge master into control replication and resolve conflicts
lightsighter Apr 9, 2020
ea720e1
legion: merge master into control replication and resolve conflicts
lightsighter Apr 9, 2020
e631c71
legion: more work on semantic information and ID generation for contr…
lightsighter Apr 9, 2020
1cc6c22
Merge branch 'master' into control_replication
lightsighter Apr 9, 2020
ddfd2ad
legion: fix for attaching semantic information in control replicated …
lightsighter Apr 9, 2020
937d2a9
Merge branch 'master' into control_replication
lightsighter Apr 10, 2020
f85c54b
legion: small bug fix for all-reduce futures collective
lightsighter Apr 10, 2020
d9eb76a
Merge branch 'master' into control_replication
lightsighter Apr 10, 2020
dee30ea
legion: fix for semantic info attach with control replication
lightsighter Apr 10, 2020
2eb45ed
bindings: merge master into control replication and resolve conflicts
lightsighter Apr 10, 2020
4b0a0e4
legion: bug fixes for a pair of collective operations
lightsighter Apr 10, 2020
571a10a
legion: merge master into control replication and resolve conflicts
lightsighter Apr 10, 2020
44183d2
Merge branch 'master' into control_replication
lightsighter Apr 10, 2020
5ca2ce4
Merge branch 'master' into control_replication
lightsighter Apr 10, 2020
f1ea8ed
legion: merge master into control replication and resolve conflicts
lightsighter Apr 11, 2020
ae8fcf6
legion: switch partition color back to reference
lightsighter Apr 11, 2020
428d17e
legion: merge master into control replication and resolve conflicts
lightsighter Apr 11, 2020
418845e
Merge branch 'master' into control_replication
lightsighter Apr 11, 2020
02a436a
Merge branch 'master' into control_replication
lightsighter Apr 11, 2020
c892180
bindings: no longer need to silence warnings as the runtime will not …
lightsighter Apr 11, 2020
a64b532
legion: one more fix for partition colors for control replication
lightsighter Apr 11, 2020
4a1b461
Merge branch 'master' into control_replication
lightsighter Apr 11, 2020
de3a76a
legion: fixes for cross product partitions with control replication
lightsighter Apr 11, 2020
fca7eb2
Merge branch 'master' into control_replication
lightsighter Apr 11, 2020
154bdaf
Merge branch 'master' into control_replication
lightsighter Apr 11, 2020
6f5a950
Merge branch 'master' into control_replication
lightsighter Apr 12, 2020
c97ad13
Merge branch 'master' into control_replication
lightsighter Apr 12, 2020
3851a9c
legion: merge master into control replication and resolve conflicts
lightsighter Apr 14, 2020
1b5d4ce
Merge branch 'master' into control_replication
lightsighter Apr 14, 2020
5d235eb
legion: fixes for dependent partitioning with control replication
lightsighter Apr 23, 2020
2f7320c
legion: merge master into control replication and resolve conflicts
lightsighter Apr 24, 2020
d4b5704
legion: fix for field space creation on remote nodes
lightsighter Apr 24, 2020
9b91882
legion: another fix for field spaces with control replication
lightsighter Apr 24, 2020
5948073
Merge branch 'master' into control_replication
lightsighter Apr 24, 2020
96516e8
legion: merge master into control replication and resolve conflicts
lightsighter Apr 25, 2020
be81b4e
Merge branch 'master' into control_replication
lightsighter Apr 26, 2020
ef1d045
legion: adding support for fast field allocation with control replica…
lightsighter Apr 26, 2020
767f61e
legion: bug fix for fast field allocation with control replication
lightsighter Apr 26, 2020
cb603a8
Merge branch 'master' into control_replication
lightsighter Apr 29, 2020
baf2ff4
Merge branch 'master' into control_replication
elliottslaughter Apr 30, 2020
9cf3e12
legion: merge master into control replication and resolve conflicts
lightsighter May 3, 2020
b224675
legion: support for local-function tasks with control replication
lightsighter May 3, 2020
7621d00
Merge branch 'master' into control_replication
streichler May 4, 2020
6e60899
legion: merge master into control replication and resolve conflicts
lightsighter May 5, 2020
8884af3
legion: allow applications to get access to sharding functors
lightsighter May 5, 2020
8904d5d
Merge branch 'master' into control_replication
lightsighter May 5, 2020
ec7ff50
Merge branch 'master' into control_replication
lightsighter May 5, 2020
a377d6d
legion: merge master into control replication and resolve conflicts
lightsighter May 6, 2020
518ea56
legion: fix for dynamic task variant registration in control replicat…
lightsighter May 6, 2020
41089f4
legion: some CI debugging code
lightsighter May 6, 2020
5785d79
legion: fix for field allocation state machine with control replication
lightsighter May 6, 2020
491fad3
Merge branch 'master' into control_replication
elliottslaughter May 6, 2020
03ae8d2
Merge branch 'master' into control_replication
elliottslaughter May 6, 2020
095be5c
Merge branch 'master' into control_replication
lightsighter May 8, 2020
b8efa91
legion: bug fix for predicate future operations
lightsighter May 8, 2020
81f6f29
Merge branch 'master' into control_replication
elliottslaughter May 9, 2020
352d790
regent: Fix for setup_env.py, stop hijacking LuaJIT URL.
elliottslaughter May 12, 2020
884c516
legion: merge master into control replication and resolve conflicts
lightsighter May 14, 2020
fd91624
legion: merge master into control replication and resolve conflicts
lightsighter May 15, 2020
f8aa8e3
Merge branch 'master' into control_replication
lightsighter May 15, 2020
e5a9fbd
legion: merge master into control replication and resolve conflicts
lightsighter May 17, 2020
a1f551a
Merge branch 'master' into control_replication
lightsighter May 17, 2020
b0481ed
Merge branch 'master' into control_replication
lightsighter May 18, 2020
14d5270
legion: initial work on merging master into control replication and r…
lightsighter May 19, 2020
ee2c67c
legion: more fixes for deletions with control replication
lightsighter May 19, 2020
1bae857
Merge branch 'master' into control_replication
lightsighter May 19, 2020
72ce1dc
legion: more fixes for deletions in control replicated contexts
lightsighter May 19, 2020
f02622c
legion: remove overzealous assertion
lightsighter May 19, 2020
c834e5f
Merge branch 'master' into control_replication
lightsighter May 20, 2020
f4cd0db
Merge branch 'master' into control_replication
lightsighter May 20, 2020
d005930
Merge branch 'master' into control_replication
lightsighter May 20, 2020
bb13d3c
Merge branch 'master' into control_replication
lightsighter May 20, 2020
29e3e6f
Merge branch 'master' into control_replication
lightsighter May 20, 2020
864c3eb
Merge branch 'master' into control_replication
magnatelee May 21, 2020
9e2e326
Merge branch 'master' into control_replication
lightsighter May 21, 2020
115634f
Merge branch 'master' into control_replication
magnatelee May 22, 2020
faf9c2c
Merge branch 'master' into control_replication
magnatelee May 22, 2020
8aeaeb1
Merge branch 'master' into control_replication
magnatelee May 22, 2020
4f55ab4
Merge branch 'master' into control_replication
lightsighter May 22, 2020
e7777a6
Merge branch 'master' into control_replication
lightsighter May 22, 2020
5f20013
Merge branch 'master' into control_replication
lightsighter May 24, 2020
7a2d2c5
legion: merge master into control replication and resolve conflicts
lightsighter May 24, 2020
b65a8a6
legion: improvements for inorder execution with control replicated co…
lightsighter May 24, 2020
645559c
Merge branch 'master' into control_replication
lightsighter May 24, 2020
aeef3cc
legion: support for field space creation with immediate fields for co…
lightsighter May 24, 2020
eeedc94
Merge branch 'master' into control_replication
lightsighter May 25, 2020
cd76404
legion: merge master into control replication and resolve conflicts
lightsighter May 28, 2020
c994b9f
Merge branch 'master' into control_replication
lightsighter May 28, 2020
15daa17
legion: merge master into control replication and resolve conflicts
lightsighter May 28, 2020
e7c71f1
legion: add missing control replication support for partition by inte…
lightsighter May 31, 2020
c9e8ed9
Merge branch 'master' into control_replication
lightsighter May 31, 2020
be1c6d1
Merge branch 'master' into control_replication
lightsighter Jun 1, 2020
27fd7ac
Merge branch 'master' into control_replication
lightsighter Jun 2, 2020
1d19a6f
legion: fix issues in sharding dependent partitioning operations
lightsighter Jun 2, 2020
000da53
legion: more fixes for creating intersection partitions with control …
lightsighter Jun 2, 2020
bc9410d
Merge branch 'master' into control_replication
elliottslaughter Jun 3, 2020
557b3a8
Merge branch 'master' into control_replication
lightsighter Jun 3, 2020
43abcf5
legion: merge master into control replication and resolve conflicts
lightsighter Jun 4, 2020
3c498b5
Merge branch 'master' into control_replication
lightsighter Jun 4, 2020
2ce6452
Merge branch 'master' into control_replication
lightsighter Jun 4, 2020
59cdf11
Merge branch 'master' into control_replication
lightsighter Jun 4, 2020
ed8a7b0
Merge branch 'master' into control_replication
lightsighter Jun 4, 2020
d0e396d
legion: merge master into control replication and resolve conflicts
lightsighter Jun 4, 2020
e73f62b
legion: merge master into control replication and resolve conflicts
lightsighter Jun 5, 2020
24de37f
legion: merge master into control replication and resolve conflicts
lightsighter Jun 5, 2020
e05bf87
Merge branch 'master' into control_replication
lightsighter Jun 5, 2020
1036b62
legion: fixes for legion spy with no tracing on ap user events
lightsighter Jun 5, 2020
d30e510
legion: merge master into control replication and resolve conflicts
lightsighter Jun 5, 2020
598d8ef
Merge branch 'master' into control_replication
lightsighter Jun 5, 2020
20770de
legion: fix merge bug
lightsighter Jun 5, 2020
c0a12bc
legion: merge master into control replication and resolve conflicts
lightsighter Jun 5, 2020
0232593
legion: merge master into control replication and resolve conflicts
lightsighter Jun 5, 2020
c36844c
legion: fix broken merge
lightsighter Jun 5, 2020
9cf3f74
Merge branch 'master' into control_replication
magnatelee Jun 11, 2020
7c6eb29
Merge branch 'master' into control_replication
magnatelee Jun 12, 2020
1c21348
legion: Modify dead code elimination for new instruction kinds and
magnatelee Jun 12, 2020
3780379
Merge branch 'master' into control_replication
magnatelee Jun 14, 2020
ba3e5fa
Merge branch 'master' into control_replication
magnatelee Jun 15, 2020
f9b0cfd
legion: fix for specifying sharding index spaces in slice task mapper…
lightsighter Jun 15, 2020
1dd6bca
legion: Minor fix for DCE
magnatelee Jun 16, 2020
eb24fd3
legion: Initialize the generator table correctly in trace optimization
magnatelee Jun 16, 2020
ecfd85e
Merge branch 'master' into control_replication
elliottslaughter Jun 17, 2020
5285d5d
Merge branch 'master' into control_replication
lightsighter Jun 17, 2020
eddc723
legion: fixes for deprecated enums with control replication
lightsighter Jun 17, 2020
9f174a8
legion: Fix for the projection tree construction
magnatelee Jun 18, 2020
ec8cf27
legion: merge master into control replication and resolve conflicts
lightsighter Jun 18, 2020
2651341
legion: merge master into control replication and resolve conflicts
lightsighter Jun 21, 2020
b1d28c1
legion: bug fixes for tracing with control replication
lightsighter Jun 21, 2020
0497080
Merge branch 'master' into control_replication
lightsighter Jun 21, 2020
71797df
Merge branch 'master' into control_replication
lightsighter Jun 23, 2020
c508480
Merge branch 'master' into control_replication
lightsighter Jun 23, 2020
b5298a0
legion: merge master into control replication and resolve conflicts
lightsighter Jun 29, 2020
6e498fe
Merge branch 'master' into control_replication
lightsighter Jun 29, 2020
c392139
Merge branch 'master' into control_replication
lightsighter Jun 29, 2020
365154c
legion: fix duplicate deletion
lightsighter Jun 29, 2020
1395c31
legion: support for invertible sharding functions
lightsighter Jun 29, 2020
f03c045
legion: fix polarity bug
lightsighter Jun 29, 2020
c3c9164
Merge branch 'master' into control_replication
lightsighter Jun 30, 2020
85c19e4
Merge branch 'master' into control_replication
lightsighter Jul 6, 2020
7686ee2
legion: support for murmur3 hashing for verifying control replicability
lightsighter Jul 6, 2020
16661dc
legion: fix for creation of index spaces from futures in control repl…
lightsighter Jul 6, 2020
bb7b600
legion: merge master into control replication and resolve conflicts
lightsighter Jul 7, 2020
16224a0
legion: fix for unordered operations
lightsighter Jul 8, 2020
3949182
legion: fix for performing dynamic registration callbacks with contro…
lightsighter Jul 8, 2020
46510ad
Merge branch 'master' into control_replication
lightsighter Jul 8, 2020
5a58076
legion: initial support for hash-based checking of arguments to contr…
lightsighter Jul 9, 2020
ee58a03
legion: merge master into control replication and resolve conflicts
lightsighter Jul 9, 2020
709b5f4
legion: merge master into control replication and resolve conflicts
lightsighter Jul 10, 2020
b86048c
Merge branch 'master' into control_replication
lightsighter Jul 10, 2020
9e93d26
Merge branch 'master' into control_replication
lightsighter Jul 10, 2020
6eb0a8d
Merge branch 'master' into control_replication
lightsighter Jul 11, 2020
d720548
legion: more support for verifying the safety of control replication …
lightsighter Jul 12, 2020
a87044e
legion: merge changes from newinsts upstream into control replication…
lightsighter Jul 13, 2020
874f3bf
legion: fix more merge bugs
lightsighter Jul 13, 2020
0c47411
legion: another merge bug fix
lightsighter Jul 13, 2020
1213e27
Merge branch 'master' into control_replication
lightsighter Jul 14, 2020
5ec975b
Test projection functor.
elliottslaughter Jul 14, 2020
4bb3ce6
Fix bugs in type declarations.
elliottslaughter Jul 14, 2020
9e3ac78
Updates to projection functor code.
elliottslaughter Jul 22, 2020
6bad168
Update projection functor code.
elliottslaughter Jul 22, 2020
57eb7a0
Add runtime debugging code.
elliottslaughter Jul 22, 2020
8f7798a
Add C projection functor example.
elliottslaughter Jul 22, 2020
559fdd3
pygion: Initial support for projection functors, symbolic arithmetic …
elliottslaughter Aug 17, 2020
16f509a
working projection functor
Aug 21, 2020
c96e979
Fix some small typos.
elliottslaughter Sep 15, 2020
437808b
Use Pygion function for proj functor
Sep 24, 2020
f447e78
use pygion function
Sep 24, 2020
6e9105f
add codegen in SymbolicBinop and SymbolicLoopIndex
Oct 1, 2020
8c61e28
add codegen in SymbolicBinop and SymbolicLoopIndex
Oct 1, 2020
57c4977
add codegen
Oct 1, 2020
b837e3f
add operators for proj functor
Oct 5, 2020
d57958b
add division in proj functor
Oct 5, 2020
259f29a
debugging segfault
Oct 16, 2020
2d2a8a5
This version is working
Oct 16, 2020
0855595
Clean up and add function to check arg type in attach_region_requirem…
Oct 19, 2020
7d65d92
use index_launch()
Oct 23, 2020
7e2ceb3
fix arg_check and test P[i+1]
Oct 26, 2020
241e17c
add symbolic expr check in arg_check
Oct 26, 2020
7ba385c
add cache for proj functor and hash and eq methods in SymbolicBinop
Oct 29, 2020
ff9ea6e
fix __new__ method
Oct 29, 2020
d92ec05
Add math methods in DomainPoint()
Nov 5, 2020
69b70d5
Add symbolize function
Nov 9, 2020
d768422
fix symbolize in SymbolicCall
Nov 13, 2020
bfff31d
proj functor working
Nov 13, 2020
9d50798
all symbolize functions done
Nov 16, 2020
423ae5c
all preprocess functions removed
Nov 16, 2020
72af4a7
Clean and reformat
Nov 16, 2020
7141238
working proj functor cache
Nov 19, 2020
5752597
clean and reformat
Nov 19, 2020
e710187
Fix assert bug
Nov 23, 2020
fee19a6
working version
Nov 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -666,14 +666,14 @@ gcc49_cxx98_debug_hdf5_mpi_regent:
variables:
<<: [*gcc49, *terra38, *debug, *cxx98_normal, *hdf5, *mpi, *regent]
# Multi-node Legion Spy
gcc49_cxx98_debug_spy_gasnet_regent:
<<: [*linux_compute, *image, *tests]
variables:
<<: [*gcc49, *terra38, *cxx98_normal, *spy, *gasnet, *regent]
gcc49_cxx98_debug_spy_mpi_regent:
<<: [*linux_compute, *image, *tests]
variables:
<<: [*gcc49, *terra38, *cxx98_normal, *spy, *mpi, *regent]
#gcc49_cxx98_debug_spy_gasnet_regent:
# <<: [*linux_compute, *image, *tests]
# variables:
# <<: [*gcc49, *terra38, *cxx98_normal, *spy, *gasnet, *regent]
#gcc49_cxx98_debug_spy_mpi_regent:
# <<: [*linux_compute, *image, *tests]
# variables:
# <<: [*gcc49, *terra38, *cxx98_normal, *spy, *mpi, *regent]
# * Different architectures
gcc49_cxx98_32bit_debug_legion:
<<: [*linux, *image, *tests]
Expand Down
39 changes: 38 additions & 1 deletion bindings/python/legion_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,39 @@ def import_global(module, check_depth=True, block=True):
# not safe to use with control replication so this will give them a way
# to check whether they are running in a safe context or not
def is_control_replicated():
return False
try:
# We should only be doing something for this if we're the top-level task
return c.legion_context_get_num_shards(top_level.runtime[0],
top_level.context[0], True) > 1
except AttributeError:
raise RuntimeError('"is_control_replicated" must be called in a legion_python task')


# Helper class for deduplicating output streams with control replication
class LegionOutputStream(object):
def __init__(self, shard_id, stream):
self.shard_id = shard_id
# This is the original stream
self.stream = stream

def close(self):
self.stream.close()

def flush(self):
self.stream.flush()

def write(self, string):
# Only do the write if we are shard 0
if self.shard_id == 0:
self.stream.write(string)

def writelines(self, sequence):
# Only do the write if we are shard 0
if self.shard_id == 0:
self.stream.writelines(sequence)

def isatty(self):
return self.stream.isatty()


def legion_python_main(raw_args, user_data, proc):
Expand All @@ -282,6 +314,11 @@ def legion_python_main(raw_args, user_data, proc):

top_level.runtime, top_level.context, top_level.task = runtime, context, task

# If we're control replicated, deduplicate stdout
if is_control_replicated():
shard_id = c.legion_context_get_shard_id(runtime[0], context[0], True)
sys.stdout = LegionOutputStream(shard_id, sys.stdout)

# Run user's script.
args = input_args(True)
start = 1
Expand Down
50 changes: 46 additions & 4 deletions bindings/python/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,21 @@ static bool control_replicate = true;
static const char * const unique_name = "legion_python";
static const VariantID vid = 1;

class LegionPyShardingFunctor : public ShardingFunctor {
public:
LegionPyShardingFunctor(void) { }
virtual ~LegionPyShardingFunctor(void) { }
public:
virtual ShardID shard(const DomainPoint &point,
const Domain &full_space,
const size_t total_shards);
};

// Special mapper just for mapping the top-level Python tasks
class LegionPyMapper : public Legion::Mapping::NullMapper {
public:
LegionPyMapper(MapperRuntime *runtime, Machine machine, TaskID top_task_id);
LegionPyMapper(MapperRuntime *runtime, Machine machine,
TaskID top_task_id, ShardingID sharding_id);
virtual ~LegionPyMapper(void);
public:
static AddressSpaceID get_local_node(void);
Expand All @@ -57,6 +68,11 @@ class LegionPyMapper : public Legion::Mapping::NullMapper {
const MapTaskInput& input,
const MapTaskOutput& default_output,
MapReplicateTaskOutput& output);
virtual void select_sharding_functor(
const MapperContext ctx,
const Task& task,
const SelectShardingFunctorInput& input,
SelectShardingFunctorOutput& output);
virtual void select_tunable_value(const MapperContext ctx,
const Task& task,
const SelectTunableInput& input,
Expand All @@ -81,6 +97,7 @@ class LegionPyMapper : public Legion::Mapping::NullMapper {
const size_t total_nodes;
const char *const mapper_name;
const TaskID top_task_id;
const ShardingID sharding_id;
protected:
std::vector<Processor> local_pys; // Python processors
};
Expand Down Expand Up @@ -125,11 +142,14 @@ static void python_main_callback(Machine machine, Runtime *runtime,
runtime->register_task_variant(registrar, code_desc, NULL, 0, task_name, vid);
runtime->attach_name(top_task_id+2, task_name, false/*mutable*/, true/*local only*/);
}
// Register our sharding function for any global import tasks
const ShardingID sharding_id = runtime->generate_library_sharding_ids(unique_name, 1);
runtime->register_sharding_functor(sharding_id, new LegionPyShardingFunctor());
// Register our mapper for the top-level task
const MapperID top_mapper_id = runtime->generate_library_mapper_ids(unique_name, 1);
runtime->set_top_level_task_mapper_id(top_mapper_id);
runtime->add_mapper(top_mapper_id,
new LegionPyMapper(runtime->get_mapper_runtime(), machine, top_task_id));
new LegionPyMapper(runtime->get_mapper_runtime(), machine, top_task_id, sharding_id));
}

int main(int argc, char **argv)
Expand Down Expand Up @@ -197,10 +217,10 @@ int main(int argc, char **argv)
return Runtime::start(argc, argv);
}

LegionPyMapper::LegionPyMapper(MapperRuntime *rt, Machine m, TaskID top_id)
LegionPyMapper::LegionPyMapper(MapperRuntime *rt, Machine m, TaskID top_id, ShardingID sid)
: NullMapper(rt, m), local_node(get_local_node()),
total_nodes(get_total_nodes(m)), mapper_name(create_name(local_node)),
top_task_id(top_id)
top_task_id(top_id), sharding_id(sid)
{
Machine::ProcessorQuery py_procs(machine);
py_procs.local_address_space();
Expand Down Expand Up @@ -378,6 +398,28 @@ void LegionPyMapper::map_top_level_task(const MapperContext ctx,
output.chosen_variant = vid;
}

ShardID LegionPyShardingFunctor::shard(const DomainPoint &point,
const Domain &full_domain,
size_t total_shards)
{
Point<1> p = point;
Rect<1> bounds = full_domain;
const size_t volume = bounds.volume();
assert((volume % total_shards) == 0);
const size_t pernode = volume / total_shards;
return (p[0] / pernode);
}

void LegionPyMapper::select_sharding_functor(
const MapperContext ctx,
const Task& task,
const SelectShardingFunctorInput& input,
SelectShardingFunctorOutput& output)
{
assert(task.task_id == (top_task_id+1));
output.chosen_functor = sharding_id;
}

void LegionPyMapper::select_tunable_value(const MapperContext ctx,
const Task& task,
const SelectTunableInput& input,
Expand Down
9 changes: 9 additions & 0 deletions bindings/python/projection_functor_example.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "legion.h"

void proj_functor(legion_runtime_t runtime,
legion_logical_partition_t parent,
legion_domain_point_t point,
legion_domain_t launch_domain)
{
legion_projection_functor_logical_partition_print_arguments_2(parent);
}
67 changes: 67 additions & 0 deletions bindings/python/projection_functor_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from __future__ import print_function

import pygion
from pygion import (
index_launch,
task,
Domain,
ID,
IndexLaunch,
R,
Region,
Partition,
ProjectionFunctor,
)

from typing import cast, Callable

import subprocess
import petra as pt

f = ProjectionFunctor.create(1 + ID)


@task(privileges=[R])
def hello(R, i, num):
print("hello from point %s (region %s)" % (i, R.ispace.bounds))
assert int(R.ispace.bounds[0, 0]) == int(i + num)


@task
def main():
R = Region([4], {"x": pygion.float64})
P = Partition.equal(R, [4])
for i in range(4):
print(
"python region %s is %s %s %s"
% (
i,
P[i].handle[0].tree_id,
P[i].handle[0].index_space.tid,
P[i].handle[0].index_space.id,
)
)
pygion.fill(R, "x", 0)

for i in IndexLaunch([3]):
hello(P[f(i)], i, 1)

for i in IndexLaunch([3]):
hello(P[i], i, 0)

for i in IndexLaunch([2]):
hello(P[i + 2], i, 2)

for i in IndexLaunch([2]):
hello(P[i + 2], i, 2)

index_launch([3], hello, P[ID], ID, 0)

# This Seg Fault when running all tests but not when it's the only test:
index_launch([3], hello, P[f(ID)], ID, 1)

index_launch([2], hello, P[ID + 2], ID, 2)


if __name__ == "__main__":
main()
Loading