Пример #1
0
    def __init__(self, targets=None):

        if MPIContext.INTERCOMM is None:
            MPIContext.INTERCOMM = initial_comm_setup()
            assert get_world_rank() == 0

        self.nengines = MPIContext.INTERCOMM.remote_size
        self.all_targets = list(range(self.nengines))
        self.targets = self.all_targets if targets is None else sorted(targets)

        # make/get comms
        # this is the object we want to use with push, pull, etc'
        self._comm_from_targets = {}
        self.comm = self.make_subcomm(self.targets)

        if BaseContext._CLEANUP is None:
            BaseContext._CLEANUP = atexit.register(_shutdown, mpi,
                                                   MPIContext.INTERCOMM,
                                                   tuple(self.all_targets))

        # local imports
        self._execute(
            "from functools import reduce; "
            "from importlib import import_module; "
            "import distarray.localapi; "
            "import distarray.localapi.mpiutils; "
            "import distarray.utils; "
            "from distarray.localapi.proxyize import Proxyize, Proxy; "
            "import numpy")

        self.context_key = self._setup_context_key()

        # setup proxyize which is used by context.apply in the rest of the
        # setup.
        cmd = "proxyize = Proxyize()"
        self._execute(cmd)
Пример #2
0
    def __init__(self, targets=None):

        if MPIContext.INTERCOMM is None:
            MPIContext.INTERCOMM = initial_comm_setup()
            assert get_world_rank() == 0

        self.nengines = MPIContext.INTERCOMM.remote_size
        self.all_targets = list(range(self.nengines))
        self.targets = self.all_targets if targets is None else sorted(targets)

        # make/get comms
        # this is the object we want to use with push, pull, etc'
        self._comm_from_targets = {}
        self.comm = self.make_subcomm(self.targets)

        if BaseContext._CLEANUP is None:
            BaseContext._CLEANUP = atexit.register(_shutdown,
                                               mpi,
                                               MPIContext.INTERCOMM,
                                               tuple(self.all_targets))

        # local imports
        self._execute("from functools import reduce; "
                          "from importlib import import_module; "
                          "import distarray.localapi; "
                          "import distarray.localapi.mpiutils; "
                          "import distarray.utils; "
                          "from distarray.localapi.proxyize import Proxyize, Proxy; "
                          "import numpy")

        self.context_key = self._setup_context_key()

        # setup proxyize which is used by context.apply in the rest of the
        # setup.
        cmd = "proxyize = Proxyize()"
        self._execute(cmd)
Пример #3
0
def mpi_print(*args, **kwargs):
    from distarray.mpionly_utils import get_world_rank
    print("[%d]" % get_world_rank(), *args, **kwargs)
Пример #4
0
def mpi_print(*args, **kwargs):
    from distarray.mpionly_utils import get_world_rank
    print("[%d]" % get_world_rank(), *args, **kwargs)