From bacb1861dd415dc0694feb9195f7066ceb7af8f2 Mon Sep 17 00:00:00 2001 From: Rohan Yadav Date: Fri, 9 Sep 2022 10:15:02 -0700 Subject: [PATCH 1/5] cunumeric: make the attach hack configurable by `-cunumeric:attach-hack` --- cunumeric/runtime.py | 51 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/cunumeric/runtime.py b/cunumeric/runtime.py index ce64874b2d..b46f6c2fb1 100644 --- a/cunumeric/runtime.py +++ b/cunumeric/runtime.py @@ -96,6 +96,15 @@ help="Turn on warnings", ), ), + Argument( + "attach-hack", + ArgSpec( + action="store_true", + default=False, + dest="attach_hack", + help="Enable the attach hack which avoids attaching in certain cases by doing direct writes. This may be needed for multi-node runs of some applications.", # noqa E501 + ), + ), Argument( "report:coverage", ArgSpec( @@ -539,17 +548,37 @@ def find_or_create_array_thunk( shape=array.shape, optimize_scalar=False, ) - store.attach_external_allocation( - self.legate_context, - array.data, - share, - ) - return DeferredArray( - self, - store, - dtype=array.dtype, - numpy_array=array if share else None, - ) + # If the attach hack is enabled, do writes from the input array + # into the resulting array. Otherwise, do an attach. The attach + # hack enables scaling to multiple nodes when restricted + # attaches must be performed. + if self.args.attach_hack: + assert not share + thunk = DeferredArray( + self, + store, + dtype=array.dtype, + ) + for index in np.ndindex(array.shape): + thunk.set_item( + index, + self.create_wrapped_scalar( + array[index], array.dtype, () + ), + ) + return thunk + else: + store.attach_external_allocation( + self.legate_context, + array.data, + share, + ) + return DeferredArray( + self, + store, + dtype=array.dtype, + numpy_array=array if share else None, + ) assert not defer # Make this into an eager evaluated thunk From 39c6b6c351ef271522087c7ffa5ad64b44965a99 Mon Sep 17 00:00:00 2001 From: Manolis Papadakis Date: Wed, 21 Sep 2022 14:43:24 -0700 Subject: [PATCH 2/5] Allow casting in cn.dot, to match numpy's behavior (#598) --- cunumeric/array.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cunumeric/array.py b/cunumeric/array.py index 9097429f83..270c612ed6 100644 --- a/cunumeric/array.py +++ b/cunumeric/array.py @@ -2545,7 +2545,7 @@ def dot(self, rhs: Any, out: Union[ndarray, None] = None) -> ndarray: self, rhs, out=out, - casting="no", + casting="unsafe", ) def dump(self, file: Union[str, Path]) -> None: From cad2d7767c1528b7779f4e7226de194a4d84b870 Mon Sep 17 00:00:00 2001 From: Rohan Yadav Date: Fri, 30 Sep 2022 13:25:45 -0700 Subject: [PATCH 3/5] conda: update environment scripts for supercomputer clusters --- conda/environment-cluster-3.10.yml | 57 ++++++++++++++++++++++++++++++ conda/environment-cluster-3.8.yml | 57 ++++++++++++++++++++++++++++++ conda/environment-cluster-3.9.yml | 57 ++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 conda/environment-cluster-3.10.yml create mode 100644 conda/environment-cluster-3.8.yml create mode 100644 conda/environment-cluster-3.9.yml diff --git a/conda/environment-cluster-3.10.yml b/conda/environment-cluster-3.10.yml new file mode 100644 index 0000000000..9fd6553ae5 --- /dev/null +++ b/conda/environment-cluster-3.10.yml @@ -0,0 +1,57 @@ +name: cunumeric-test +channels: + - conda-forge +dependencies: + - python=3.10 + + # build + - git + - nccl + - make + - zlib + - cmake>=3.24 + - ninja + - sysroot_linux-64==2.17 # [linux64] + - setuptools>=60 + - cutensor>=1.3.3 + - scikit-build>=0.13.1 + + # runtime + - cffi + - numpy>=1.22 + - opt_einsum + - pyarrow>=5 + - scipy + - typing_extensions + - llvm-openmp + - openblas=*=*openmp* + + # tests + - clang>=8 + - clang-tools>=8 + - colorama + - coverage + - mock + - mypy>=0.961 + - pre-commit + - pynvml + - pytest + - pytest-cov + - pytest-mock + - pytest-lazy-fixture + - types-docutils + + # pip dependencies + - pip + - pip: + # docs + - jinja2 + - pydata-sphinx-theme + - recommonmark + - markdown<3.4.0 + - sphinx>=4.4.0 + - sphinx-copybutton + - sphinx-markdown-tables + + # examples + - tifffile diff --git a/conda/environment-cluster-3.8.yml b/conda/environment-cluster-3.8.yml new file mode 100644 index 0000000000..1e153ed850 --- /dev/null +++ b/conda/environment-cluster-3.8.yml @@ -0,0 +1,57 @@ +name: cunumeric-test +channels: + - conda-forge +dependencies: + - python=3.8 + + # build + - git + - nccl + - make + - zlib + - cmake>=3.24 + - ninja + - sysroot_linux-64==2.17 # [linux64] + - setuptools>=60 + - cutensor>=1.3.3 + - scikit-build>=0.13.1 + + # runtime + - cffi + - numpy>=1.22 + - opt_einsum + - pyarrow>=5 + - scipy + - typing_extensions + - llvm-openmp + - openblas=*=*openmp* + + # tests + - clang>=8 + - clang-tools>=8 + - colorama + - coverage + - mock + - mypy>=0.961 + - pre-commit + - pynvml + - pytest + - pytest-cov + - pytest-mock + - pytest-lazy-fixture + - types-docutils + + # pip dependencies + - pip + - pip: + # docs + - jinja2 + - pydata-sphinx-theme + - recommonmark + - markdown<3.4.0 + - sphinx>=4.4.0 + - sphinx-copybutton + - sphinx-markdown-tables + + # examples + - tifffile diff --git a/conda/environment-cluster-3.9.yml b/conda/environment-cluster-3.9.yml new file mode 100644 index 0000000000..e4b0fbbded --- /dev/null +++ b/conda/environment-cluster-3.9.yml @@ -0,0 +1,57 @@ +name: cunumeric-test +channels: + - conda-forge +dependencies: + - python=3.9 + + # build + - git + - nccl + - make + - zlib + - cmake>=3.24 + - ninja + - sysroot_linux-64==2.17 # [linux64] + - setuptools>=60 + - cutensor>=1.3.3 + - scikit-build>=0.13.1 + + # runtime + - cffi + - numpy>=1.22 + - opt_einsum + - pyarrow>=5 + - scipy + - typing_extensions + - llvm-openmp + - openblas=*=*openmp* + + # tests + - clang>=8 + - clang-tools>=8 + - colorama + - coverage + - mock + - mypy>=0.961 + - pre-commit + - pynvml + - pytest + - pytest-cov + - pytest-mock + - pytest-lazy-fixture + - types-docutils + + # pip dependencies + - pip + - pip: + # docs + - jinja2 + - pydata-sphinx-theme + - recommonmark + - markdown<3.4.0 + - sphinx>=4.4.0 + - sphinx-copybutton + - sphinx-markdown-tables + + # examples + - tifffile From 6b3d0eb042ce7075fb1f3202461a45028c511f71 Mon Sep 17 00:00:00 2001 From: Rohan Yadav Date: Sat, 26 Nov 2022 15:20:24 -0800 Subject: [PATCH 4/5] conda: update cmake version in conda envs Signed-off-by: Rohan Yadav --- conda/environment-cluster-3.10.yml | 2 +- conda/environment-cluster-3.8.yml | 2 +- conda/environment-cluster-3.9.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conda/environment-cluster-3.10.yml b/conda/environment-cluster-3.10.yml index 9fd6553ae5..9737568f7a 100644 --- a/conda/environment-cluster-3.10.yml +++ b/conda/environment-cluster-3.10.yml @@ -9,7 +9,7 @@ dependencies: - nccl - make - zlib - - cmake>=3.24 + - cmake==3.24 - ninja - sysroot_linux-64==2.17 # [linux64] - setuptools>=60 diff --git a/conda/environment-cluster-3.8.yml b/conda/environment-cluster-3.8.yml index 1e153ed850..32085c95f0 100644 --- a/conda/environment-cluster-3.8.yml +++ b/conda/environment-cluster-3.8.yml @@ -9,7 +9,7 @@ dependencies: - nccl - make - zlib - - cmake>=3.24 + - cmake==3.24 - ninja - sysroot_linux-64==2.17 # [linux64] - setuptools>=60 diff --git a/conda/environment-cluster-3.9.yml b/conda/environment-cluster-3.9.yml index e4b0fbbded..f75299c855 100644 --- a/conda/environment-cluster-3.9.yml +++ b/conda/environment-cluster-3.9.yml @@ -9,7 +9,7 @@ dependencies: - nccl - make - zlib - - cmake>=3.24 + - cmake==3.24 - ninja - sysroot_linux-64==2.17 # [linux64] - setuptools>=60 From 2c2d35523731e0d27c96c8c2f33f7f1f25d0132e Mon Sep 17 00:00:00 2001 From: Rohan Yadav Date: Wed, 18 Jan 2023 22:52:34 -0800 Subject: [PATCH 5/5] cunumeric: implement a somewhat broken version of broadcast_to (and fix some mypy errors) Signed-off-by: Rohan Yadav --- cunumeric/coverage.py | 4 ++-- cunumeric/module.py | 15 +++++++++++++++ cunumeric/runtime.py | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cunumeric/coverage.py b/cunumeric/coverage.py index f8f4446aed..982769dc13 100644 --- a/cunumeric/coverage.py +++ b/cunumeric/coverage.py @@ -116,8 +116,8 @@ def wrapper(*args: Any, **kwargs: Any) -> Any: # ufuncs the way we need it to. The alternative would be to vendor and # modify a custom version of @wraps if hasattr(wrapper.__wrapped__, "_name"): - wrapper.__name__ = wrapper.__wrapped__._name - wrapper.__qualname__ = wrapper.__wrapped__._name + wrapper.__name__ = wrapper.__wrapped__._name # type: ignore + wrapper.__qualname__ = wrapper.__wrapped__._name # type: ignore # TODO (bev) Scraping text to set flags seems a bit fragile. It would be # preferable to start with flags, and use those to update docstrings. diff --git a/cunumeric/module.py b/cunumeric/module.py index a2a9720875..4337b7cebf 100644 --- a/cunumeric/module.py +++ b/cunumeric/module.py @@ -1129,6 +1129,21 @@ def reshape( return a.reshape(newshape, order=order) +# Support a very basic (and incorrect in the general case) version of +# broadcast_to that only works if we don't perform direct writes to +# the underlying array. +@add_boilerplate("array") +def broadcast_to( + array: ndarray, shape: NdShapeLike, subok: bool = False +) -> ndarray: + from .deferred import DeferredArray + + thunk = array._thunk + store = thunk._broadcast(shape) # type: ignore + new_thunk = DeferredArray(thunk.runtime, store, array.dtype) + return ndarray(shape, dtype=array.dtype, thunk=new_thunk) + + # Transpose-like operations diff --git a/cunumeric/runtime.py b/cunumeric/runtime.py index 6a50fe4a8f..d4d3e36522 100644 --- a/cunumeric/runtime.py +++ b/cunumeric/runtime.py @@ -368,7 +368,7 @@ def get_numpy_thunk( ) -> NumPyThunk: # Check to see if this object implements the Legate data interface if hasattr(obj, "__legate_data_interface__"): - legate_data = obj.__legate_data_interface__ + legate_data = obj.__legate_data_interface__ # type: ignore if legate_data["version"] != 1: raise NotImplementedError( "Need support for other Legate data interface versions"