diff --git a/conda/environment-cluster-3.10.yml b/conda/environment-cluster-3.10.yml new file mode 100644 index 0000000000..9737568f7a --- /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..32085c95f0 --- /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..f75299c855 --- /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 diff --git a/cunumeric/module.py b/cunumeric/module.py index 9e2175d9bd..03545d39b2 100644 --- a/cunumeric/module.py +++ b/cunumeric/module.py @@ -1130,6 +1130,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 f0ad0398b5..9ce560ce7f 100644 --- a/cunumeric/runtime.py +++ b/cunumeric/runtime.py @@ -462,17 +462,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 settings.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 diff --git a/cunumeric/settings.py b/cunumeric/settings.py index c781ac279d..394f118260 100644 --- a/cunumeric/settings.py +++ b/cunumeric/settings.py @@ -53,6 +53,18 @@ class CunumericRuntimeSettings(Settings): """, ) + attach_hack: PrioritizedSetting[bool] = PrioritizedSetting( + "attach-hack", + "CUNUMERIC_ATTACH_HACK", + default=False, + convert=convert_bool, + 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. + """, + ) + report_coverage: PrioritizedSetting[bool] = PrioritizedSetting( "report_coverage", "CUNUMERIC_REPORT_COVERAGE",