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

legate.sparse tracking branch [DO NOT MERGE] #483

Open
wants to merge 55 commits into
base: branch-24.03
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
05d3f69
[DNM] core: preliminary implementation of image partitions
rohany Jun 24, 2022
b6fbe6e
more updates to solver, allow for partitions dependent on image const…
rohany Jun 30, 2022
b647721
core: allow for manual tasks to have unbound outputs
rohany Jun 30, 2022
db7cbbb
several updates for SpGEMM:
rohany Jul 3, 2022
927f2d6
legate/core: track validity of and cache image partitions
rohany Jul 5, 2022
2730fc5
legate/core: add user hints about disjointness/completeness of images
rohany Jul 5, 2022
47eb03b
legate/core: make sure that mapper id's are passed to image partitions
rohany Jul 5, 2022
47018d8
legate/core: stop overriding the _num_pieces knob in the runtime
rohany Jul 14, 2022
2952346
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 14, 2022
78c9b8b
legate/core: enable specifying an image functor for image constraints
rohany Jul 21, 2022
28e5992
legate/core: fix bug in solver causing unnecessary replication
rohany Jul 26, 2022
129ec25
legate/core: add preimage partitions and update domain partitions
rohany Jul 28, 2022
73d2441
legate/core: properly check for restrictions on image partitions
rohany Aug 1, 2022
3be5508
legate/core: be permissive to numpy types when converting Shape tuples
rohany Aug 1, 2022
3f00a0d
legate/core: stop directly constructing Legion Partitions
Aug 3, 2022
8a69fde
Revert "legate/core: stop directly constructing Legion Partitions"
Aug 4, 2022
c67162e
legate/core: supporting partitions when dimensions dont match color s…
Aug 4, 2022
b4a0131
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 4, 2022
4bbba90
src/core/mapper: remove map_copy 1-gpu heuristic
rohany Aug 9, 2022
e07daa6
core: thread disjointness and completeness of partitions through image
rohany Aug 10, 2022
2c33ffa
legate/core: issue fills for collected regions to encourage gc
rohany Aug 12, 2022
dbe6960
src/core/mapping: add sharding for fills issued by the core
rohany Aug 25, 2022
ebf9e02
legate/core: add the ability to apply affine projections to domain parts
rohany Aug 25, 2022
681478d
legate/core: stop hashing store version in ImagePartition
rohany Aug 31, 2022
45efdf3
legate/core/partition: support future-map backed domains in affine pr…
rohany Sep 8, 2022
2a76d4a
legate/core: rebasing on top of core reorganization
rohany Sep 15, 2022
1ed74f9
Merge branch 'branch-22.10' into legate-sparse
rohany Sep 17, 2022
d761d05
legate/core/store: stop using weighted partitions as keys when transf…
rohany Sep 27, 2022
d1c0ef6
legate/core/store: fix some fallout from partition refactoring
rohany Sep 27, 2022
bec9227
*: fix all mypy warnings
rohany Sep 27, 2022
0ae2962
Merge branch 'branch-22.10' into legate-sparse
rohany Sep 27, 2022
c41b071
Merge branch 'branch-22.10' into legate-sparse
rohany Sep 27, 2022
66ff57e
Merge branch 'branch-22.10' into legate-sparse
rohany Sep 28, 2022
0a14398
Merge branch 'branch-22.10' into legate-sparse
rohany Sep 28, 2022
10a015c
Adjust consensus match frequency based on field sizes (#402)
magnatelee Sep 30, 2022
f240823
Merge branch 'branch-22.10' into legate-sparse
rohany Sep 30, 2022
b4d7669
Merge branch 'branch-22.12' into legate-sparse
rohany Oct 7, 2022
18afbb3
legate/core/partition: use storages for equality rather than stores
rohany Oct 11, 2022
e7146a7
Merge branch 'branch-22.12' into legate-sparse
rohany Nov 5, 2022
6cc1aca
Merge branch 'branch-22.12' into legate-sparse-part-mgr-merge
rohany Nov 19, 2022
140695f
Merge pull request #3 from rohany/legate-sparse-part-mgr-merge
rohany Nov 19, 2022
a7c2ca5
Merge branch 'branch-22.12' into legate-sparse
rohany Nov 21, 2022
8b2d6ef
Merge branch 'branch-22.12' into legate-sparse
rohany Nov 22, 2022
3383168
Merge branch 'branch-22.12' into legate-sparse
rohany Nov 29, 2022
0a7c469
Merge branch 'branch-22.12' into legate-sparse
rohany Dec 2, 2022
60d9f20
legate/core/partition: fix bug in equality checking of preimages
rohany Dec 11, 2022
e5321f8
legate/core/partition: stop leaking stores when using PreImage
rohany Dec 12, 2022
3b103a5
Merge branch 'branch-22.12' into legate-sparse
rohany Dec 13, 2022
e422d81
Merge branch 'branch-22.12' into legate-sparse
Jan 10, 2023
459c84c
Merge branch 'branch-22.12' into legate-sparse
rohany Jan 13, 2023
ab4e8a1
Merge branch 'branch-22.12' into legate-sparse
rohany Jan 19, 2023
2440eeb
Merge branch 'branch-22.12' into legate-sparse
rohany Jan 20, 2023
ae9a997
install.py: switch the default branch back to control_replication
rohany Feb 17, 2023
5279dc6
cmake/thirdparty: one more change to switch back to control_replication
rohany Feb 17, 2023
dfd073c
Merge branch 'branch-23.05' into legate-sparse
magnatelee Mar 15, 2023
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
2 changes: 2 additions & 0 deletions legate/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
PartitionByRestriction,
PartitionByImage,
PartitionByImageRange,
PartitionByPreimage,
PartitionByPreimageRange,
EqualPartition,
PartitionByWeights,
IndexPartition,
Expand Down
4 changes: 4 additions & 0 deletions legate/core/_legion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
PartitionByRestriction,
PartitionByImage,
PartitionByImageRange,
PartitionByPreimage,
PartitionByPreimageRange,
EqualPartition,
PartitionByWeights,
PartitionByDomain,
Expand Down Expand Up @@ -88,6 +90,8 @@
"PartitionByDomain",
"PartitionByImage",
"PartitionByImageRange",
"PartitionByPreimage",
"PartitionByPreimageRange",
"PartitionByRestriction",
"PartitionByWeights",
"PartitionFunctor",
Expand Down
2 changes: 1 addition & 1 deletion legate/core/_legion/future.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def from_list(
context,
domain,
points,
futures,
futures_,
num_futures,
False,
0,
Expand Down
20 changes: 20 additions & 0 deletions legate/core/_legion/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ def get_root(self) -> Region:
"""
return self.parent.get_root()

@property
def disjoint(self) -> bool:
return self.index_partition.disjoint

@property
def complete(self) -> bool:
return self.index_partition.complete


class IndexPartition:
_logical_handle: Any
Expand Down Expand Up @@ -260,3 +268,15 @@ def get_root(self) -> IndexSpace:
Return the root IndexSpace in this tree.
"""
return self.parent.get_root()

@property
def disjoint(self) -> bool:
return legion.legion_index_partition_is_disjoint( # type: ignore
self.runtime, self.handle
)

@property
def complete(self) -> bool:
return legion.legion_index_partition_is_complete( # type: ignore
self.runtime, self.handle
)
15 changes: 12 additions & 3 deletions legate/core/_legion/partition_functor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@
from typing import TYPE_CHECKING, Any, Union

from .. import ffi, legion
from . import FieldID
from .future import FutureMap
from .geometry import Point

if TYPE_CHECKING:
from . import FieldID, IndexPartition, IndexSpace, Rect, Region, Transform
from . import (
FieldID,
IndexPartition,
IndexSpace,
Partition,
Rect,
Region,
Transform,
)


class PartitionFunctor:
Expand Down Expand Up @@ -103,7 +112,7 @@ class PartitionByImage(PartitionFunctor):
def __init__(
self,
region: Region,
part: IndexPartition,
part: Partition,
field: Union[int, FieldID],
mapper: int = 0,
tag: int = 0,
Expand Down Expand Up @@ -148,7 +157,7 @@ class PartitionByImageRange(PartitionFunctor):
def __init__(
self,
region: Region,
part: IndexPartition,
part: Partition,
field: Union[int, FieldID],
mapper: int = 0,
tag: int = 0,
Expand Down
75 changes: 74 additions & 1 deletion legate/core/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any, Iterator, Optional, Protocol, Union

from .partition import Restriction
from .partition import ImagePartition, Replicate, Restriction

if TYPE_CHECKING:
from .partition import PartitionBase
Expand Down Expand Up @@ -219,6 +219,79 @@ def unknowns(self) -> Iterator[PartSym]:
yield unknown


class Image(Expr):
def __init__(
self,
source_store: Store,
dst_store: Store,
src_part_sym: Expr,
mapper: int,
range: bool = False,
functor: Any = ImagePartition,
disjoint: bool = True,
complete: bool = True,
):
self._source_store = source_store
self._dst_store = dst_store
self._src_part_sym = src_part_sym
self._mapper = mapper
self._range = range
self._functor = functor
self._disjoint = disjoint
self._complete = complete

def subst(self, mapping: dict[PartSym, PartitionBase]) -> Expr:
return Image(
self._source_store,
self._dst_store,
self._src_part_sym.subst(mapping),
self._mapper,
range=self._range,
functor=self._functor,
disjoint=self._disjoint,
complete=self._complete,
)

@property
def ndim(self) -> int:
return self._src_part_sym.ndim

def reduce(self) -> Lit:
expr = self._src_part_sym.reduce()
assert isinstance(expr, Lit)
part = expr._part
if isinstance(part, Replicate):
return Lit(part)
return Lit(
self._functor(
self._source_store,
part,
self._mapper,
range=self._range,
disjoint=self._disjoint,
complete=self._complete,
)
)

def unknowns(self) -> Iterator[PartSym]:
for unknown in self._src_part_sym.unknowns():
yield unknown

def equals(self, other: object) -> bool:
return (
isinstance(other, Image)
and self._source_store == other._source_store
and self._dst_store == other._dst_store
# Careful! Overloaded equals operator.
and self._src_part_sym is other._src_part_sym
and self._range == other._range
and self._mapper == other._mapper
and self._functor == other._functor
and self._disjoint == other._disjoint
and self._complete == other._complete
)


class Constraint:
pass

Expand Down
64 changes: 56 additions & 8 deletions legate/core/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import legate.core.types as ty

from . import Future, FutureMap, Rect
from .constraints import PartSym
from .constraints import Image, PartSym
from .launcher import CopyLauncher, FillLauncher, TaskLauncher
from .partition import REPLICATE, Weighted
from .partition import REPLICATE, ImagePartition, Weighted
from .shape import Shape
from .store import Store, StorePartition
from .utils import OrderedSet, capture_traceback_repr
Expand Down Expand Up @@ -157,6 +157,12 @@ def get_all_stores(self) -> OrderedSet[Store]:
result.update(store for (store, _) in self._reductions)
return result

def get_all_modified_stores(self) -> OrderedSet[Store]:
result: OrderedSet[Store] = OrderedSet()
result.update(self._outputs)
result.update(store for (store, _) in self._reductions)
return result

def add_alignment(self, store1: Store, store2: Store) -> None:
"""
Sets an alignment between stores. Equivalent to the following code:
Expand Down Expand Up @@ -216,6 +222,36 @@ def add_broadcast(
part = self._get_unique_partition(store)
self.add_constraint(part.broadcast(axes=axes))

# add_image_constraint adds a constraint that the image of store1 is
# contained within the partition of store2.
def add_image_constraint(
self,
store1: Store,
store2: Store,
range: bool = False,
functor: Any = ImagePartition,
disjoint: bool = True,
complete: bool = True,
) -> None:
self._check_store(store1)
self._check_store(store2)
# TODO (rohany): We only support point (and rect types if range) here.
# It seems like rects should be added to legate.core's type system
# rather than an external type system to understand this then.
part1 = self._get_unique_partition(store1)
part2 = self._get_unique_partition(store2)
image = Image(
store1,
store2,
part1,
self._context.mapper_id,
range=range,
functor=functor,
disjoint=disjoint,
complete=complete,
)
self.add_constraint(image <= part2)

def add_constraint(self, constraint: Constraint) -> None:
"""
Adds a partitioning constraint to the operation
Expand Down Expand Up @@ -851,14 +887,17 @@ def __init__(
op_id=op_id,
)
self._launch_domain: Rect = launch_domain
self._input_projs: list[Union[ProjFn, None]] = []
# TODO (rohany): The int here is an explicit ID.
self._input_projs: list[Union[ProjFn, None, int]] = []
self._output_projs: list[Union[ProjFn, None]] = []
self._reduction_projs: list[Union[ProjFn, None]] = []

self._input_parts: list[StorePartition] = []
self._output_parts: list[StorePartition] = []
self._reduction_parts: list[tuple[StorePartition, int]] = []

self._scalar_future_maps: list[FutureMap] = []

@property
def launch_ndim(self) -> int:
return self._launch_domain.dim
Expand All @@ -876,7 +915,7 @@ def _check_arg(arg: Union[Store, StorePartition]) -> None:
def add_input(
self,
arg: Union[Store, StorePartition],
proj: Optional[ProjFn] = None,
proj: Optional[Union[ProjFn, int]] = None,
) -> None:
"""
Adds a store as input to the task
Expand Down Expand Up @@ -918,10 +957,9 @@ def add_output(
self._check_arg(arg)
if isinstance(arg, Store):
if arg.unbound:
raise NotImplementedError(
"Unbound store cannot be used with "
"manually parallelized task"
)
self._unbound_outputs.append(len(self._outputs))
self._outputs.append(arg)
return
if arg.kind is Future:
self._scalar_outputs.append(len(self._outputs))
self._outputs.append(arg)
Expand Down Expand Up @@ -1006,6 +1044,16 @@ def launch(self, strategy: Strategy) -> None:
part.store, req, tag=0, read_write=can_read_write
)

for fm in self._scalar_future_maps:
launcher.add_future_map(fm)

# Add all unbound stores.
for store_idx in self._unbound_outputs:
store = self._outputs[store_idx]
fspace = self.context.runtime.create_field_space()
field_id = fspace.allocate_field(store.type)
launcher.add_unbound_output(store, fspace, field_id)

self._add_scalar_args_to_launcher(launcher)

launcher.set_can_raise_exception(self.can_raise_exception)
Expand Down
Loading