From c363fd6543515fded0718485906a3847890a33ed Mon Sep 17 00:00:00 2001 From: arunjose696 Date: Mon, 23 Oct 2023 09:59:40 -0500 Subject: [PATCH] using numpy to alter values of service buffer --- environment.yml | 1 + requirements.txt | 1 + unidist/core/backends/mpi/core/shared_object_store.py | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/environment.yml b/environment.yml index f4a92ab9..9150d9ea 100644 --- a/environment.yml +++ b/environment.yml @@ -16,6 +16,7 @@ dependencies: - cython - psutil - pytest + - numpy # for downloading packages from PyPI - pip - pip: diff --git a/requirements.txt b/requirements.txt index 6b366ec2..dd14ef16 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,7 @@ dask[complete]>=2.22.0 distributed>=2.22.0 mpi4py>=3.0.3 msgpack>=1.0.0 +numpy # https://github.com/modin-project/unidist/issues/324 pydantic<2 ray[default]>=1.13.0 diff --git a/unidist/core/backends/mpi/core/shared_object_store.py b/unidist/core/backends/mpi/core/shared_object_store.py index 538a5448..97fcd713 100644 --- a/unidist/core/backends/mpi/core/shared_object_store.py +++ b/unidist/core/backends/mpi/core/shared_object_store.py @@ -10,6 +10,7 @@ import psutil import weakref from array import array +import numpy as np from unidist.core.backends.mpi.core._memory import parallel_memcopy from unidist.core.backends.mpi.utils import ImmutableDict @@ -190,9 +191,8 @@ def _allocate_shared_memory(self): self.service_shared_buffer = memoryview(service_buffer).cast("l") # Set -1 to the service buffer because 0 is a valid value and may be recognized by mistake. if mpi_state.is_monitor_process(): - self.service_shared_buffer[:] = array( - "l", [-1] * len(self.service_shared_buffer) - ) + memoryview_array = np.frombuffer(self.service_shared_buffer,dtype=np.int64) + memoryview_array[:] = -1 def _parse_data_id(self, data_id): """